change_form.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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; {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
  15. &rsaquo; {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
  16. </div>
  17. {% endblock %}
  18. {% endif %}
  19. {% block content %}
  20. <div id="content-main">
  21. <div class="changeform-object-tools">
  22. {% block object-tools %}
  23. {% if change %}
  24. {% if not is_popup %}
  25. <ul class="object-tools horizontal">
  26. {% block object-tools-items %}
  27. <li>
  28. {% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
  29. <a href="{% jet_add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
  30. </li>
  31. {% if has_absolute_url %}
  32. <li><a href="{{ absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>
  33. {% endif %}
  34. {% endblock %}
  35. </ul>
  36. {% endif %}
  37. {% endif %}
  38. {% endblock %}
  39. </div>
  40. <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>
  41. {% csrf_token %}
  42. {% block form_top %}{% endblock %}
  43. {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
  44. {% filter_fieldsets_with_errors adminform as fieldsets_with_errors %}
  45. <div class="changeform">
  46. {% if adminform.fieldsets|length > 1 or inline_admin_formsets|length > 0 %}
  47. <ul class="changeform-tabs">
  48. {% for fieldset in adminform %}
  49. {% is_fieldset_selected forloop.counter0 fieldsets_with_errors as selected %}
  50. {% is_fieldset_with_errors forloop.counter0 fieldsets_with_errors as fieldset_with_errors %}
  51. <li class="changeform-tabs-item{% if selected %} selected{% endif %}{% if fieldset_with_errors %} errors{% endif %}">
  52. <a href="#" class="changeform-tabs-item-link" data-module-id="module_{{ forloop.counter0 }}">
  53. {% if fieldset.name %}
  54. {{ fieldset.name }}
  55. {% else %}
  56. {% trans "General" %}
  57. {% endif %}
  58. </a>
  59. </li>
  60. {% endfor %}
  61. {% for inline_admin_formset in inline_admin_formsets %}
  62. {% formset_has_errors inline_admin_formset.formset as errors %}
  63. <li class="changeform-tabs-item{% if errors %} errors{% endif %}">
  64. <a href="#" class="changeform-tabs-item-link" data-module-id="inline_module_{{ forloop.counter0 }}">
  65. {{ inline_admin_formset.opts.verbose_name_plural|capfirst }}
  66. </a>
  67. </li>
  68. {% endfor %}
  69. </ul>
  70. {% endif %}
  71. {% if is_popup %}<input type="hidden" name="{{ is_popup_var|default:"_popup" }}" value="1" />{% endif %}
  72. {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
  73. {% if errors %}
  74. {{ adminform.form.non_field_errors }}
  75. {% endif %}
  76. {% block field_sets %}
  77. {% for fieldset in adminform %}
  78. {% is_fieldset_selected forloop.counter0 fieldsets_with_errors as selected %}
  79. {% is_fieldset_with_errors forloop.counter0 fieldsets_with_errors as fieldset_with_errors %}
  80. {% include "admin/includes/fieldset.html" with index=forloop.counter0 selected=selected errors=fieldset_with_errors %}
  81. {% endfor %}
  82. {% endblock %}
  83. {% block after_field_sets %}{% endblock %}
  84. {% block inline_field_sets %}
  85. {% for inline_admin_formset in inline_admin_formsets %}
  86. {% formset_has_errors inline_admin_formset.formset as errors %}
  87. {% include inline_admin_formset.opts.template with index=forloop.counter0 errors=errors %}
  88. {% endfor %}
  89. {% endblock %}
  90. {% block after_related_objects %}{% endblock %}
  91. {% block admin_change_form_document_ready %}
  92. <script type="text/javascript">
  93. (function($) {
  94. {# JET: Add handlers for Django <= 1.6 #}
  95. $(document).ready(function() {
  96. $('.add-another').removeAttr('onclick').click(function(e) {
  97. e.preventDefault();
  98. showAddAnotherPopup(this);
  99. });
  100. $('.related-lookup').removeAttr('onclick').click(function(e) {
  101. e.preventDefault();
  102. showRelatedObjectLookupPopup(this);
  103. });
  104. {% if adminform and add %}
  105. $('form#{{ opts.model_name }}_form :input:visible:enabled:first').focus()
  106. {% endif %}
  107. });
  108. })(django.jQuery);
  109. </script>
  110. {% endblock %}
  111. {# JavaScript for prepopulated fields #}
  112. {% prepopulated_fields_js %}
  113. </div>
  114. {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
  115. </form>
  116. </div>
  117. {% endblock %}