tabular.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {% load i18n admin_urls admin_static admin_modify %}
  2. <div class="module" id="inline_module_{{ index }}">
  3. <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
  4. <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
  5. {{ inline_admin_formset.formset.management_form }}
  6. <fieldset class="module">
  7. {% if errors %}
  8. <p class="errornote">
  9. {% trans "Please correct the errors below." %}
  10. </p>
  11. {% endif %}
  12. {{ inline_admin_formset.formset.non_form_errors }}
  13. <table>
  14. <thead><tr>
  15. <th></th>
  16. {% for field in inline_admin_formset.fields %}
  17. {% if not field.widget.is_hidden %}
  18. <th{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}
  19. {% if field.help_text %}&nbsp;<img src="{% static "admin/img/icon-unknown.gif" %}" class="help help-tooltip" width="10" height="10" alt="({{ field.help_text|striptags }})" title="{{ field.help_text|striptags }}" />{% endif %}
  20. </th>
  21. {% endif %}
  22. {% endfor %}
  23. {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
  24. </tr></thead>
  25. <tbody>
  26. {% for inline_admin_form in inline_admin_formset %}
  27. {% if inline_admin_form.form.non_field_errors %}
  28. <tr><td colspan="{{ inline_admin_form|cell_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
  29. {% endif %}
  30. <tr class="form-row {% cycle "row1" "row2" %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
  31. id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
  32. <td class="original">
  33. {% if inline_admin_form.original or inline_admin_form.show_url %}<p>
  34. {% if inline_admin_form.original %}
  35. {% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
  36. <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" title="{% trans "Change" %} {{ inline_admin_form.original }}" class="inlinechangelink">
  37. <span class="icon-edit"></span>
  38. </a>
  39. {% endif %}
  40. {% endif %}
  41. {% if inline_admin_form.show_url %}
  42. <a href="{{ inline_admin_form.absolute_url }}" title="{% trans "View on site" %}">
  43. <span class="icon-open-external"></span>
  44. </a>
  45. {% endif %}
  46. </p>{% endif %}
  47. {% if not inline_admin_form.original %}
  48. <span class="icon-new"></span>
  49. {% endif %}
  50. {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
  51. {{ inline_admin_form.fk_field.field }}
  52. {% spaceless %}
  53. {% for fieldset in inline_admin_form %}
  54. {% for line in fieldset %}
  55. {% for field in line %}
  56. {% if field.field.is_hidden %} {{ field.field }} {% endif %}
  57. {% endfor %}
  58. {% endfor %}
  59. {% endfor %}
  60. {% endspaceless %}
  61. </td>
  62. {% for fieldset in inline_admin_form %}
  63. {% for line in fieldset %}
  64. {% for field in line %}
  65. {% if not field.field.is_hidden %}
  66. <td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}>
  67. {% if field.is_readonly %}
  68. <p>{{ field.contents }}</p>
  69. {% else %}
  70. {{ field.field.errors.as_ul }}
  71. {{ field.field }}
  72. {% endif %}
  73. </td>
  74. {% endif %}
  75. {% endfor %}
  76. {% endfor %}
  77. {% endfor %}
  78. {% if inline_admin_formset.formset.can_delete %}
  79. <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
  80. {% endif %}
  81. </tr>
  82. {% endfor %}
  83. </tbody>
  84. </table>
  85. </fieldset>
  86. </div>
  87. </div>
  88. </div>
  89. <script type="text/javascript">
  90. (function($) {
  91. $("#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr").tabularFormset({
  92. prefix: "{{ inline_admin_formset.formset.prefix }}",
  93. adminStaticPrefix: '{% static "admin/" %}',
  94. addText: "<span class=\"icon-add\"></span> {% blocktrans with inline_admin_formset.opts.verbose_name|capfirst as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
  95. deleteText: "{% trans 'Remove' %}"
  96. });
  97. })(django.jQuery);
  98. </script>