1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
{% extends "admin/base_site.html" %}
<!-- LOADING -->
{% load i18n admin_modify adminmedia grp_tags %}
<!-- STYLESHEETS -->
{% block stylesheets %}
{{ block.super }}
{% endblock %}
<!-- JAVASCRIPTS -->
{% block javascripts %}
{{ block.super }}
{% url admin:jsi18n as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:'../../../jsi18n/' }}"></script>
<script src="{% admin_media_prefix %}js/grappelli/jquery.grp_inline.js" type="text/javascript"></script>
{% if change %}
<script type="text/javascript" src="{{STATIC_URL}}gstudio/js/URI.js"></script>
<script type="text/javascript" charset="utf-8">
(function($){
$(document).ready(function() {
$("#id_relationtype").change(function() {
p = $("#id_relationtype").val()
test="?id=" + p;
var url = new URI("ajaxleft/?id=" )+ test;
var smpl_uri = new URI("/admin/gstudio/relation/ajaxleft/?id=11");
var blah = new URI(test);
var url = blah.resolve(smpl_uri);
$.get(url,
function(data){
$("#id_left_subject").empty()
for (var key in data) {
$('#id_left_subject').append(
$('<option></option>').val(key).html(data[key])
);
}
});
url = "ajaxright/?id=" + test
var some_uri = new URI("/admin/gstudio/relation/ajaxright/?id=11");
var blah = new URI(test);
var url = blah.resolve(some_uri);
$.get(url,
function(data){
$("#id_right_subject").empty()
for (var key in data) {
$('#id_right_subject').append(
$('<option></option>').val(key).html(data[key])
);
}
});
});
});
})(django.jQuery);
</script>
{% else %}
<script type="text/javascript" src="{{STATIC_URL}}gstudio/js/URI.js"></script>
<script type="text/javascript" charset="utf-8">
(function($){
$(document).ready(function() {
$("#id_relationtype").change(function() {
p = $("#id_relationtype").val()
test="?id=" + p;
var url = new URI("ajaxleft/?id=" )+ test;
var some_uri = new URI("/admin/gstudio/relation/add/ajaxleft/?id=11");
var blah = new URI(test);
var url = blah.resolve(some_uri);
$.get(url,
function(data){
$("#id_left_subject").empty()
for (var key in data) {
$('#id_left_subject').append(
$('<option></option>').val(key).html(data[key])
);
}
});
url = "ajaxright/?id=" + test
var some_uri = new URI("/admin/gstudio/relation/add/ajaxright/?id=11");
var blah = new URI(test);
var url = blah.resolve(some_uri);
$.get(url,
function(data){
$("#id_right_subject").empty()
for (var key in data) {
$('#id_right_subject').append(
$('<option></option>').val(key).html(data[key])
);
}
});
});
});
})(django.jQuery);
</script>
{% endif %}
<script type="text/javascript" charset="utf-8">
(function($) {
$(document).ready(function() {
grappelli.initDateAndTimePicker();
$("div.container-flexible div.group").grp_collapsible_group();
$("div#content .collapse").grp_collapsible({
on_init: function(elem, options) {
// open collapse (and all collapse parents) in case of errors
if (elem.find("ul.errorlist").length > 0) {
elem.removeClass("closed")
.addClass("open");
elem.parents(".collapse")
.removeClass("closed")
.addClass("open");
}
}
});
var related_lookup_fields_fk = {% get_related_lookup_fields_fk adminform.model_admin %};
var related_lookup_fields_m2m = {% get_related_lookup_fields_m2m adminform.model_admin %};
var related_lookup_fields_generic = {% get_related_lookup_fields_generic adminform.model_admin %};
var autocomplete_fields_fk = {% get_autocomplete_lookup_fields_fk adminform.model_admin %};
var autocomplete_fields_m2m = {% get_autocomplete_lookup_fields_m2m adminform.model_admin %};
var autocomplete_fields_generic = {% get_autocomplete_lookup_fields_generic adminform.model_admin %};
$.each(related_lookup_fields_fk, function() {
$("#id_" + this).grp_related_fk({lookup_url:"{% url grp_related_lookup %}"});
});
$.each(related_lookup_fields_m2m, function() {
$("#id_" + this).grp_related_m2m({lookup_url:"{% url grp_m2m_lookup %}"});
});
$.each(related_lookup_fields_generic, function() {
var content_type = "#id_" + this[0],
object_id = "#id_" + this[1];
$(object_id).grp_related_generic({content_type:content_type, object_id:object_id, lookup_url:"{% url grp_related_lookup %}"});
});
$.each(autocomplete_fields_fk, function() {
$("#id_" + this).grp_autocomplete_fk({
lookup_url:"{% url grp_related_lookup %}",
autocomplete_lookup_url:"{% url grp_autocomplete_lookup %}"
});
});
$.each(autocomplete_fields_m2m, function() {
$("#id_" + this).grp_autocomplete_m2m({
lookup_url:"{% url grp_m2m_lookup %}",
autocomplete_lookup_url:"{% url grp_autocomplete_lookup %}"
});
});
$.each(autocomplete_fields_generic, function() {
var content_type = "#id_" + this[0],
object_id = "#id_" + this[1];
$(object_id).grp_autocomplete_generic({
content_type:content_type,
object_id:object_id,
lookup_url:"{% url grp_related_lookup %}",
autocomplete_lookup_url:"{% url grp_autocomplete_lookup %}"
});
});
});
})(django.jQuery);
</script>
{{ media }}
{% endblock %}
<!-- COLTYPE/BODYCLASS -->
{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
{% block content-class %}content-flexible{% endblock %}
<!-- BREADCRUMBS -->
{% block breadcrumbs %}
{% if not is_popup %}
<div id="breadcrumbs">
<a href="../../../">{% trans "Home" %}</a> ›
<a href="../../">{% trans app_label|capfirst|escape %}</a> ›
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} ›
{% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endif %}
{% endblock %}
<!-- OBJECT TOOLS -->
{% block object-tools %}
{% if change %}
{% if not is_popup %}
<ul class="tools">
{% block object-tools-items %}
<li><a href="history/">{% trans "History" %}</a></li>
{% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="focus" target="_blank">{% trans "View on site" %}</a></li>{% endif%}
{% endblock %}
</ul>
{% endif %}
{% endif %}
{% endblock %}
<!-- CONTENT -->
{% block content %}
<div class="container-flexible">
<div class="form-container">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
<div>
<!-- Popup Hidden Field -->
{% if is_popup %}tretret<input type="hidden" name="_popup" value="1" />{% endif %}
<!-- Submit-Row -->
{% if save_on_top %}{% submit_row %}{% endif %}
<!-- Errors -->
{% if errors %}
<p class="errornote">{% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}</p>
<ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}
<!-- Fieldsets -->
{% for fieldset in adminform %}
{% include "admin/includes/fieldset.html" %}
{% endfor %}
{% block after_field_sets %}{% endblock %}
<!-- Inlines -->
{% for inline_admin_formset in inline_admin_formsets %}
{% include inline_admin_formset.opts.template %}
{% endfor %}
{% block after_related_objects %}{% endblock %}
<!-- Submit-Row -->
{% submit_row %}
{% if adminform and add %}
{% block extrahead %}
<script type="text/javascript">
(function($){
$(function(){
try {
// focus on first form-field
$("#{{ adminform.first_field.auto_id }}, #{{ adminform.first_field.auto_id }}_0")
.eq(0).focus();
} catch(e) {}
});
}(django.jQuery));
</script>
{% endblock %}
{% endif %}
<!-- JS for prepopulated fields -->
{% prepopulated_fields_js %}
</div>
</form>
</div>
</div>
{% endblock %}
|