{% extends 'admin/change_form.html' %}

{% comment %}
    This template is required to supply information regarding the displayed object
    from Django's template context to JavaScript for proper functioning of object notification
    widget. Following data is supplied:
        1. object's app_label
        2. object's model_name
        3. object's primary key
{% endcomment %}

{% block admin_change_form_document_ready %}
    {{ block.super }}
    {% if change %}
        <script>
            const owNotifyAppLabel = '{{ opts.app_label }}',
                owNotifyModelName = '{{ opts.model_name }}',
                uuidRegex = /\/((\w{4,12}-?)){5}\//,
                owIsChangeForm = true;
            let objectId;
            try{
                objectId = uuidRegex.exec(window.location)[0];
            }
            catch(error){
                try{
                    objectId = /\/(\d+)\//.exec(window.location)[0];
                }
                catch(error){
                    throw error;
                }
            }
            const owNotifyObjectId = objectId.replace(/\//g,'');
        </script>
    {% endif %}
{% endblock %}
