change_form.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {% extends "admin/base_site.html" %}
  2. {% load i18n admin_urls admin_static admin_modify jet_tags %}
  3. {% block extrahead %}
  4. {{ block.super }}
  5. {{ media }}
  6. {% endblock %}
  7. {% block coltype %}colM{% endblock %}
  8. {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}
  9. {% if not is_popup %}
  10. {% block breadcrumbs %}
  11. <div class="breadcrumbs">
  12. <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
  13. &rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{% if opts.app_config.verbose_name %}{{ opts.app_config.verbose_name }}{% else %}{% trans app_label as app_label %}{{ app_label|capfirst|escape }}{% endif %}</a>
  14. &rsaquo;
  15. {% if has_change_permission %}
  16. {% url opts|admin_urlname:'changelist' as url %}
  17. <a href="{% jet_add_preserved_filters url %}">{{ opts.verbose_name_plural|capfirst }}</a>
  18. {% else %}
  19. {{ opts.verbose_name_plural|capfirst }}
  20. {% endif %}
  21. &rsaquo; {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
  22. </div>
  23. {% endblock %}
  24. {% endif %}
  25. {% block content %}
  26. <div id="content-main">
  27. <div class="cf">
  28. {% jet_change_form_sibling_links_enabled as show_siblings %}
  29. {% if change and show_siblings %}
  30. <div class="changeform-navigation">
  31. {% spaceless %}
  32. {% jet_previous_object_url as url %}
  33. <a{% if url %} href="{{ url }}"{% endif %} class="segmented-button left{% if not url %} disabled{% endif %}">
  34. {% trans "←" %}
  35. </a>
  36. {% jet_next_object_url as url %}
  37. <a{% if url %} href="{{ url }}"{% endif %} class="segmented-button right{% if not url %} disabled{% endif %}">
  38. {% trans "→" %}
  39. </a>
  40. {% endspaceless %}
  41. </div>
  42. {% endif %}
  43. <div class="changeform-object-tools">
  44. {% block object-tools %}
  45. {% if change %}
  46. {% if not is_popup %}
  47. <ul class="object-tools horizontal">
  48. {% block object-tools-items %}
  49. <li>
  50. {% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
  51. <a href="{% jet_add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
  52. </li>
  53. {% if has_absolute_url %}
  54. <li><a href="{{ absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>
  55. {% endif %}
  56. {% endblock %}
  57. </ul>
  58. {% endif %}
  59. {% endif %}
  60. {% endblock %}
  61. </div>
  62. </div>
  63. <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>
  64. {% csrf_token %}
  65. {% block form_top %}{% endblock %}
  66. {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
  67. {% filter_fieldsets_with_errors adminform as fieldsets_with_errors %}
  68. <div class="changeform">
  69. {% if adminform.fieldsets|length > 1 or inline_admin_formsets|length > 0 %}
  70. <ul class="changeform-tabs">
  71. {% for fieldset in adminform %}
  72. {% is_fieldset_selected forloop.counter0 fieldsets_with_errors as selected %}
  73. {% is_fieldset_with_errors forloop.counter0 fieldsets_with_errors as fieldset_with_errors %}
  74. <li class="changeform-tabs-item{% if selected %} selected{% endif %}{% if fieldset_with_errors %} errors{% endif %}">
  75. <a href="#/module_{{ forloop.counter0 }}" class="changeform-tabs-item-link" data-module-id="module_{{ forloop.counter0 }}">
  76. {% if fieldset.name %}
  77. {{ fieldset.name }}
  78. {% else %}
  79. {% trans "General" %}
  80. {% endif %}
  81. </a>
  82. </li>
  83. {% endfor %}
  84. {% for inline_admin_formset in inline_admin_formsets %}
  85. {% formset_has_errors inline_admin_formset.formset as errors %}
  86. <li class="changeform-tabs-item{% if errors %} errors{% endif %}">
  87. <a href="#/inline_module_{{ forloop.counter0 }}" class="changeform-tabs-item-link" data-module-id="inline_module_{{ forloop.counter0 }}">
  88. {{ inline_admin_formset.opts.verbose_name_plural|capfirst }}
  89. </a>
  90. </li>
  91. {% endfor %}
  92. </ul>
  93. {% endif %}
  94. {% if is_popup %}<input type="hidden" name="{{ is_popup_var|default:"_popup" }}" value="1" />{% endif %}
  95. {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
  96. {% if errors %}
  97. {{ adminform.form.non_field_errors }}
  98. {% endif %}
  99. {% block field_sets %}
  100. {% for fieldset in adminform %}
  101. {% is_fieldset_selected forloop.counter0 fieldsets_with_errors as selected %}
  102. {% is_fieldset_with_errors forloop.counter0 fieldsets_with_errors as fieldset_with_errors %}
  103. {% include "admin/includes/fieldset.html" with index=forloop.counter0 selected=selected errors=fieldset_with_errors %}
  104. {% endfor %}
  105. {% endblock %}
  106. {% block after_field_sets %}{% endblock %}
  107. {% block inline_field_sets %}
  108. {% for inline_admin_formset in inline_admin_formsets %}
  109. {% formset_has_errors inline_admin_formset.formset as errors %}
  110. {% include inline_admin_formset.opts.template with index=forloop.counter0 errors=errors %}
  111. {% endfor %}
  112. {% endblock %}
  113. {% block after_related_objects %}{% endblock %}
  114. {% block admin_change_form_document_ready %}
  115. <script type="text/javascript">
  116. (function($) {
  117. {# JET: Add handlers for Django <= 1.6 #}
  118. $(document).ready(function() {
  119. $('.add-another').removeAttr('onclick').click(function(e) {
  120. e.preventDefault();
  121. showAddAnotherPopup(this);
  122. });
  123. $('.related-lookup').removeAttr('onclick').click(function(e) {
  124. e.preventDefault();
  125. showRelatedObjectLookupPopup(this);
  126. });
  127. {% if adminform and add %}
  128. $('form#{{ opts.model_name }}_form :input:visible:enabled:first').focus()
  129. {% endif %}
  130. });
  131. })(django.jQuery);
  132. </script>
  133. {% endblock %}
  134. {# JavaScript for prepopulated fields #}
  135. {% prepopulated_fields_js %}
  136. </div>
  137. {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
  138. </form>
  139. </div>
  140. {% endblock %}