<commit_before>{% extends 'front/base.html' %}
{% load tabs %}

{% block title %}Dokument {{ documentcategory.name }} {{ document|yesno:"bearbeiten,hinzufügen" }}{% endblock %}

{% block navigation %}
    {% activetab 'navigation' 'documents' %}
    {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <a href="{% url 'documentcategory_list' %}">Dokumente</a> &raquo;
    <a href="{% url 'document_list' documentcategory.name|slugify %}">{{ documentcategory.name }}</a> &raquo;
    Dokument {{ document|yesno:"bearbeiten,hinzufügen" }}
{% endblock %}

{% block scripts %}
    {{ block.super }}
    <script type="text/javascript">
        $(document).ready(function() {
            var field_dtype = $('#id_dtype');
            var field_public = $('#id_public');

            // Initial state of "public" field
            if (field_dtype.val() == {{ exam_dtype_id|default:-1 }}) {
                field_public.parents('.control-group').addClass('hidden');
                field_public.prop('checked', false);
            }

            // Show or hide "public" field on dtype change
            var previous_checked_state = field_public.prop('checked');
            field_dtype.change(function() {
                if ($(this).val() == {{ exam_dtype_id|default:-1 }}) {
                    field_public.parents('.control-group').addClass('hidden');
                    previous_checked_state = field_public.prop('checked');
                    field_public.prop('checked', false);
                } else {
                    field_public.parents('.control-group').removeClass('hidden');
                    field_public.prop('checked', previous_checked_state);
                }
            });
        });
    </script>
{% endblock %}

{% block content %}

    <div class="page-header">
        <h1>Dokument {{ documentcategory.name }} {{ document|yesno:"bearbeiten,hinzufügen" }}</h1>
    </div>

    <form method="POST" enctype="multipart/form-data" class="form-horizontal">{% csrf_token %}
        {% include 'lib/form_loop.html' %}
        <div class="form-actions">
            <button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> {{ document|yesno:"Speichern,Eintragen" }}</button>
            <a href="{% url 'document_list' documentcategory.name|slugify %}" class="btn"><i class="icon-remove"></i> Abbrechen</a>
        </div>
    </form>
{% endblock %}<commit_msg>No license chooser for exams (fixes #114)<commit_after>{% extends 'front/base.html' %}
{% load tabs %}

{% block title %}Dokument {{ documentcategory.name }} {{ document|yesno:"bearbeiten,hinzufügen" }}{% endblock %}

{% block navigation %}
    {% activetab 'navigation' 'documents' %}
    {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <a href="{% url 'documentcategory_list' %}">Dokumente</a> &raquo;
    <a href="{% url 'document_list' documentcategory.name|slugify %}">{{ documentcategory.name }}</a> &raquo;
    Dokument {{ document|yesno:"bearbeiten,hinzufügen" }}
{% endblock %}

{% block scripts %}
    {{ block.super }}
    <script type="text/javascript">
        $(document).ready(function() {
            var field_dtype = $('#id_dtype');
            var field_license = $('#id_license');
            var field_public = $('#id_public');

            // Initial state of "public" and "license" fields
            if (field_dtype.val() == {{ exam_dtype_id|default:-1 }}) {
                field_public.parents('.control-group').addClass('hidden');
                field_public.prop('checked', false);

                field_license.parents('.control-group').addClass('hidden');
                field_license.val('');
            }

            // Show or hide "public" and "license" field on dtype change
            var previous_checked_state = field_public.prop('checked');
            var previous_license = field_license.val();
            field_dtype.change(function() {
                if ($(this).val() == {{ exam_dtype_id|default:-1 }}) {
                    field_public.parents('.control-group').addClass('hidden');
                    previous_checked_state = field_public.prop('checked');
                    field_public.prop('checked', false);

                    field_license.parents('.control-group').addClass('hidden');
                    previous_license = field_license.val();
                    field_license.val('');
                } else {
                    field_public.parents('.control-group').removeClass('hidden');
                    field_public.prop('checked', previous_checked_state);

                    field_license.parents('.control-group').removeClass('hidden');
                    field_license.val(previous_license);
                }
            });
        });
    </script>
{% endblock %}

{% block content %}

    <div class="page-header">
        <h1>Dokument {{ documentcategory.name }} {{ document|yesno:"bearbeiten,hinzufügen" }}</h1>
    </div>

    <form method="POST" enctype="multipart/form-data" class="form-horizontal">{% csrf_token %}
        {% include 'lib/form_loop.html' %}
        <div class="form-actions">
            <button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> {{ document|yesno:"Speichern,Eintragen" }}</button>
            <a href="{% url 'document_list' documentcategory.name|slugify %}" class="btn"><i class="icon-remove"></i> Abbrechen</a>
        </div>
    </form>
{% endblock %}
{'fraction_non_alphanumeric': 0.1705340699815838, 'fraction_numerical': 0.0020257826887661143, 'mean_word_length': 2.5543193717277486, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1552162', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1526, 'n_words': 270}