-
diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py
index bd661f3..5b56402 100644
a
|
b
|
def delete_selected(modeladmin, request, queryset):
|
69 | 69 | "perms_lacking": perms_needed, |
70 | 70 | "protected": protected, |
71 | 71 | "opts": opts, |
72 | | "root_path": modeladmin.admin_site.root_path, |
73 | 72 | "app_label": app_label, |
74 | 73 | 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, |
75 | 74 | } |
-
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 550f46a..5f40157 100644
a
|
b
|
from django.contrib import messages
|
10 | 10 | from django.views.decorators.csrf import csrf_protect |
11 | 11 | from django.core.exceptions import PermissionDenied, ValidationError |
12 | 12 | from django.core.paginator import Paginator |
| 13 | from django.core.urlresolvers import reverse |
13 | 14 | from django.db import models, transaction, router |
14 | 15 | from django.db.models.related import RelatedObject |
15 | 16 | from django.db.models.fields import BLANK_CHOICE_DASH, FieldDoesNotExist |
… |
… |
class BaseModelAdmin(object):
|
154 | 155 | """ |
155 | 156 | db = kwargs.get('using') |
156 | 157 | if db_field.name in self.raw_id_fields: |
157 | | kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, using=db) |
| 158 | kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, self.admin_site, |
| 159 | using=db) |
158 | 160 | elif db_field.name in self.radio_fields: |
159 | 161 | kwargs['widget'] = widgets.AdminRadioSelect(attrs={ |
160 | 162 | 'class': get_ul_class(self.radio_fields[db_field.name]), |
… |
… |
class BaseModelAdmin(object):
|
174 | 176 | db = kwargs.get('using') |
175 | 177 | |
176 | 178 | if db_field.name in self.raw_id_fields: |
177 | | kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, using=db) |
| 179 | kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel, self.admin_site, |
| 180 | using=db) |
178 | 181 | kwargs['help_text'] = '' |
179 | 182 | elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)): |
180 | 183 | kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical)) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
726 | 729 | 'content_type_id': ContentType.objects.get_for_model(self.model).id, |
727 | 730 | 'save_as': self.save_as, |
728 | 731 | 'save_on_top': self.save_on_top, |
729 | | 'root_path': self.admin_site.root_path, |
730 | 732 | }) |
731 | 733 | if add and self.add_form_template is not None: |
732 | 734 | form_template = self.add_form_template |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
769 | 771 | # redirect to the change-list page for this object. Otherwise, |
770 | 772 | # redirect to the admin index. |
771 | 773 | if self.has_change_permission(request, None): |
772 | | post_url = '../' |
| 774 | post_url = reverse('admin:%s_%s_changelist' % |
| 775 | (opts.app_label, opts.module_name), |
| 776 | current_app=self.admin_site.name) |
773 | 777 | else: |
774 | | post_url = '../../../' |
| 778 | post_url = reverse('admin:index', |
| 779 | current_app=self.admin_site.name) |
775 | 780 | return HttpResponseRedirect(post_url) |
776 | 781 | |
777 | 782 | def response_change(self, request, obj): |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
780 | 785 | """ |
781 | 786 | opts = obj._meta |
782 | 787 | |
783 | | # Handle proxy models automatically created by .only() or .defer() |
| 788 | # Handle proxy models automatically created by .only() or .defer(). |
| 789 | # Refs #14529 |
784 | 790 | verbose_name = opts.verbose_name |
| 791 | module_name = opts.module_name |
785 | 792 | if obj._deferred: |
786 | 793 | opts_ = opts.proxy_for_model._meta |
787 | 794 | verbose_name = opts_.verbose_name |
| 795 | module_name = opts_.module_name |
788 | 796 | |
789 | 797 | pk_value = obj._get_pk_val() |
790 | 798 | |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
798 | 806 | elif "_saveasnew" in request.POST: |
799 | 807 | msg = _('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(verbose_name), 'obj': obj} |
800 | 808 | self.message_user(request, msg) |
801 | | return HttpResponseRedirect("../%s/" % pk_value) |
| 809 | return HttpResponseRedirect(reverse('admin:%s_%s_change' % |
| 810 | (opts.app_label, module_name), |
| 811 | args=(pk_value,), |
| 812 | current_app=self.admin_site.name)) |
802 | 813 | elif "_addanother" in request.POST: |
803 | 814 | self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(verbose_name))) |
804 | | return HttpResponseRedirect("../add/") |
| 815 | return HttpResponseRedirect(reverse('admin:%s_%s_add' % |
| 816 | (opts.app_label, module_name), |
| 817 | current_app=self.admin_site.name)) |
805 | 818 | else: |
806 | 819 | self.message_user(request, msg) |
807 | 820 | # Figure out where to redirect. If the user has change permission, |
808 | 821 | # redirect to the change-list page for this object. Otherwise, |
809 | 822 | # redirect to the admin index. |
810 | 823 | if self.has_change_permission(request, None): |
811 | | return HttpResponseRedirect('../') |
| 824 | post_url = reverse('admin:%s_%s_changelist' % |
| 825 | (opts.app_label, module_name), |
| 826 | current_app=self.admin_site.name) |
812 | 827 | else: |
813 | | return HttpResponseRedirect('../../../') |
| 828 | post_url = reverse('admin:index', |
| 829 | current_app=self.admin_site.name) |
| 830 | return HttpResponseRedirect(post_url) |
814 | 831 | |
815 | 832 | def response_action(self, request, queryset): |
816 | 833 | """ |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
962 | 979 | 'media': mark_safe(media), |
963 | 980 | 'inline_admin_formsets': inline_admin_formsets, |
964 | 981 | 'errors': helpers.AdminErrorList(form, formsets), |
965 | | 'root_path': self.admin_site.root_path, |
966 | 982 | 'app_label': opts.app_label, |
967 | 983 | } |
968 | 984 | context.update(extra_context or {}) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
984 | 1000 | raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)}) |
985 | 1001 | |
986 | 1002 | if request.method == 'POST' and "_saveasnew" in request.POST: |
987 | | return self.add_view(request, form_url='../add/') |
| 1003 | return self.add_view(request, form_url=reverse('admin:%s_%s_add' % |
| 1004 | (opts.app_label, opts.module_name), |
| 1005 | current_app=self.admin_site.name)) |
988 | 1006 | |
989 | 1007 | ModelForm = self.get_form(request, obj) |
990 | 1008 | formsets = [] |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1053 | 1071 | 'media': mark_safe(media), |
1054 | 1072 | 'inline_admin_formsets': inline_admin_formsets, |
1055 | 1073 | 'errors': helpers.AdminErrorList(form, formsets), |
1056 | | 'root_path': self.admin_site.root_path, |
1057 | 1074 | 'app_label': opts.app_label, |
1058 | 1075 | } |
1059 | 1076 | context.update(extra_context or {}) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1195 | 1212 | 'cl': cl, |
1196 | 1213 | 'media': media, |
1197 | 1214 | 'has_add_permission': self.has_add_permission(request), |
1198 | | 'root_path': self.admin_site.root_path, |
1199 | 1215 | 'app_label': app_label, |
1200 | 1216 | 'action_form': action_form, |
1201 | 1217 | 'actions_on_top': self.actions_on_top, |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1242 | 1258 | self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)}) |
1243 | 1259 | |
1244 | 1260 | if not self.has_change_permission(request, None): |
1245 | | return HttpResponseRedirect("../../../../") |
1246 | | return HttpResponseRedirect("../../") |
| 1261 | return HttpResponseRedirect(reverse('admin:index', |
| 1262 | current_app=self.admin_site.name)) |
| 1263 | return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % |
| 1264 | (opts.app_label, opts.module_name), |
| 1265 | current_app=self.admin_site.name)) |
1247 | 1266 | |
1248 | 1267 | object_name = force_unicode(opts.verbose_name) |
1249 | 1268 | |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1260 | 1279 | "perms_lacking": perms_needed, |
1261 | 1280 | "protected": protected, |
1262 | 1281 | "opts": opts, |
1263 | | "root_path": self.admin_site.root_path, |
1264 | 1282 | "app_label": app_label, |
1265 | 1283 | } |
1266 | 1284 | context.update(extra_context or {}) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1288 | 1306 | 'action_list': action_list, |
1289 | 1307 | 'module_name': capfirst(force_unicode(opts.verbose_name_plural)), |
1290 | 1308 | 'object': obj, |
1291 | | 'root_path': self.admin_site.root_path, |
1292 | 1309 | 'app_label': app_label, |
| 1310 | "opts": opts, |
1293 | 1311 | } |
1294 | 1312 | context.update(extra_context or {}) |
1295 | 1313 | return TemplateResponse(request, self.object_history_template or [ |
-
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index a0338ee..3ba9314 100644
a
|
b
|
class AdminSite(object):
|
39 | 39 | password_change_template = None |
40 | 40 | password_change_done_template = None |
41 | 41 | |
42 | | def __init__(self, name=None, app_name='admin'): |
| 42 | def __init__(self, name='admin', app_name='admin'): |
43 | 43 | self._registry = {} # model_class class -> admin_class instance |
44 | | self.root_path = None |
45 | | if name is None: |
46 | | self.name = 'admin' |
47 | | else: |
48 | | self.name = name |
| 44 | self.name = name |
49 | 45 | self.app_name = app_name |
50 | 46 | self._actions = {'delete_selected': actions.delete_selected} |
51 | 47 | self._global_actions = self._actions.copy() |
… |
… |
class AdminSite(object):
|
254 | 250 | Handles the "change password" task -- both form display and validation. |
255 | 251 | """ |
256 | 252 | from django.contrib.auth.views import password_change |
257 | | if self.root_path is not None: |
258 | | url = '%spassword_change/done/' % self.root_path |
259 | | else: |
260 | | url = reverse('admin:password_change_done', current_app=self.name) |
| 253 | url = reverse('admin:password_change_done', current_app=self.name) |
261 | 254 | defaults = { |
262 | 255 | 'current_app': self.name, |
263 | 256 | 'post_change_redirect': url |
… |
… |
class AdminSite(object):
|
316 | 309 | from django.contrib.auth.views import login |
317 | 310 | context = { |
318 | 311 | 'title': _('Log in'), |
319 | | 'root_path': self.root_path, |
320 | 312 | 'app_path': request.get_full_path(), |
321 | 313 | REDIRECT_FIELD_NAME: request.get_full_path(), |
322 | 314 | } |
… |
… |
class AdminSite(object):
|
347 | 339 | # Check whether user has any perm for this module. |
348 | 340 | # If so, add the module to the model_list. |
349 | 341 | if True in perms.values(): |
| 342 | info = (app_label, model._meta.module_name) |
350 | 343 | model_dict = { |
351 | 344 | 'name': capfirst(model._meta.verbose_name_plural), |
352 | | 'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())), |
| 345 | 'admin_url': reverse('admin:%s_%s_changelist' % info, current_app=self.name), |
| 346 | 'add_url': reverse('admin:%s_%s_add' % info, current_app=self.name), |
353 | 347 | 'perms': perms, |
354 | 348 | } |
355 | 349 | if app_label in app_dict: |
… |
… |
class AdminSite(object):
|
357 | 351 | else: |
358 | 352 | app_dict[app_label] = { |
359 | 353 | 'name': app_label.title(), |
360 | | 'app_url': app_label + '/', |
| 354 | 'app_url': reverse('admin:app_list', kwargs={'app_label': app_label}, current_app=self.name), |
361 | 355 | 'has_module_perms': has_module_perms, |
362 | 356 | 'models': [model_dict], |
363 | 357 | } |
… |
… |
class AdminSite(object):
|
373 | 367 | context = { |
374 | 368 | 'title': _('Site administration'), |
375 | 369 | 'app_list': app_list, |
376 | | 'root_path': self.root_path, |
377 | 370 | } |
378 | 371 | context.update(extra_context or {}) |
379 | 372 | return TemplateResponse(request, [ |
… |
… |
class AdminSite(object):
|
392 | 385 | # Check whether user has any perm for this module. |
393 | 386 | # If so, add the module to the model_list. |
394 | 387 | if True in perms.values(): |
| 388 | info = (app_label, model._meta.module_name) |
395 | 389 | model_dict = { |
396 | 390 | 'name': capfirst(model._meta.verbose_name_plural), |
397 | | 'admin_url': '%s/' % model.__name__.lower(), |
| 391 | 'admin_url': reverse('admin:%s_%s_changelist' % info, current_app=self.name), |
| 392 | 'add_url': reverse('admin:%s_%s_add' % info, current_app=self.name), |
398 | 393 | 'perms': perms, |
399 | 394 | } |
400 | 395 | if app_dict: |
… |
… |
class AdminSite(object):
|
416 | 411 | context = { |
417 | 412 | 'title': _('%s administration') % capfirst(app_label), |
418 | 413 | 'app_list': [app_dict], |
419 | | 'root_path': self.root_path, |
420 | 414 | } |
421 | 415 | context.update(extra_context or {}) |
422 | 416 | |
-
diff --git a/django/contrib/admin/templates/admin/500.html b/django/contrib/admin/templates/admin/500.html
index b30e431..eeb9e8d 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans "Home" %}</a> › {% trans "Server error" %}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Server error' %} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block title %}{% trans 'Server error (500)' %}{% endblock %} |
7 | 13 | |
-
diff --git a/django/contrib/admin/templates/admin/app_index.html b/django/contrib/admin/templates/admin/app_index.html
index 120433d..4616b16 100644
a
|
b
|
|
1 | | {% extends "admin/index.html" %} |
2 | | {% load i18n %} |
| 1 | {% extends "admin/index.html" %} |
| 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | 5 | {% if not is_popup %} |
5 | | |
6 | 6 | {% block breadcrumbs %} |
7 | | <div class="breadcrumbs"><a href="../"> |
8 | | {% trans "Home" %}</a> › |
| 7 | <div class="breadcrumbs"> |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › |
9 | 10 | {% for app in app_list %} |
10 | 11 | {% blocktrans with app.name as name %}{{ name }}{% endblocktrans %} |
11 | | {% endfor %}</div>{% endblock %} |
12 | | |
13 | | {% endif %} |
| 12 | {% endfor %} |
| 13 | </div> |
| 14 | {% endblock %} |
| 15 | {% endif %} |
14 | 16 | |
15 | | {% block sidebar %}{% endblock %} |
16 | | No newline at end of file |
| 17 | {% block sidebar %}{% endblock %} |
-
diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html
index c280f50..18f8b80 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n static admin_modify %} |
3 | 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
| 5 | |
4 | 6 | {% block extrahead %}{{ block.super }} |
5 | 7 | {% url 'admin:jsi18n' as jsi18nurl %} |
6 | 8 | <script type="text/javascript" src="{{ jsi18nurl|default:"../../../../jsi18n/" }}"></script> |
7 | 9 | {% endblock %} |
8 | 10 | {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %} |
9 | 11 | {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} |
10 | | {% block breadcrumbs %}{% if not is_popup %} |
11 | | <div class="breadcrumbs"> |
12 | | <a href="../../../../">{% trans "Home" %}</a> › |
13 | | <a href="../../../">{{ opts.app_label|capfirst|escape }}</a> › |
14 | | <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> › |
15 | | <a href="../">{{ original|truncatewords:"18" }}</a> › |
16 | | {% trans 'Change password' %} |
| 12 | {% if not is_popup %} |
| 13 | {% block breadcrumbs %} |
| 14 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 15 | › <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_label|capfirst|escape }}</a> |
| 16 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}">{{ opts.verbose_name_plural|capfirst }}</a> |
| 17 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}{{ original.pk }}">{{ original|truncatewords:"18" }}</a> |
| 18 | › {% trans 'Change password' %} |
17 | 19 | </div> |
18 | | {% endif %}{% endblock %} |
| 20 | {% endblock %} |
| 21 | {% endif %} |
19 | 22 | {% block content %}<div id="content-main"> |
20 | 23 | <form action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} |
21 | 24 | <div> |
-
diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
index 9034ae8..d0feb1c 100644
a
|
b
|
|
32 | 32 | {% if docsroot %} |
33 | 33 | <a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / |
34 | 34 | {% endif %} |
35 | | {% url 'admin:password_change' as password_change_url %} |
36 | | {% if password_change_url %} |
37 | | <a href="{{ password_change_url }}"> |
38 | | {% else %} |
39 | | <a href="{{ root_path }}password_change/"> |
40 | | {% endif %} |
41 | | {% trans 'Change password' %}</a> / |
42 | | {% url 'admin:logout' as logout_url %} |
43 | | {% if logout_url %} |
44 | | <a href="{{ logout_url }}"> |
45 | | {% else %} |
46 | | <a href="{{ root_path }}logout/"> |
47 | | {% endif %} |
48 | | {% trans 'Log out' %}</a> |
| 35 | <a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> / |
| 36 | <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a> |
49 | 37 | {% endblock %} |
50 | 38 | </div> |
51 | 39 | {% endif %} |
52 | 40 | {% block nav-global %}{% endblock %} |
53 | 41 | </div> |
54 | 42 | <!-- END Header --> |
55 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans 'Home' %}</a>{% if title %} › {{ title }}{% endif %}</div>{% endblock %} |
| 43 | {% block breadcrumbs %} |
| 44 | <div class="breadcrumbs"> |
| 45 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 46 | {% if title %} › {{ title }}{% endif %} |
| 47 | </div> |
| 48 | {% endblock %} |
56 | 49 | {% endif %} |
57 | 50 | |
58 | 51 | {% block messages %} |
-
diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html
index c5e428d..5a3b1ab 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n static admin_modify %} |
3 | 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
4 | 5 | |
5 | 6 | {% block extrahead %}{{ block.super }} |
6 | 7 | {% url 'admin:jsi18n' as jsi18nurl %} |
… |
… |
|
14 | 15 | |
15 | 16 | {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} |
16 | 17 | |
17 | | {% block breadcrumbs %}{% if not is_popup %} |
18 | | <div class="breadcrumbs"> |
19 | | <a href="../../../">{% trans "Home" %}</a> › |
20 | | <a href="../../">{{ app_label|capfirst|escape }}</a> › |
21 | | {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} › |
22 | | {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %} |
| 18 | {% if not is_popup %} |
| 19 | {% block breadcrumbs %} |
| 20 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 21 | › <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ app_label|capfirst|escape }}</a> |
| 22 | › {% if has_change_permission %}<a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} |
| 23 | › {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %} |
23 | 24 | </div> |
24 | | {% endif %}{% endblock %} |
| 25 | {% endblock %} |
| 26 | {% endif %} |
25 | 27 | |
26 | 28 | {% block content %}<div id="content-main"> |
27 | 29 | {% block object-tools %} |
-
diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html
index 29af47f..299e564 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n static admin_list %} |
3 | 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
| 5 | |
4 | 6 | {% block extrastyle %} |
5 | 7 | {{ block.super }} |
6 | 8 | <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" /> |
… |
… |
|
36 | 38 | {% block bodyclass %}change-list{% endblock %} |
37 | 39 | |
38 | 40 | {% if not is_popup %} |
39 | | {% block breadcrumbs %} |
40 | | <div class="breadcrumbs"> |
41 | | <a href="../../"> |
42 | | {% trans "Home" %} |
43 | | </a> |
44 | | › |
45 | | <a href="../"> |
46 | | {{ app_label|capfirst }} |
47 | | </a> |
48 | | › |
49 | | {{ cl.opts.verbose_name_plural|capfirst }} |
50 | | </div> |
51 | | {% endblock %} |
| 41 | {% block breadcrumbs %} |
| 42 | <div class="breadcrumbs"> |
| 43 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 44 | › <a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ app_label|capfirst|escape }}</a> |
| 45 | › {{ cl.opts.verbose_name_plural|capfirst }} |
| 46 | </div> |
| 47 | {% endblock %} |
52 | 48 | {% endif %} |
53 | 49 | |
54 | 50 | {% block coltype %}flex{% endblock %} |
… |
… |
|
60 | 56 | <ul class="object-tools"> |
61 | 57 | {% block object-tools-items %} |
62 | 58 | <li> |
63 | | <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink"> |
| 59 | <a href="{% model_url 'admin:%s_%s_add' cl.opts.app_label cl.opts.module_name %}{% if is_popup %}?_popup=1{% endif %}" class="addlink"> |
64 | 60 | {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %} |
65 | 61 | </a> |
66 | 62 | </li> |
-
diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html
index 0e6d47e..a1e4337 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
3 | 5 | |
4 | 6 | {% block breadcrumbs %} |
5 | 7 | <div class="breadcrumbs"> |
6 | | <a href="../../../../">{% trans "Home" %}</a> › |
7 | | <a href="../../../">{{ app_label|capfirst }}</a> › |
8 | | <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> › |
9 | | <a href="../">{{ object|truncatewords:"18" }}</a> › |
10 | | {% trans 'Delete' %} |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ app_label|capfirst }}</a> |
| 10 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}">{{ opts.verbose_name_plural|capfirst|escape }}</a> |
| 11 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}{{ object.pk }}">{{ object|truncatewords:"18" }}</a> |
| 12 | › {% trans 'Delete' %} |
11 | 13 | </div> |
12 | 14 | {% endblock %} |
13 | 15 | |
-
diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
index 127519b..0a5d097 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n l10n %} |
| 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
3 | 5 | |
4 | 6 | {% block breadcrumbs %} |
5 | 7 | <div class="breadcrumbs"> |
6 | | <a href="../../">{% trans "Home" %}</a> › |
7 | | <a href="../">{{ app_label|capfirst }}</a> › |
8 | | <a href="./">{{ opts.verbose_name_plural|capfirst }}</a> › |
9 | | {% trans 'Delete multiple objects' %} |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'admin:app_list' app_label=app_label %}">{{ app_label|capfirst|escape }}</a> |
| 10 | › <a href="{% model_url 'admin:%s_%s_changelist' app_label opts.module_name %}">{{ opts.verbose_name_plural|capfirst }}</a> |
| 11 | › {% trans 'Delete multiple objects' %} |
10 | 12 | </div> |
11 | 13 | {% endblock %} |
12 | 14 | |
-
diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html
index 0f81a1a..b654329 100644
a
|
b
|
|
26 | 26 | {% endif %} |
27 | 27 | |
28 | 28 | {% if model.perms.add %} |
29 | | <td><a href="{{ model.admin_url }}add/" class="addlink">{% trans 'Add' %}</a></td> |
| 29 | <td><a href="{{ model.add_url }}" class="addlink">{% trans 'Add' %}</a></td> |
30 | 30 | {% else %} |
31 | 31 | <td> </td> |
32 | 32 | {% endif %} |
-
diff --git a/django/contrib/admin/templates/admin/invalid_setup.html b/django/contrib/admin/templates/admin/invalid_setup.html
index f09b316..c2df4df 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> › {{ title }}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {{ title }} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block content %} |
7 | 13 | <p>{% trans "Something's wrong with your database installation. Make sure the appropriate database tables have been created, and make sure the database is readable by the appropriate user." %}</p> |
-
diff --git a/django/contrib/admin/templates/admin/object_history.html b/django/contrib/admin/templates/admin/object_history.html
index 5ae7847..bb78f5c 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | {% load admin_urls %} |
3 | 5 | |
4 | 6 | {% block breadcrumbs %} |
5 | 7 | <div class="breadcrumbs"> |
6 | | <a href="../../../../">{% trans 'Home' %}</a> › |
7 | | <a href="../../../">{{ app_label|capfirst }}</a> › |
8 | | <a href="../../">{{ module_name }}</a> › |
9 | | <a href="../">{{ object|truncatewords:"18" }}</a> › |
10 | | {% trans 'History' %} |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'admin:app_list' app_label=app_label %}">{{ app_label|capfirst|escape }}</a> |
| 10 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}">{{ module_name }}</a> |
| 11 | › <a href="{% model_url 'admin:%s_%s_changelist' opts.app_label opts.module_name %}{{ object.pk }}">{{ object|truncatewords:"18" }}</a> |
| 12 | › {% trans 'History' %} |
11 | 13 | </div> |
12 | 14 | {% endblock %} |
13 | 15 | |
-
diff --git a/django/contrib/admin/templates/registration/logged_out.html b/django/contrib/admin/templates/registration/logged_out.html
index d339ef0..e95d864 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a></div>{% endblock %} |
| 5 | {% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></div>{% endblock %} |
5 | 6 | |
6 | 7 | {% block content %} |
7 | 8 | |
8 | 9 | <p>{% trans "Thanks for spending some quality time with the Web site today." %}</p> |
9 | 10 | |
10 | | <p><a href="../">{% trans 'Log in again' %}</a></p> |
| 11 | <p><a href="{% url 'admin:index' %}">{% trans 'Log in again' %}</a></p> |
11 | 12 | |
12 | 13 | {% endblock %} |
-
diff --git a/django/contrib/admin/templates/registration/password_change_done.html b/django/contrib/admin/templates/registration/password_change_done.html
index 0c0690d..863fc96 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
3 | 3 | {% load url from future %} |
4 | | {% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}{% trans 'Change password' %} / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %} |
5 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> › {% trans 'Password change' %}</div>{% endblock %} |
| 4 | {% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}{% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Password change' %} |
| 9 | </div> |
| 10 | {% endblock %} |
6 | 11 | |
7 | 12 | {% block title %}{% trans 'Password change successful' %}{% endblock %} |
8 | 13 | |
-
diff --git a/django/contrib/admin/templates/registration/password_change_form.html b/django/contrib/admin/templates/registration/password_change_form.html
index f76692d..0e4ea53 100644
a
|
b
|
|
2 | 2 | {% load i18n static %} |
3 | 3 | {% load url from future %} |
4 | 4 | {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %} |
5 | | {% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %} {% trans 'Change password' %} / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %} |
6 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password change' %}</div>{% endblock %} |
| 5 | {% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %} {% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %} |
| 6 | {% block breadcrumbs %} |
| 7 | <div class="breadcrumbs"> |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › {% trans 'Password change' %} |
| 10 | </div> |
| 11 | {% endblock %} |
7 | 12 | |
8 | 13 | {% block title %}{% trans 'Password change' %}{% endblock %} |
9 | 14 | |
-
diff --git a/django/contrib/admin/templates/registration/password_reset_complete.html b/django/contrib/admin/templates/registration/password_reset_complete.html
index fceb167..7c07707 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> › {% trans 'Password reset' %}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Password reset' %} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block title %}{% trans 'Password reset complete' %}{% endblock %} |
7 | 13 | |
-
diff --git a/django/contrib/admin/templates/registration/password_reset_confirm.html b/django/contrib/admin/templates/registration/password_reset_confirm.html
index df9cf1b..d5299eb 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password reset confirmation' %}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Password reset confirmation' %} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block title %}{% trans 'Password reset' %}{% endblock %} |
7 | 13 | |
-
diff --git a/django/contrib/admin/templates/registration/password_reset_done.html b/django/contrib/admin/templates/registration/password_reset_done.html
index e223bdb..fd73af8 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password reset' %}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Password reset' %} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block title %}{% trans 'Password reset successful' %}{% endblock %} |
7 | 13 | |
-
diff --git a/django/contrib/admin/templates/registration/password_reset_form.html b/django/contrib/admin/templates/registration/password_reset_form.html
index d3a1284..2b591fe 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
3 | 4 | |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password reset' %}</div>{% endblock %} |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Password reset' %} |
| 9 | </div> |
| 10 | {% endblock %} |
5 | 11 | |
6 | 12 | {% block title %}{% trans "Password reset" %}{% endblock %} |
7 | 13 | |
-
diff --git a/django/contrib/admin/templatetags/admin_urls.py b/django/contrib/admin/templatetags/admin_urls.py
new file mode 100644
index 0000000..90f30ed
-
|
+
|
|
| 1 | from django.core.urlresolvers import reverse, NoReverseMatch |
| 2 | from django import template |
| 3 | |
| 4 | register = template.Library() |
| 5 | |
| 6 | def model_url(context, fmt_string, app_name, model_name): |
| 7 | try: |
| 8 | return reverse(fmt_string % (app_name, model_name), |
| 9 | current_app=context.current_app) |
| 10 | except NoReverseMatch: |
| 11 | return '' |
| 12 | register.simple_tag(takes_context=True)(model_url) |
-
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index bf48f16..15bccff 100644
a
|
b
|
class ForeignKeyRawIdWidget(forms.TextInput):
|
113 | 113 | A Widget for displaying ForeignKeys in the "raw_id" interface rather than |
114 | 114 | in a <select> box. |
115 | 115 | """ |
116 | | def __init__(self, rel, attrs=None, using=None): |
| 116 | def __init__(self, rel, admin_site, attrs=None, using=None): |
117 | 117 | self.rel = rel |
118 | 118 | self.db = using |
| 119 | self.admin_site = admin_site |
119 | 120 | super(ForeignKeyRawIdWidget, self).__init__(attrs) |
120 | 121 | |
121 | 122 | def render(self, name, value, attrs=None): |
| 123 | rel_to = self.rel.to |
122 | 124 | if attrs is None: |
123 | 125 | attrs = {} |
124 | | related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower()) |
125 | | params = self.url_parameters() |
126 | | if params: |
127 | | url = u'?' + u'&'.join([u'%s=%s' % (k, v) for k, v in params.items()]) |
128 | | else: |
129 | | url = u'' |
130 | | if "class" not in attrs: |
131 | | attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook. |
132 | | output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)] |
133 | | # TODO: "id_" is hard-coded here. This should instead use the correct |
134 | | # API to determine the ID dynamically. |
135 | | output.append(u'<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' |
136 | | % (related_url, url, name)) |
137 | | output.append(u'<img src="%s" width="16" height="16" alt="%s" /></a>' |
138 | | % (static('admin/img/selector-search.gif'), _('Lookup'))) |
| 126 | extra = [] |
| 127 | if rel_to in self.admin_site._registry: # If the related object has an admin interface: |
| 128 | try: |
| 129 | related_url = reverse('admin:%s_%s_changelist' % |
| 130 | (rel_to._meta.app_label, |
| 131 | rel_to._meta.module_name), |
| 132 | current_app=self.admin_site.name) |
| 133 | except NoReverseMatch: |
| 134 | raise |
| 135 | |
| 136 | params = self.url_parameters() |
| 137 | if params: |
| 138 | url = u'?' + u'&'.join([u'%s=%s' % (k, v) for k, v in params.items()]) |
| 139 | else: |
| 140 | url = u'' |
| 141 | if "class" not in attrs: |
| 142 | attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript code looks for this hook. |
| 143 | # TODO: "id_" is hard-coded here. This should instead use the correct |
| 144 | # API to determine the ID dynamically. |
| 145 | extra.append(u'<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' |
| 146 | % (related_url, url, name)) |
| 147 | extra.append(u'<img src="%s" width="16" height="16" alt="%s" /></a>' |
| 148 | % (static('admin/img/selector-search.gif'), _('Lookup'))) |
| 149 | output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)] + extra |
139 | 150 | if value: |
140 | 151 | output.append(self.label_for_value(value)) |
141 | 152 | return mark_safe(u''.join(output)) |
… |
… |
class RelatedFieldWidgetWrapper(forms.Widget):
|
229 | 240 | def render(self, name, value, *args, **kwargs): |
230 | 241 | rel_to = self.rel.to |
231 | 242 | info = (rel_to._meta.app_label, rel_to._meta.object_name.lower()) |
232 | | try: |
233 | | related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name) |
234 | | except NoReverseMatch: |
235 | | info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower()) |
236 | | related_url = '%s%s/%s/add/' % info |
237 | 243 | self.widget.choices = self.choices |
238 | 244 | output = [self.widget.render(name, value, *args, **kwargs)] |
239 | 245 | if self.can_add_related: |
| 246 | related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name) |
240 | 247 | # TODO: "id_" is hard-coded here. This should instead use the correct |
241 | 248 | # API to determine the ID dynamically. |
242 | 249 | output.append(u'<a href="%s" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/bookmarklets.html b/django/contrib/admindocs/templates/admin_doc/bookmarklets.html
index 6447529..baa717c 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | | |
3 | | {% block breadcrumbs %}{% load i18n %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> › <a href="../">{% trans "Documentation" %}</a> › {% trans "Bookmarklets" %}</div>{% endblock %} |
| 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 9 | › {% trans 'Bookmarklets' %} |
| 10 | </div> |
| 11 | {% endblock %} |
4 | 12 | {% block title %}{% trans "Documentation bookmarklets" %}{% endblock %} |
5 | 13 | |
6 | 14 | {% block content %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/index.html b/django/contrib/admindocs/templates/admin_doc/index.html
index a8b21c3..652fbfd 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
3 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="{{ root_path }}">Home</a> › Documentation</div>{% endblock %} |
| 3 | {% load url from future %} |
| 4 | |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Documentation' %}</a> |
| 9 | </div> |
| 10 | {% endblock %} |
4 | 11 | {% block title %}Documentation{% endblock %} |
5 | 12 | |
6 | 13 | {% block content %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/missing_docutils.html b/django/contrib/admindocs/templates/admin_doc/missing_docutils.html
index 97c9d47..34c18ff 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
3 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> › Documentation</div>{% endblock %} |
| 3 | {% load url from future %} |
| 4 | |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › {% trans 'Documentation' %}</a> |
| 9 | </div> |
4 | 10 | {% block title %}Please install docutils{% endblock %} |
5 | 11 | |
6 | 12 | {% block content %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/model_detail.html b/django/contrib/admindocs/templates/admin_doc/model_detail.html
index 828df18..82cb405 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
3 | 5 | {% block extrahead %} |
4 | 6 | {{ block.super }} |
5 | 7 | <style type="text/css"> |
… |
… |
|
8 | 10 | </style> |
9 | 11 | {% endblock %} |
10 | 12 | |
11 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> › <a href="../../">Documentation</a> › <a href="../">Models</a> › {{ name }}</div>{% endblock %} |
| 13 | {% block breadcrumbs %} |
| 14 | <div class="breadcrumbs"> |
| 15 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 16 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 17 | › <a href="{% url 'django-admindocs-models-index' %}">{% trans 'Models' %}</a> |
| 18 | › {{ name }} |
| 19 | </div> |
| 20 | {% endblock %} |
12 | 21 | |
13 | 22 | {% block title %}Model: {{ name }}{% endblock %} |
14 | 23 | |
… |
… |
|
41 | 50 | </table> |
42 | 51 | </div> |
43 | 52 | |
44 | | <p class="small"><a href="../">‹ Back to Models Documentation</a></p> |
| 53 | <p class="small"><a href="{% url 'django-admindocs-models-index' %}">‹ Back to Models Documentation</a></p> |
45 | 54 | </div> |
46 | 55 | {% endblock %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/model_index.html b/django/contrib/admindocs/templates/admin_doc/model_index.html
index 47c94c0..4eb3cf6 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
3 | 5 | {% block coltype %}colSM{% endblock %} |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Models</div>{% endblock %} |
| 6 | |
| 7 | {% block breadcrumbs %} |
| 8 | <div class="breadcrumbs"> |
| 9 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 10 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 11 | › {% trans 'Models' %} |
| 12 | </div> |
| 13 | {% endblock %} |
5 | 14 | |
6 | 15 | {% block title %}Models{% endblock %} |
7 | 16 | |
… |
… |
|
19 | 28 | <table class="xfull"> |
20 | 29 | {% for model in group.list %} |
21 | 30 | <tr> |
22 | | <th><a href="{{ model.app_label }}.{{ model.object_name.lower }}/">{{ model.object_name }}</a></th> |
| 31 | <th><a href="{% url 'django-admindocs-models-detail' app_label=model.app_label model_name=model.object_name.lower %}">{{ model.object_name }}</a></th> |
23 | 32 | </tr> |
24 | 33 | {% endfor %} |
25 | 34 | </table> |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/template_detail.html b/django/contrib/admindocs/templates/admin_doc/template_detail.html
index c04dedc..307dd62 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
3 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> › <a href="../../">Documentation</a> › Templates › {{ name }}</div>{% endblock %} |
| 3 | {% load url from future %} |
| 4 | |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 9 | › {% trans 'Templates' %} |
| 10 | › {{ name }} |
| 11 | </div> |
| 12 | {% endblock %} |
4 | 13 | |
5 | 14 | {% block title %}Template: {{ name }}{% endblock %} |
6 | 15 | |
… |
… |
|
17 | 26 | </ol> |
18 | 27 | {% endfor %} |
19 | 28 | |
20 | | <p class="small"><a href="../../">‹ Back to Documentation</a></p> |
| 29 | <p class="small"><a href="{% url 'django-admindocs-docroot' %}">‹ Back to Documentation</a></p> |
21 | 30 | {% endblock %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/template_filter_index.html b/django/contrib/admindocs/templates/admin_doc/template_filter_index.html
index 46ccf0f..1809bc9 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
3 | 5 | {% block coltype %}colSM{% endblock %} |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › filters</div>{% endblock %} |
| 6 | {% block breadcrumbs %} |
| 7 | <div class="breadcrumbs"> |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 10 | › {% trans 'Filters' %} |
| 11 | </div> |
| 12 | {% endblock %} |
5 | 13 | {% block title %}Template filters{% endblock %} |
6 | 14 | |
7 | 15 | {% block content %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/template_tag_index.html b/django/contrib/admindocs/templates/admin_doc/template_tag_index.html
index 676c025..18e5d95 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
3 | 5 | {% block coltype %}colSM{% endblock %} |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Tags</div>{% endblock %} |
| 6 | {% block breadcrumbs %} |
| 7 | <div class="breadcrumbs"> |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 10 | › {% trans 'Tags' %} |
| 11 | </div> |
| 12 | {% endblock %} |
5 | 13 | {% block title %}Template tags{% endblock %} |
6 | 14 | |
7 | 15 | {% block content %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/view_detail.html b/django/contrib/admindocs/templates/admin_doc/view_detail.html
index c6d080c..41c8121 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
3 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> › <a href="../../">Documentation</a> › <a href="../">Views</a> › {{ name }}</div>{% endblock %} |
| 3 | {% load url from future %} |
| 4 | |
| 5 | {% block breadcrumbs %} |
| 6 | <div class="breadcrumbs"> |
| 7 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 8 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 9 | › <a href="{% url 'django-admindocs-views-index' %}">{% trans 'Views' %}</a> |
| 10 | › {{ name }} |
| 11 | </div> |
| 12 | {% endblock %} |
4 | 13 | {% block title %}View: {{ name }}{% endblock %} |
5 | 14 | |
6 | 15 | {% block content %} |
… |
… |
|
21 | 30 | <p>{{ meta.Templates }}</p> |
22 | 31 | {% endif %} |
23 | 32 | |
24 | | <p class="small"><a href="../">‹ Back to Views Documentation</a></p> |
| 33 | <p class="small"><a href="{% url 'django-admindocs-views-index' %}">‹ Back to Views Documentation</a></p> |
25 | 34 | {% endblock %} |
-
diff --git a/django/contrib/admindocs/templates/admin_doc/view_index.html b/django/contrib/admindocs/templates/admin_doc/view_index.html
index 6b10fa6..e508c84 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n %} |
| 3 | {% load url from future %} |
| 4 | |
3 | 5 | {% block coltype %}colSM{% endblock %} |
4 | | {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Views</div>{% endblock %} |
| 6 | {% block breadcrumbs %} |
| 7 | <div class="breadcrumbs"> |
| 8 | <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> |
| 9 | › <a href="{% url 'django-admindocs-docroot' %}">{% trans 'Documentation' %}</a> |
| 10 | › {% trans 'Views' %} |
| 11 | </div> |
| 12 | {% endblock %} |
5 | 13 | {% block title %}Views{% endblock %} |
6 | 14 | |
7 | 15 | {% block content %} |
… |
… |
|
29 | 37 | |
30 | 38 | {% for view in site_views.list|dictsort:"url" %} |
31 | 39 | {% ifchanged %} |
32 | | <h3><a href="{{ view.module }}.{{ view.name }}/">{{ view.url }}</a></h3> |
33 | | <p class="small quiet">View function: {{ view.module }}.{{ view.name }}</p> |
| 40 | <h3><a href="{% url 'django-admindocs-views-detail' view=view.full_name %}">{{ view.url }}</a></h3> |
| 41 | <p class="small quiet">View function: {{ view.full_name }}</p> |
34 | 42 | <p>{{ view.title }}</p> |
35 | 43 | <hr /> |
36 | 44 | {% endifchanged %} |
-
diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
index 079f7ab..d65c257 100644
a
|
b
|
def view_index(request):
|
133 | 133 | site_obj = GenericSite() |
134 | 134 | for (func, regex) in view_functions: |
135 | 135 | views.append({ |
136 | | 'name': getattr(func, '__name__', func.__class__.__name__), |
137 | | 'module': func.__module__, |
| 136 | 'full_name': '%s.%s' % (func.__module__, getattr(func, '__name__', func.__class__.__name__)), |
138 | 137 | 'site_id': settings_mod.SITE_ID, |
139 | 138 | 'site': site_obj, |
140 | 139 | 'url': simplify_regex(regex), |
-
diff --git a/tests/regressiontests/admin_custom_urls/__init__.py b/tests/regressiontests/admin_custom_urls/__init__.py
new file mode 100644
index 0000000..792d600
-
diff --git a/tests/regressiontests/admin_custom_urls/fixtures/actions.json b/tests/regressiontests/admin_custom_urls/fixtures/actions.json
new file mode 100644
index 0000000..d803393
-
|
+
|
|
| 1 | [ |
| 2 | { |
| 3 | "pk": "delete", |
| 4 | "model": "admin_custom_urls.action", |
| 5 | "fields": { |
| 6 | "description": "Remove things." |
| 7 | } |
| 8 | }, |
| 9 | { |
| 10 | "pk": "rename", |
| 11 | "model": "admin_custom_urls.action", |
| 12 | "fields": { |
| 13 | "description": "Gives things other names." |
| 14 | } |
| 15 | }, |
| 16 | { |
| 17 | "pk": "add", |
| 18 | "model": "admin_custom_urls.action", |
| 19 | "fields": { |
| 20 | "description": "Add things." |
| 21 | } |
| 22 | }, |
| 23 | { |
| 24 | "pk": "path/to/file/", |
| 25 | "model": "admin_custom_urls.action", |
| 26 | "fields": { |
| 27 | "description": "An action with '/' in its name." |
| 28 | } |
| 29 | }, |
| 30 | { |
| 31 | "pk": "path/to/html/document.html", |
| 32 | "model": "admin_custom_urls.action", |
| 33 | "fields": { |
| 34 | "description": "An action with a name similar to a HTML doc path." |
| 35 | } |
| 36 | }, |
| 37 | { |
| 38 | "pk": "javascript:alert('Hello world');\">Click here</a>", |
| 39 | "model": "admin_custom_urls.action", |
| 40 | "fields": { |
| 41 | "description": "An action with a name suspected of being a XSS attempt" |
| 42 | } |
| 43 | } |
| 44 | ] |
| 45 | No newline at end of file |
-
diff --git a/tests/regressiontests/admin_custom_urls/fixtures/users.json b/tests/regressiontests/admin_custom_urls/fixtures/users.json
new file mode 100644
index 0000000..72d86d7
-
|
+
|
|
| 1 | [ |
| 2 | { |
| 3 | "pk": 100, |
| 4 | "model": "auth.user", |
| 5 | "fields": { |
| 6 | "username": "super", |
| 7 | "first_name": "Super", |
| 8 | "last_name": "User", |
| 9 | "is_active": true, |
| 10 | "is_superuser": true, |
| 11 | "is_staff": true, |
| 12 | "last_login": "2007-05-30 13:20:10", |
| 13 | "groups": [], |
| 14 | "user_permissions": [], |
| 15 | "password": "sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158", |
| 16 | "email": "super@example.com", |
| 17 | "date_joined": "2007-05-30 13:20:10" |
| 18 | } |
| 19 | } |
| 20 | ] |
-
diff --git a/tests/regressiontests/admin_custom_urls/models.py b/tests/regressiontests/admin_custom_urls/models.py
new file mode 100644
index 0000000..f8c83a9
-
|
+
|
|
| 1 | from functools import update_wrapper |
| 2 | |
| 3 | from django.contrib import admin |
| 4 | from django.db import models |
| 5 | |
| 6 | |
| 7 | class Action(models.Model): |
| 8 | name = models.CharField(max_length=50, primary_key=True) |
| 9 | description = models.CharField(max_length=70) |
| 10 | |
| 11 | def __unicode__(self): |
| 12 | return self.name |
| 13 | |
| 14 | |
| 15 | class ActionAdmin(admin.ModelAdmin): |
| 16 | """ |
| 17 | A ModelAdmin for the Action model that changes the URL of the add_view |
| 18 | to '<app name>/<model name>/!add/' |
| 19 | The Action model has a CharField PK. |
| 20 | """ |
| 21 | |
| 22 | list_display = ('name', 'description') |
| 23 | |
| 24 | def remove_url(self, name): |
| 25 | """ |
| 26 | Remove all entries named 'name' from the ModelAdmin instance URL |
| 27 | patterns list |
| 28 | """ |
| 29 | return filter(lambda e: e.name != name, super(ActionAdmin, self).get_urls()) |
| 30 | |
| 31 | def get_urls(self): |
| 32 | # Add the URL of our custom 'add_view' view to the front of the URLs |
| 33 | # list. Remove the existing one(s) first |
| 34 | from django.conf.urls.defaults import patterns, url |
| 35 | |
| 36 | def wrap(view): |
| 37 | def wrapper(*args, **kwargs): |
| 38 | return self.admin_site.admin_view(view)(*args, **kwargs) |
| 39 | return update_wrapper(wrapper, view) |
| 40 | |
| 41 | info = self.model._meta.app_label, self.model._meta.module_name |
| 42 | |
| 43 | view_name = '%s_%s_add' % info |
| 44 | |
| 45 | return patterns('', |
| 46 | url(r'^!add/$', wrap(self.add_view), name=view_name), |
| 47 | ) + self.remove_url(view_name) |
| 48 | |
| 49 | |
| 50 | admin.site.register(Action, ActionAdmin) |
-
diff --git a/tests/regressiontests/admin_custom_urls/tests.py b/tests/regressiontests/admin_custom_urls/tests.py
new file mode 100644
index 0000000..cfc6b85
-
|
+
|
|
| 1 | from django.core.urlresolvers import reverse |
| 2 | from django.template.response import TemplateResponse |
| 3 | from django.test import TestCase |
| 4 | |
| 5 | from models import Action |
| 6 | |
| 7 | |
| 8 | class AdminCustomUrlsTest(TestCase): |
| 9 | fixtures = ['users.json', 'actions.json'] |
| 10 | |
| 11 | def setUp(self): |
| 12 | self.client.login(username='super', password='secret') |
| 13 | |
| 14 | def tearDown(self): |
| 15 | self.client.logout() |
| 16 | |
| 17 | def testBasicAddGet(self): |
| 18 | """ |
| 19 | A smoke test to ensure GET on the add_view works. |
| 20 | """ |
| 21 | response = self.client.get('/custom_urls/admin/admin_custom_urls/action/!add/') |
| 22 | self.assertIsInstance(response, TemplateResponse) |
| 23 | self.assertEqual(response.status_code, 200) |
| 24 | |
| 25 | def testAddWithGETArgs(self): |
| 26 | response = self.client.get('/custom_urls/admin/admin_custom_urls/action/!add/', {'name': 'My Action'}) |
| 27 | self.assertEqual(response.status_code, 200) |
| 28 | self.assertTrue( |
| 29 | 'value="My Action"' in response.content, |
| 30 | "Couldn't find an input with the right value in the response." |
| 31 | ) |
| 32 | |
| 33 | def testBasicAddPost(self): |
| 34 | """ |
| 35 | A smoke test to ensure POST on add_view works. |
| 36 | """ |
| 37 | post_data = { |
| 38 | '_popup': u'1', |
| 39 | "name": u'Action added through a popup', |
| 40 | "description": u"Description of added action", |
| 41 | } |
| 42 | response = self.client.post('/custom_urls/admin/admin_custom_urls/action/!add/', post_data) |
| 43 | self.assertEqual(response.status_code, 200) |
| 44 | self.assertContains(response, 'dismissAddAnotherPopup') |
| 45 | self.assertContains(response, 'Action added through a popup') |
| 46 | |
| 47 | def testAdminUrlsNoClash(self): |
| 48 | """ |
| 49 | Test that some admin URLs work correctly. The model has a CharField |
| 50 | PK and the add_view URL has been customized. |
| 51 | """ |
| 52 | # Should get the change_view for model instance with PK 'add', not show |
| 53 | # the add_view |
| 54 | response = self.client.get('/custom_urls/admin/admin_custom_urls/action/add/') |
| 55 | self.assertEqual(response.status_code, 200) |
| 56 | self.assertContains(response, 'Change action') |
| 57 | |
| 58 | # Ditto, but use reverse() to build the URL |
| 59 | path = reverse('admin:%s_action_change' % Action._meta.app_label, |
| 60 | args=('add',)) |
| 61 | response = self.client.get(path) |
| 62 | self.assertEqual(response.status_code, 200) |
| 63 | self.assertContains(response, 'Change action') |
| 64 | |
| 65 | # Should correctly get the change_view for the model instance with the |
| 66 | # funny-looking PK |
| 67 | path = reverse('admin:%s_action_change' % Action._meta.app_label, |
| 68 | args=("path/to/html/document.html",)) |
| 69 | response = self.client.get(path) |
| 70 | self.assertEqual(response.status_code, 200) |
| 71 | self.assertContains(response, 'Change action') |
| 72 | self.assertContains(response, 'value="path/to/html/document.html"') |
-
diff --git a/tests/regressiontests/admin_custom_urls/urls.py b/tests/regressiontests/admin_custom_urls/urls.py
new file mode 100644
index 0000000..6c2761a
-
|
+
|
|
| 1 | from django.conf.urls.defaults import * |
| 2 | from django.contrib import admin |
| 3 | |
| 4 | urlpatterns = patterns('', |
| 5 | (r'^admin/', include(admin.site.urls)), |
| 6 | ) |
| 7 | |
-
diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py
index ee0abd1..9f7d080 100644
a
|
b
|
class BookInline(admin.TabularInline):
|
44 | 44 | class AuthorAdmin(admin.ModelAdmin): |
45 | 45 | inlines = [BookInline] |
46 | 46 | |
| 47 | admin.site.register(Book) |
47 | 48 | admin.site.register(Author, AuthorAdmin) |
48 | 49 | |
49 | 50 | class Holder(models.Model): |
-
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 7128f04..85fb66c 100644
a
|
b
|
class SaveAsTests(TestCase):
|
585 | 585 | self.assertTrue(response.context['save_as']) |
586 | 586 | post_data = {'_saveasnew':'', 'name':'John M', 'gender':3, 'alive':'checked'} |
587 | 587 | response = self.client.post('/test_admin/admin/admin_views/person/1/', post_data) |
588 | | self.assertEqual(response.context['form_url'], '../add/') |
| 588 | self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/') |
589 | 589 | |
590 | 590 | class CustomModelAdminTest(AdminViewBasicTest): |
591 | 591 | urlbit = "admin2" |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
830 | 830 | self.client.post('/test_admin/admin/', self.adduser_login) |
831 | 831 | addpage = self.client.get('/test_admin/admin/admin_views/article/add/') |
832 | 832 | self.assertEqual(addpage.status_code, 200) |
833 | | change_list_link = '<a href="../">Articles</a> ›' |
| 833 | change_list_link = '› <a href="/test_admin/admin/admin_views/article/">Articles</a>' |
834 | 834 | self.assertFalse(change_list_link in addpage.content, |
835 | 835 | 'User restricted to add permission is given link to change list view in breadcrumbs.') |
836 | 836 | post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict) |
-
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 3cdb017..ac3baa0 100644
a
|
b
|
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
|
255 | 255 | ) |
256 | 256 | rel = models.Album._meta.get_field('band').rel |
257 | 257 | |
258 | | w = ForeignKeyRawIdWidget(rel) |
| 258 | w = ForeignKeyRawIdWidget(rel, admin.site) |
259 | 259 | self.assertEqual( |
260 | 260 | conditional_escape(w.render('test', band.pk, attrs={})), |
261 | | '<input type="text" name="test" value="%(bandpk)s" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/band/?t=id" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Linkin Park</strong>' % dict(admin_media_prefix(), bandpk=band.pk), |
| 261 | '<input type="text" name="test" value="%(bandpk)s" /> <strong>Linkin Park</strong>' % {"bandpk": band.pk} |
262 | 262 | ) |
263 | 263 | |
264 | 264 | def test_relations_to_non_primary_key(self): |
… |
… |
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
|
270 | 270 | barcode=87, name='Core', parent=apple |
271 | 271 | ) |
272 | 272 | rel = models.Inventory._meta.get_field('parent').rel |
273 | | w = ForeignKeyRawIdWidget(rel) |
| 273 | w = ForeignKeyRawIdWidget(rel, admin.site) |
274 | 274 | self.assertEqual( |
275 | 275 | w.render('test', core.parent_id, attrs={}), |
276 | | '<input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong>' % admin_media_prefix(), |
| 276 | '<input type="text" name="test" value="86" /> <strong>Apple</strong>', |
277 | 277 | ) |
278 | 278 | |
279 | 279 | |
280 | 280 | def test_proper_manager_for_label_lookup(self): |
281 | 281 | # see #9258 |
282 | 282 | rel = models.Inventory._meta.get_field('parent').rel |
283 | | w = ForeignKeyRawIdWidget(rel) |
| 283 | w = ForeignKeyRawIdWidget(rel, admin.site) |
284 | 284 | |
285 | 285 | hidden = models.Inventory.objects.create( |
286 | 286 | barcode=93, name='Hidden', hidden=True |
… |
… |
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
|
290 | 290 | ) |
291 | 291 | self.assertEqual( |
292 | 292 | w.render('test', child_of_hidden.parent_id, attrs={}), |
293 | | '<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Hidden</strong>' % admin_media_prefix(), |
| 293 | '<input type="text" name="test" value="93" /> <strong>Hidden</strong>', |
294 | 294 | ) |
295 | 295 | |
296 | 296 | |
… |
… |
class ManyToManyRawIdWidgetTest(DjangoTestCase):
|
306 | 306 | band.members.add(m1, m2) |
307 | 307 | rel = models.Band._meta.get_field('members').rel |
308 | 308 | |
309 | | w = ManyToManyRawIdWidget(rel) |
| 309 | w = ManyToManyRawIdWidget(rel, admin.site) |
310 | 310 | self.assertEqual( |
311 | 311 | conditional_escape(w.render('test', [m1.pk, m2.pk], attrs={})), |
312 | | '<input type="text" name="test" value="%(m1pk)s,%(m2pk)s" class="vManyToManyRawIdAdminField" /><a href="../../../admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_media_prefix(), m1pk=m1.pk, m2pk=m2.pk), |
| 312 | '<input type="text" name="test" value="%(m1pk)s,%(m2pk)s" class="vManyToManyRawIdAdminField" />' % {"m1pk": m1.pk, "m2pk": m2.pk}, |
313 | 313 | ) |
314 | 314 | |
315 | 315 | self.assertEqual( |
316 | 316 | conditional_escape(w.render('test', [m1.pk])), |
317 | | '<input type="text" name="test" value="%(m1pk)s" class="vManyToManyRawIdAdminField" /><a href="../../../admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_media_prefix(), m1pk=m1.pk, m2pk=m2.pk), |
| 317 | '<input type="text" name="test" value="%(m1pk)s" class="vManyToManyRawIdAdminField" />' % {"m1pk": m1.pk}, |
318 | 318 | ) |
319 | 319 | |
320 | 320 | self.assertEqual(w._has_changed(None, None), False) |
-
diff --git a/tests/regressiontests/admin_widgets/widgetadmin.py b/tests/regressiontests/admin_widgets/widgetadmin.py
index 6f15d92..9082f8a 100644
a
|
b
|
site.register(models.User)
|
28 | 28 | site.register(models.Car, CarAdmin) |
29 | 29 | site.register(models.CarTire, CarTireAdmin) |
30 | 30 | site.register(models.Event, EventAdmin) |
| 31 | |
| 32 | site.register(models.Inventory) |
| 33 | site.register(models.Member) |
| 34 | site.register(models.Band) |
-
diff --git a/tests/urls.py b/tests/urls.py
index b3f719d..929a913 100644
a
|
b
|
urlpatterns = patterns('',
|
29 | 29 | # admin widget tests |
30 | 30 | (r'widget_admin/', include('regressiontests.admin_widgets.urls')), |
31 | 31 | |
| 32 | # admin custom URL tests |
| 33 | (r'^custom_urls/', include('regressiontests.admin_custom_urls.urls')), |
| 34 | |
32 | 35 | ) |