Skip to content

Commit

Permalink
Removed deprecated admin contrib app AdminSite root_path attribute. R…
Browse files Browse the repository at this point in the history
…efs #15294, r11250, r16136.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16575 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
ramiro committed Jul 30, 2011
1 parent 5120f01 commit ff9a666
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 33 deletions.
1 change: 0 additions & 1 deletion django/contrib/admin/actions.py
Expand Up @@ -69,7 +69,6 @@ def delete_selected(modeladmin, request, queryset):
"perms_lacking": perms_needed, "perms_lacking": perms_needed,
"protected": protected, "protected": protected,
"opts": opts, "opts": opts,
"root_path": modeladmin.admin_site.root_path,
"app_label": app_label, "app_label": app_label,
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
} }
Expand Down
6 changes: 0 additions & 6 deletions django/contrib/admin/options.py
Expand Up @@ -726,7 +726,6 @@ def render_change_form(self, request, context, add=False, change=False, form_url
'content_type_id': ContentType.objects.get_for_model(self.model).id, 'content_type_id': ContentType.objects.get_for_model(self.model).id,
'save_as': self.save_as, 'save_as': self.save_as,
'save_on_top': self.save_on_top, 'save_on_top': self.save_on_top,
'root_path': self.admin_site.root_path,
}) })
if add and self.add_form_template is not None: if add and self.add_form_template is not None:
form_template = self.add_form_template form_template = self.add_form_template
Expand Down Expand Up @@ -962,7 +961,6 @@ def add_view(self, request, form_url='', extra_context=None):
'media': mark_safe(media), 'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets, 'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets), 'errors': helpers.AdminErrorList(form, formsets),
'root_path': self.admin_site.root_path,
'app_label': opts.app_label, 'app_label': opts.app_label,
} }
context.update(extra_context or {}) context.update(extra_context or {})
Expand Down Expand Up @@ -1053,7 +1051,6 @@ def change_view(self, request, object_id, extra_context=None):
'media': mark_safe(media), 'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets, 'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets), 'errors': helpers.AdminErrorList(form, formsets),
'root_path': self.admin_site.root_path,
'app_label': opts.app_label, 'app_label': opts.app_label,
} }
context.update(extra_context or {}) context.update(extra_context or {})
Expand Down Expand Up @@ -1195,7 +1192,6 @@ def changelist_view(self, request, extra_context=None):
'cl': cl, 'cl': cl,
'media': media, 'media': media,
'has_add_permission': self.has_add_permission(request), 'has_add_permission': self.has_add_permission(request),
'root_path': self.admin_site.root_path,
'app_label': app_label, 'app_label': app_label,
'action_form': action_form, 'action_form': action_form,
'actions_on_top': self.actions_on_top, 'actions_on_top': self.actions_on_top,
Expand Down Expand Up @@ -1260,7 +1256,6 @@ def delete_view(self, request, object_id, extra_context=None):
"perms_lacking": perms_needed, "perms_lacking": perms_needed,
"protected": protected, "protected": protected,
"opts": opts, "opts": opts,
"root_path": self.admin_site.root_path,
"app_label": app_label, "app_label": app_label,
} }
context.update(extra_context or {}) context.update(extra_context or {})
Expand Down Expand Up @@ -1288,7 +1283,6 @@ def history_view(self, request, object_id, extra_context=None):
'action_list': action_list, 'action_list': action_list,
'module_name': capfirst(force_unicode(opts.verbose_name_plural)), 'module_name': capfirst(force_unicode(opts.verbose_name_plural)),
'object': obj, 'object': obj,
'root_path': self.admin_site.root_path,
'app_label': app_label, 'app_label': app_label,
} }
context.update(extra_context or {}) context.update(extra_context or {})
Expand Down
9 changes: 1 addition & 8 deletions django/contrib/admin/sites.py
Expand Up @@ -41,7 +41,6 @@ class AdminSite(object):


