PageRenderTime 45ms CodeModel.GetById 34ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/django/contrib/admin/templates/mako/admin/edit_inline/stacked.html

https://code.google.com/p/mango-py/
HTML | 116 lines | 102 code | 14 blank | 0 comment | 0 complexity | 820b38354c113a5c7aa4f657057601a1 MD5 | raw file
  1<%def name="inline_edit(inline_admin_formset, formset_count)">
  2
  3<%!
  4    # filter to titlecase text
  5    def title(text):
  6        return text.title()
  7%>
  8
  9<%namespace name="admin" module="django.contrib.admin.templatetags.adminmedia" />
 10
 11<div class="inline-group" id="${ inline_admin_formset.formset.prefix }-group">
 12  <h2>${ inline_admin_formset.opts.verbose_name_plural|title,h }</h2>
 13${inline_admin_formset.formset.management_form}
 14${inline_admin_formset.formset.non_form_errors()}
 15<%
 16    inline_admin_formset_list = [X for X in inline_admin_formset]
 17%>
 18% for i,inline_admin_form in enumerate(inline_admin_formset_list):
 19<%
 20    lastloop = (i == ( len(inline_admin_formset_list)-1) )
 21%>
 22<div class="inline-related${ ' empty-form last-related' if lastloop else '' }" id="${ inline_admin_formset.formset.prefix }-${i if lastloop else 'empty'}">
 23  <h3><b>${inline_admin_formset.opts.verbose_name|title,h}:</b>&nbsp;<span class="inline_label">${ inline_admin_form.original if inline_admin_form.original else '#'+str(i) }</span>
 24    % if inline_admin_form.show_url:
 25        <a href="../../../r/${ inline_admin_form.original_content_type_id }/${ inline_admin_form.original.id }/">${ trans("View on site") }</a>
 26    % endif
 27    
 28% if inline_admin_formset.formset.can_delete and inline_admin_form.original:
 29<span class="delete">${inline_admin_form.deletion_field().field.as_widget()} ${inline_admin_form.deletion_field().label_tag()}</span>
 30% endif
 31
 32  </h3>
 33  
 34% if inline_admin_form.show_url:
 35
 36  <p><a href="../../../r/${inline_admin_form.original.content_type_id}/${inline_admin_form.original.id}/">${trans("View on site")}</a></p>
 37  
 38% endif
 39
 40
 41
 42<%namespace file="admin/includes/fieldset.html" import="*" />  
 43% for fieldset in inline_admin_form:
 44    ${fieldsets(fieldset)}
 45% endfor
 46
 47% if inline_admin_form.has_auto_field:
 48  ${inline_admin_form.pk_field().field}
 49% endif
 50  ${inline_admin_form.fk_field().field}
 51</div>
 52% endfor
 53</div>
 54
 55<script type="text/javascript">
 56(function($) {
 57    $(document).ready(function() {
 58        var rows = "#${ inline_admin_formset.formset.prefix }-group .inline-related";
 59        var updateInlineLabel = function(row) {
 60            $(rows).find(".inline_label").each(function(i) {
 61                var count = i + 1;
 62                $(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
 63            });
 64        }
 65        var reinitDateTimeShortCuts = function() {
 66            // Reinitialize the calendar and clock widgets by force, yuck.
 67            if (typeof DateTimeShortcuts != "undefined") {
 68                $(".datetimeshortcuts").remove();
 69                DateTimeShortcuts.init();
 70            }
 71        }
 72        var updateSelectFilter = function() {
 73            // If any SelectFilter widgets were added, instantiate a new instance.
 74            if (typeof SelectFilter != "undefined"){
 75                $(".selectfilter").each(function(index, value){
 76                  var namearr = value.name.split('-');
 77                  SelectFilter.init(value.id, namearr[namearr.length-1], false, "${ admin_media_prefix() }");
 78                })
 79                $(".selectfilterstacked").each(function(index, value){
 80                  var namearr = value.name.split('-');
 81                  SelectFilter.init(value.id, namearr[namearr.length-1], true, "${ admin_media_prefix() }");
 82                })
 83            }
 84        }
 85        var initPrepopulatedFields = function(row) {
 86            row.find('.prepopulated_field').each(function() {
 87                var field = $(this);
 88                var input = field.find('input, select, textarea');
 89                var dependency_list = input.data('dependency_list') || [];
 90                var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
 91                if (dependencies.length) {
 92                    input.prepopulate(dependencies, input.attr('maxlength'));
 93                }
 94            });
 95        }
 96        $(rows).formset({
 97            prefix: "${ inline_admin_formset.formset.prefix }",
 98            addText: "Add another ${title(inline_admin_formset.opts.verbose_name)}",
 99            numCols: "${inline_admin_form.field_count()}",
100            formCssClass: "dynamic-${ inline_admin_formset.formset.prefix }",
101            deleteCssClass: "inline-deletelink",
102            deleteText: "${ trans('Remove')}",
103            emptyCssClass: "empty-form",
104            removed: updateInlineLabel,
105            added: (function(row) {
106                initPrepopulatedFields(row);
107                reinitDateTimeShortCuts();
108                updateSelectFilter();
109                updateInlineLabel(row);
110            })
111        });
112    });
113})(django.jQuery);
114</script>
115
116</%def>