Ticket #10061: admin-urls.diff
| File admin-urls.diff, 8.5 kB (added by Alex, 1 year ago) |
|---|
-
a/django/contrib/admin/options.py
old new 437 437 'save_as': self.save_as, 438 438 'save_on_top': self.save_on_top, 439 439 'root_path': self.admin_site.root_path, 440 'admin_site': self.admin_site.name, 440 441 }) 441 442 return render_to_response(self.change_form_template or [ 442 443 "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), … … 571 572 'errors': helpers.AdminErrorList(form, formsets), 572 573 'root_path': self.admin_site.root_path, 573 574 'app_label': opts.app_label, 575 'admin_site': self.admin_site.name, 574 576 } 575 577 context.update(extra_context or {}) 576 578 return self.render_change_form(request, context, add=True) … … 649 651 'inline_admin_formsets': inline_admin_formsets, 650 652 'errors': helpers.AdminErrorList(form, formsets), 651 653 'root_path': self.admin_site.root_path, 654 'admin_site': self.admin_site.name, 652 655 'app_label': opts.app_label, 653 656 } 654 657 context.update(extra_context or {}) … … 681 684 'cl': cl, 682 685 'has_add_permission': self.has_add_permission(request), 683 686 'root_path': self.admin_site.root_path, 687 'admin_site': self.admin_site.name, 684 688 'app_label': app_label, 685 689 } 686 690 context.update(extra_context or {}) … … 736 740 "perms_lacking": perms_needed, 737 741 "opts": opts, 738 742 "root_path": self.admin_site.root_path, 743 'admin_site': self.admin_site.name, 739 744 "app_label": app_label, 740 745 } 741 746 context.update(extra_context or {}) … … 763 768 'module_name': capfirst(force_unicode(opts.verbose_name_plural)), 764 769 'object': obj, 765 770 'root_path': self.admin_site.root_path, 771 'admin_site': self.admin_site.name, 766 772 'app_label': app_label, 767 773 } 768 774 context.update(extra_context or {}) -
a/django/contrib/admin/sites.py
old new 3 3 from django.contrib.admin import ModelAdmin 4 4 from django.contrib.auth import authenticate, login 5 5 from django.db.models.base import ModelBase 6 from django.core.urlresolvers import reverse 6 7 from django.core.exceptions import ImproperlyConfigured 7 8 from django.shortcuts import render_to_response 8 9 from django.utils.functional import update_wrapper … … 35 36 36 37 def __init__(self, name=None): 37 38 self._registry = {} # model_class class -> admin_class instance 38 # TODO Root path is used to calculate urls under the old root() method 39 # in order to maintain backwards compatibility we are leaving that in 40 # so root_path isn't needed, not sure what to do about this. 41 self.root_path = 'admin/' 39 self.root_path = None 42 40 if name is None: 43 41 name = '' 44 42 else: … … 163 161 name='%sadmin_index' % self.name), 164 162 url(r'^logout/$', 165 163 wrap(self.logout), 166 name='%sadmin_logout' ),164 name='%sadmin_logout' % self.name), 167 165 url(r'^password_change/$', 168 166 wrap(self.password_change), 169 167 name='%sadmin_password_change' % self.name), … … 197 195 Handles the "change password" task -- both form display and validation. 198 196 """ 199 197 from django.contrib.auth.views import password_change 198 if self.root_path is not None: 199 url = '%spassword_change/done/' % self.root_path 200 else: 201 url = reverse('%sadmin_logout' % self.name) 200 202 return password_change(request, 201 post_change_redirect= '%spassword_change/done/' % self.root_path)203 post_change_redirect=url) 202 204 203 205 def password_change_done(self, request): 204 206 """ … … 328 330 'title': _('Site administration'), 329 331 'app_list': app_list, 330 332 'root_path': self.root_path, 333 'admin_site': self.name 331 334 } 332 335 context.update(extra_context or {}) 333 336 return render_to_response(self.index_template or 'admin/index.html', context, … … 342 345 'app_path': request.get_full_path(), 343 346 'error_message': error_message, 344 347 'root_path': self.root_path, 348 'admin_site': self.name, 345 349 } 346 350 context.update(extra_context or {}) 347 351 return render_to_response(self.login_template or 'admin/login.html', context, … … 388 392 'title': _('%s administration') % capfirst(app_label), 389 393 'app_list': [app_dict], 390 394 'root_path': self.root_path, 395 'admin_site': self.name, 391 396 } 392 397 context.update(extra_context or {}) 393 398 return render_to_response(self.app_index_template or 'admin/app_index.html', context, -
a/django/contrib/admin/templates/admin/base.html
old new 25 25 {% block branding %}{% endblock %} 26 26 </div> 27 27 {% if user.is_authenticated and user.is_staff %} 28 <div id="user-tools">{% trans 'Welcome,' %} <strong>{% firstof user.first_name user.username %}</strong>. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}<a href="{{ root_path }}password_change/">{% trans 'Change password' %}</a> / <a href="{{ root_path }}logout/">{% trans 'Log out' %}</a>{% endblock %}</div> 28 <div id="user-tools"> 29 {% trans 'Welcome,' %} 30 <strong> 31 {% firstof user.first_name user.username %} 32 </strong>. 33 {% block userlinks %} 34 {% url django-admindocs-docroot as docsroot %} 35 {% if docsroot %} 36 <a href="{{ docsroot }}"> 37 {% trans 'Documentation' %} 38 </a> / 39 {% endif %} 40 {% url admin_site:admin_password_change as password_change_url %} 41 {% if password_change_url %} 42 <a href="{{ password_change_url }}"> 43 {% else %} 44 <a href="{{ root_path }}password_change/"> 45 {% endif %} 46 {% trans 'Change password' %} 47 </a> / 48 {% url admin_site:admin_logout as logout_url %} 49 {% if logout_url %} 50 <a href="{{ logout_url }}"> 51 {% else %} 52 <a href="{{ root_path }}logout/"> 53 {% endif %} 54 {% trans 'Log out' %} 55 </a> 56 {% endblock %} 57 </div> 29 58 {% endif %} 30 59 {% block nav-global %}{% endblock %} 31 60 </div> -
a/django/template/defaulttags.py
old new 368 368 369 369 def render(self, context): 370 370 from django.core.urlresolvers import reverse, NoReverseMatch 371 if len(self.view_name) > 1: 372 self.view_name = Variable(self.view_name[0]).resolve(context) + self.view_name[1] 373 else: 374 self.view_name = self.view_name[0] 371 375 args = [arg.resolve(context) for arg in self.args] 372 376 kwargs = dict([(smart_str(k,'ascii'), v.resolve(context)) 373 377 for k, v in self.kwargs.items()]) … … 1102 1106 raise TemplateSyntaxError("'%s' takes at least one argument" 1103 1107 " (path to a view)" % bits[0]) 1104 1108 viewname = bits[1] 1109 if ':' in viewname: 1110 viewname = viewname.split(':') 1111 else: 1112 viewname = [viewname] 1105 1113 args = [] 1106 1114 kwargs = {} 1107 1115 asvar = None