def __init__(self, name=None, app_name='admin'): def __init__(self, name=None, app_name='admin'):
self._registry = {} # model_class class -> admin_class instance self._registry = {} # model_class class -> admin_class instance
self.root_path = None
if name is None: if name is None:
self.name = 'admin' self.name = 'admin'
else: else:
Expand Down Expand Up @@ -254,10 +253,7 @@ def password_change(self, request):
Handles the "change password" task -- both form display and validation. Handles the "change password" task -- both form display and validation.
""" """
from django.contrib.auth.views import password_change from django.contrib.auth.views import password_change
if self.root_path is not None: url = reverse('admin:password_change_done', current_app=self.name)
url = '%spassword_change/done/' % self.root_path
else:
url = reverse('admin:password_change_done', current_app=self.name)
defaults = { defaults = {
'current_app': self.name, 'current_app': self.name,
'post_change_redirect': url 'post_change_redirect': url
Expand Down Expand Up @@ -316,7 +312,6 @@ def login(self, request, extra_context=None):
from django.contrib.auth.views import login from django.contrib.auth.views import login
context = { context = {
'title': _('Log in'), 'title': _('Log in'),
'root_path': self.root_path,
'app_path': request.get_full_path(), 'app_path': request.get_full_path(),
REDIRECT_FIELD_NAME: request.get_full_path(), REDIRECT_FIELD_NAME: request.get_full_path(),
} }
Expand Down Expand Up @@ -373,7 +368,6 @@ def index(self, request, extra_context=None):
context = { context = {
'title': _('Site administration'), 'title': _('Site administration'),
'app_list': app_list, 'app_list': app_list,
'root_path': self.root_path,
} }
context.update(extra_context or {}) context.update(extra_context or {})
return TemplateResponse(request, [ return TemplateResponse(request, [
Expand Down Expand Up @@ -416,7 +410,6 @@ def app_index(self, request, app_label, extra_context=None):
context = { context = {
'title': _('%s administration') % capfirst(app_label), 'title': _('%s administration') % capfirst(app_label),
'app_list': [app_dict], 'app_list': [app_dict],
'root_path': self.root_path,
} }
context.update(extra_context or {}) context.update(extra_context or {})


Expand Down
14 changes: 2 additions & 12 deletions django/contrib/admin/templates/admin/base.html
Expand Up @@ -32,19 +32,9 @@
{% if docsroot %} {% if docsroot %}
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / <a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
{% endif %} {% endif %}
{% url 'admin:password_change' as password_change_url %} <a href="{% url 'admin:password_change' %}">
{% if password_change_url %}
<a href="{{ password_change_url }}">
{% else %}
<a href="{{ root_path }}password_change/">
{% endif %}
{% trans 'Change password' %}</a> / {% trans 'Change password' %}</a> /
{% url 'admin:logout' as logout_url %} <a href="{% url 'admin:logout' %}">
{% if logout_url %}
<a href="{{ logout_url }}">
{% else %}
<a href="{{ root_path }}logout/">
{% endif %}
{% trans 'Log out' %}</a> {% trans 'Log out' %}</a>
{% endblock %} {% endblock %}
</div> </div>
Expand Down
6 changes: 1 addition & 5 deletions django/contrib/admin/widgets.py
Expand Up @@ -228,14 +228,10 @@ def _media(self):
def render(self, name, value, *args, **kwargs): def render(self, name, value, *args, **kwargs):
rel_to = self.rel.to rel_to = self.rel.to
info = (rel_to._meta.app_label, rel_to._meta.object_name.lower()) info = (rel_to._meta.app_label, rel_to._meta.object_name.lower())
try:
related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
except NoReverseMatch:
info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
related_url = '%s%s/%s/add/' % info
self.widget.choices = self.choices self.widget.choices = self.choices
output = [self.widget.render(name, value, *args, **kwargs)] output = [self.widget.render(name, value, *args, **kwargs)]
if self.can_add_related: if self.can_add_related:
related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
# TODO: "id_" is hard-coded here. This should instead use the correct # TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically. # API to determine the ID dynamically.
output.append(u'<a href="%s" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' output.append(u'<a href="%s" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> '
Expand Down
1 change: 0 additions & 1 deletion django/contrib/auth/admin.py
Expand Up @@ -136,7 +136,6 @@ def user_change_password(self, request, id):
'original': user, 'original': user,
'save_as': False, 'save_as': False,
'show_save': True, 'show_save': True,
'root_path': self.admin_site.root_path,
} }
return TemplateResponse(request, [ return TemplateResponse(request, [
self.change_user_password_template or self.change_user_password_template or
Expand Down

0 comments on commit ff9a666

Please sign in to comment.