1 {% load i18n adminmedia grp_tags %}
4 <div class="group tabular{% if inline_admin_formset.opts.classes %} {{ inline_admin_formset.opts.classes|join:" " }}{% endif %}"
5 id="{{ inline_admin_formset.formset.prefix }}-group" >
6 <h2 class="collapse-handler">{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
8 <li class="add-handler-container"><a href="javascript://" class="icon add-handler" title="{% trans 'Add Another' %}"> </a></li>
10 {{ inline_admin_formset.formset.management_form }}
11 {{ inline_admin_formset.formset.non_form_errors }}
13 <div class="module table">
14 <div class="module thead">
16 {% for field in inline_admin_formset.fields %}
17 {% if not field.widget.is_hidden %}
18 <div class="th {{ field.label|lower }}{% if field.required %} required{% endif %}">{{ field.label|capfirst }}</div>
21 <div class="th content_type">Content type</div>
22 <div class="th value">Value</div>
23 {% if inline_admin_formset.formset.can_delete %}<div class="th"> </div>{% endif %}
26 {% for inline_admin_form in inline_admin_formset %}
28 <div class="module tbody{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
29 id="{{ inline_admin_formset.formset.prefix }}{% if not forloop.last %}{{ forloop.counter0 }}{% else %}-empty{% endif %}">
30 {% if inline_admin_form.form.non_field_errors %}
31 <ul class="errorlist"><li>{{ inline_admin_form.form.non_field_errors }}</li></ul>
33 <h3 style="display: none;"><b>{{ inline_admin_formset.opts.verbose_name|title }} #{{ forloop.counter }}</b> {% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}</h3>
35 {% for fieldset in inline_admin_form %}
36 {% for line in fieldset %}
37 {% for field in line %}
38 {% if field.is_hidden %} {{ field.field }} {% endif %}
44 {% for fieldset in inline_admin_form %}
45 {% for line in fieldset %}
46 {% for field in line %}
47 <div class="td {{ field.field.name }} {% if field.field.errors %} error{% endif %}">
48 {% if field.is_readonly %}
49 <p>{{ field.contents }}</p>
52 {{ field.field.errors.as_ul }}
58 {% with inline_admin_form.form.content_type as field %}<div class="td {{ field.name }}{% if field.errors %} error{% endif %}">{{ field }}{{ field.errors.as_ul }}</div>{% endwith %}
59 {% with inline_admin_form.form.value as field %}<div class="td {{ field.name }}{% if field.errors %} error{% endif %}">{{ field }}{{ field.errors.as_ul }}</div>{% endwith %}
60 <div class="td tools">
63 {% if inline_admin_form.show_url %}<li class="viewsite-link-container"><a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/" class="icon viewsite-link" title="{% trans 'View on Site' %}"> </a></li>{% endif %}
64 {% if inline_admin_formset.opts.sortable_field_name %}
65 <li class="drag-handler-container"><a href="javascript://" class="icon drag-handler" title="{% trans 'Move Item' %}"></a></li>
67 {% if inline_admin_formset.formset.can_delete %}<li class="delete-handler-container">{{ inline_admin_form.deletion_field.field }}<a href="javascript://" class="icon {% if inline_admin_form.original %}delete-handler{% else %}remove-handler{% endif %}" title="{% trans 'Remove' %}"> </a>{% endif %}
71 {{ inline_admin_form.fk_field.field }}
72 {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
77 <div class="module add-item">
78 <a href="javascript://" class="add-handler">{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}</a>
80 <li class="add-handler-container"><a href="javascript://" class="icon add-handler" title="{% trans 'Add Item' %}"> </a></li>
81 </ul><br clear="all" />
85 <script type="text/javascript">
87 $(document).ready(function($) {
89 var prefix = "{{ inline_admin_formset.formset.prefix }}";
90 var related_lookup_fields_fk = {% get_related_lookup_fields_fk inline_admin_formset.opts %};
91 var related_lookup_fields_m2m = {% get_related_lookup_fields_m2m inline_admin_formset.opts %};
92 var related_lookup_fields_generic = {% get_related_lookup_fields_generic inline_admin_formset.opts %};
93 $.each(related_lookup_fields_fk, function() {
94 $("#{{ inline_admin_formset.formset.prefix }}-group > div.table")
95 .find("input[name^='" + prefix + "'][name$='" + this + "']")
96 .grp_related_fk({lookup_url:"{% url grp_related_lookup %}"});
98 $.each(related_lookup_fields_m2m, function() {
99 $("#{{ inline_admin_formset.formset.prefix }}-group > div.table")
100 .find("input[name^='" + prefix + "'][name$='" + this + "']")
101 .grp_related_m2m({lookup_url:"{% url grp_m2m_lookup %}"});
103 $.each(related_lookup_fields_generic, function() {
104 var content_type = this[0],
106 $("#{{ inline_admin_formset.formset.prefix }}-group > div.table")
107 .find("input[name^='" + prefix + "'][name$='" + this[1] + "']")
109 var i = $(this).attr("id").match(/-\d+-/);
111 var ct_id = "#id_" + prefix + i[0] + content_type,
112 obj_id = "#id_" + prefix + i[0] + object_id;
113 $(this).grp_related_generic({content_type:ct_id, object_id:obj_id, lookup_url:"{% url grp_related_lookup %}"});
118 $("#{{ inline_admin_formset.formset.prefix }}-group").grp_inline({
119 prefix: "{{ inline_admin_formset.formset.prefix }}",
120 onBeforeAdded: function(inline) {},
121 onAfterAdded: function(form) {
122 grappelli.reinitDateTimeFields(form);
123 grappelli.updateSelectFilter(form);
124 $.each(related_lookup_fields_fk, function() {
125 form.find("input[name^='" + prefix + "'][name$='" + this + "']")
126 .grp_related_fk({lookup_url:"{% url grp_related_lookup %}"});
128 $.each(related_lookup_fields_m2m, function() {
129 form.find("input[name^='" + prefix + "'][name$='" + this + "']")
130 .grp_related_m2m({lookup_url:"{% url grp_m2m_lookup %}"});
132 $.each(related_lookup_fields_generic, function() {
133 var content_type = this[0],
135 form.find("input[name^='" + prefix + "'][name$='" + this[1] + "']")
137 var i = $(this).attr("id").match(/-\d+-/);
139 var ct_id = "#id_" + prefix + i[0] + content_type,
140 obj_id = "#id_" + prefix + i[0] + object_id;
141 $(this).grp_related_generic({content_type:ct_id, object_id:obj_id, lookup_url:"{% url grp_related_lookup %}"});
148 {% if inline_admin_formset.opts.sortable_field_name %}
149 $("#{{ inline_admin_formset.formset.prefix }}-group > div.table").sortable({
150 handle: "a.drag-handler",
151 items: "div.dynamic-form",
154 forceHelperSize: true,
155 containment: '#{{ inline_admin_formset.formset.prefix }}-group > div.table',
156 tolerance: 'pointer',
158 $("#{{ opts.module_name }}_form").bind("submit", function(){
159 var sortable_field_name = "{{ inline_admin_formset.opts.sortable_field_name }}";
161 $("#{{ inline_admin_formset.formset.prefix }}-group").find("div.dynamic-form").each(function(){
162 var fields = $(this).find("div.td :input[value]");
163 if (fields.serialize()) {
164 $(this).find("input[name$='"+sortable_field_name+"']").val(i);