PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/admin/templates/admin/edit_inline/tabular.html

https://code.google.com/p/mango-py/
HTML | 128 lines | 126 code | 2 blank | 0 comment | 0 complexity | 7ac2e71bc8da08681c2cc290711b4750 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. {% load i18n adminmedia admin_modify %}
  2. <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
  3. <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
  4. {{ inline_admin_formset.formset.management_form }}
  5. <fieldset class="module">
  6. <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
  7. {{ inline_admin_formset.formset.non_form_errors }}
  8. <table>
  9. <thead><tr>
  10. {% for field in inline_admin_formset.fields %}
  11. {% if not field.widget.is_hidden %}
  12. <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
  13. {% endif %}
  14. {% endfor %}
  15. {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
  16. </tr></thead>
  17. <tbody>
  18. {% for inline_admin_form in inline_admin_formset %}
  19. {% if inline_admin_form.form.non_field_errors %}
  20. <tr><td colspan="{{ inline_admin_form|cell_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
  21. {% endif %}
  22. <tr class="{% cycle "row1" "row2" %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
  23. id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
  24. <td class="original">
  25. {% if inline_admin_form.original or inline_admin_form.show_url %}<p>
  26. {% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
  27. {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %}
  28. </p>{% endif %}
  29. {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
  30. {{ inline_admin_form.fk_field.field }}
  31. {% spaceless %}
  32. {% for fieldset in inline_admin_form %}
  33. {% for line in fieldset %}
  34. {% for field in line %}
  35. {% if field.is_hidden %} {{ field.field }} {% endif %}
  36. {% endfor %}
  37. {% endfor %}
  38. {% endfor %}
  39. {% endspaceless %}
  40. </td>
  41. {% for fieldset in inline_admin_form %}
  42. {% for line in fieldset %}
  43. {% for field in line %}
  44. <td class="{{ field.field.name }}">
  45. {% if field.is_readonly %}
  46. <p>{{ field.contents }}</p>
  47. {% else %}
  48. {{ field.field.errors.as_ul }}
  49. {{ field.field }}
  50. {% endif %}
  51. </td>
  52. {% endfor %}
  53. {% endfor %}
  54. {% endfor %}
  55. {% if inline_admin_formset.formset.can_delete %}
  56. <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
  57. {% endif %}
  58. </tr>
  59. {% endfor %}
  60. </tbody>
  61. </table>
  62. </fieldset>
  63. </div>
  64. </div>
  65. <script type="text/javascript">
  66. (function($) {
  67. $(document).ready(function($) {
  68. var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
  69. var alternatingRows = function(row) {
  70. $(rows).not(".add-row").removeClass("row1 row2")
  71. .filter(":even").addClass("row1").end()
  72. .filter(rows + ":odd").addClass("row2");
  73. }
  74. var reinitDateTimeShortCuts = function() {
  75. // Reinitialize the calendar and clock widgets by force
  76. if (typeof DateTimeShortcuts != "undefined") {
  77. $(".datetimeshortcuts").remove();
  78. DateTimeShortcuts.init();
  79. }
  80. }
  81. var updateSelectFilter = function() {
  82. // If any SelectFilter widgets are a part of the new form,
  83. // instantiate a new SelectFilter instance for it.
  84. if (typeof SelectFilter != "undefined"){
  85. $(".selectfilter").each(function(index, value){
  86. var namearr = value.name.split('-');
  87. SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
  88. });
  89. $(".selectfilterstacked").each(function(index, value){
  90. var namearr = value.name.split('-');
  91. SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
  92. });
  93. }
  94. }
  95. var initPrepopulatedFields = function(row) {
  96. row.find('.prepopulated_field').each(function() {
  97. var field = $(this);
  98. var input = field.find('input, select, textarea');
  99. var dependency_list = input.data('dependency_list') || [];
  100. var dependencies = [];
  101. $.each(dependency_list, function(i, field_name) {
  102. dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
  103. });
  104. if (dependencies.length) {
  105. input.prepopulate(dependencies, input.attr('maxlength'));
  106. }
  107. });
  108. }
  109. $(rows).formset({
  110. prefix: "{{ inline_admin_formset.formset.prefix }}",
  111. addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
  112. formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
  113. deleteCssClass: "inline-deletelink",
  114. deleteText: "{% trans "Remove" %}",
  115. emptyCssClass: "empty-form",
  116. removed: alternatingRows,
  117. added: (function(row) {
  118. initPrepopulatedFields(row);
  119. reinitDateTimeShortCuts();
  120. updateSelectFilter();
  121. alternatingRows(row);
  122. })
  123. });
  124. });
  125. })(django.jQuery);
  126. </script>