Ticket #10061: admin-urls.13.diff

File admin-urls.13.diff, 14.4 KB (added by Alex Gaynor, 15 years ago)

Probably just a whitespace change, but I can't remember if I've had to resolve any merge conflicts

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 8297eca..6a7e884 100644
    a b class ModelAdmin(BaseModelAdmin):  
    235235            url(r'^add/$',
    236236                wrap(self.add_view),
    237237                name='%sadmin_%s_%s_add' % info),
    238             url(r'^(.+)/history/$',
     238            url(r'^(?P<object_id>.+)/history/$',
    239239                wrap(self.history_view),
    240240                name='%sadmin_%s_%s_history' % info),
    241             url(r'^(.+)/delete/$',
     241            url(r'^(?P<object_id>.+)/delete/$',
    242242                wrap(self.delete_view),
    243243                name='%sadmin_%s_%s_delete' % info),
    244             url(r'^(.+)/$',
     244            url(r'^(?P<object_id>.+)/$',
    245245                wrap(self.change_view),
    246246                name='%sadmin_%s_%s_change' % info),
    247247        )
    class ModelAdmin(BaseModelAdmin):  
    581581            'save_as': self.save_as,
    582582            'save_on_top': self.save_on_top,
    583583            'root_path': self.admin_site.root_path,
     584            'admin_site': self.admin_site.name,
    584585        })
    585586        return render_to_response(self.change_form_template or [
    586587            "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()),
    class ModelAdmin(BaseModelAdmin):  
    778779            'errors': helpers.AdminErrorList(form, formsets),
    779780            'root_path': self.admin_site.root_path,
    780781            'app_label': opts.app_label,
     782            'admin_site': self.admin_site.name,
    781783        }
    782784        context.update(extra_context or {})
    783785        return self.render_change_form(request, context, form_url=form_url, add=True)
    class ModelAdmin(BaseModelAdmin):  
    866868            'inline_admin_formsets': inline_admin_formsets,
    867869            'errors': helpers.AdminErrorList(form, formsets),
    868870            'root_path': self.admin_site.root_path,
     871            'admin_site': self.admin_site.name,
    869872            'app_label': opts.app_label,
    870873        }
    871874        context.update(extra_context or {})
    class ModelAdmin(BaseModelAdmin):  
    971974            'media': media,
    972975            'has_add_permission': self.has_add_permission(request),
    973976            'root_path': self.admin_site.root_path,
     977            'admin_site': self.admin_site.name,
    974978            'app_label': app_label,
    975979            'action_form': action_form,
    976980            'actions_on_top': self.actions_on_top,
    class ModelAdmin(BaseModelAdmin):  
    10291033            "perms_lacking": perms_needed,
    10301034            "opts": opts,
    10311035            "root_path": self.admin_site.root_path,
     1036            'admin_site': self.admin_site.name,
    10321037            "app_label": app_label,
    10331038        }
    10341039        context.update(extra_context or {})
    class ModelAdmin(BaseModelAdmin):  
    10561061            'module_name': capfirst(force_unicode(opts.verbose_name_plural)),
    10571062            'object': obj,
    10581063            'root_path': self.admin_site.root_path,
     1064            'admin_site': self.admin_site.name,
    10591065            'app_label': app_label,
    10601066        }
    10611067        context.update(extra_context or {})
  • django/contrib/admin/sites.py

    diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
    index 6e9ef11..1ad86fd 100644
    a b from django.contrib.admin import ModelAdmin  
    44from django.contrib.admin import actions
    55from django.contrib.auth import authenticate, login
    66from django.db.models.base import ModelBase
     7from django.core.urlresolvers import reverse
    78from django.core.exceptions import ImproperlyConfigured
    89from django.shortcuts import render_to_response
    910from django.utils.functional import update_wrapper
    class AdminSite(object):  
    4041
    4142    def __init__(self, name=None):
    4243        self._registry = {} # model_class class -> admin_class instance
    43         # TODO Root path is used to calculate urls under the old root() method
    44         # in order to maintain backwards compatibility we are leaving that in
    45         # so root_path isn't needed, not sure what to do about this.
    46         self.root_path = 'admin/'
     44        self.root_path = None
    4745        if name is None:
    4846            name = ''
    4947        else:
    class AdminSite(object):  
    199197                name='%sadmin_index' % self.name),
    200198            url(r'^logout/$',
    201199                wrap(self.logout),
    202                 name='%sadmin_logout'),
     200                name='%sadmin_logout' % self.name),
    203201            url(r'^password_change/$',
    204202                wrap(self.password_change),
    205203                name='%sadmin_password_change' % self.name),
    class AdminSite(object):  
    233231        Handles the "change password" task -- both form display and validation.
    234232        """
    235233        from django.contrib.auth.views import password_change
    236         return password_change(request,
    237             post_change_redirect='%spassword_change/done/' % self.root_path)
     234        if self.root_path is not None:
     235            url = '%spassword_change/done/' % self.root_path
     236        else:
     237            url = reverse('%sadmin_password_change_done' % self.name)
     238        return password_change(request, post_change_redirect=url)
    238239
    239240    def password_change_done(self, request):
    240241        """
    class AdminSite(object):  
    360361            'title': _('Site administration'),
    361362            'app_list': app_list,
    362363            'root_path': self.root_path,
     364            'admin_site': self.name
    363365        }
    364366        context.update(extra_context or {})
    365367        return render_to_response(self.index_template or 'admin/index.html', context,
    class AdminSite(object):  
    374376            'app_path': request.get_full_path(),
    375377            'error_message': error_message,
    376378            'root_path': self.root_path,
     379            'admin_site': self.name,
    377380        }
    378381        context.update(extra_context or {})
    379382        return render_to_response(self.login_template or 'admin/login.html', context,
    class AdminSite(object):  
    417420            'title': _('%s administration') % capfirst(app_label),
    418421            'app_list': [app_dict],
    419422            'root_path': self.root_path,
     423            'admin_site': self.name,
    420424        }
    421425        context.update(extra_context or {})
    422426        return render_to_response(self.app_index_template or ('admin/%s/app_index.html' % app_label,
  • django/contrib/admin/templates/admin/base.html

    diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
    index 8cab439..cbbbd54 100644
    a b  
    2323        {% block branding %}{% endblock %}
    2424        </div>
    2525        {% if user.is_authenticated and user.is_staff %}
    26         <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>
     26        <div id="user-tools">
     27            {% trans 'Welcome,' %}
     28            <strong>{% firstof user.first_name user.username %}</strong>.
     29            {% block userlinks %}
     30                {% url django-admindocs-docroot as docsroot %}
     31                {% if docsroot %}
     32                    <a href="{{ docsroot }}">
     33                        {% trans 'Documentation' %}
     34                    </a> /
     35                {% endif %}
     36                {% url admin_site:admin_password_change as password_change_url %}
     37                {% if password_change_url %}
     38                    <a href="{{ password_change_url }}">
     39                {% else %}
     40                    <a href="{{ root_path }}password_change/">
     41                {% endif %}
     42                    {% trans 'Change password' %}
     43                </a> /
     44                {% url admin_site:admin_logout as logout_url %}
     45                {% if logout_url %}
     46                    <a href="{{ logout_url }}">
     47                {% else %}
     48                    <a href="{{ root_path }}logout/">
     49                {% endif %}
     50                    {% trans 'Log out' %}
     51                </a>
     52            {% endblock %}
     53        </div>
    2754        {% endif %}
    2855        {% block nav-global %}{% endblock %}
    2956    </div>
  • django/contrib/auth/admin.py

    diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
    index 34691c0..48dc3e5 100644
    a b class UserAdmin(admin.ModelAdmin):  
    9292            'save_as': False,
    9393            'username_help_text': self.model._meta.get_field('username').help_text,
    9494            'root_path': self.admin_site.root_path,
     95            'admin_site': self.admin_site.name,
    9596            'app_label': self.model._meta.app_label,           
    9697        }, context_instance=template.RequestContext(request))
    9798
    class UserAdmin(admin.ModelAdmin):  
    122123            'save_as': False,
    123124            'show_save': True,
    124125            'root_path': self.admin_site.root_path,
     126            'admin_site': self.admin_site.name,
    125127        }, context_instance=RequestContext(request))
    126128
    127129
  • django/contrib/comments/views/moderation.py

    diff --git a/django/contrib/comments/views/moderation.py b/django/contrib/comments/views/moderation.py
    index 3334b09..880c6d7 100644
    a b from django.core.paginator import Paginator, InvalidPage  
    77from django.http import Http404
    88from django.contrib import comments
    99from django.contrib.comments import signals
     10from django.contrib import admin
    1011
    1112#@login_required
    1213def flag(request, comment_id, next=None):
    def moderation_queue(request):  
    185186        'previous': page - 1,
    186187        'pages': paginator.num_pages,
    187188        'hits' : paginator.count,
    188         'page_range' : paginator.page_range
     189        'page_range' : paginator.page_range,
     190        'admin_site': admin.site.name,
    189191    }, context_instance=template.RequestContext(request))
    190192
    191193moderation_queue = permission_required("comments.can_moderate")(moderation_queue)
  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index ac83756..32ba34c 100644
    a b def resolve(path, urlconf=None):  
    257257    return get_resolver(urlconf).resolve(path)
    258258
    259259def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None):
     260    if isinstance(viewname, basestring):
     261        viewname = ''.join(viewname.split(':'))
    260262    args = args or []
    261263    kwargs = kwargs or {}
    262264    if prefix is None:
  • django/template/defaulttags.py

    diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
    index a61dd8b..630078c 100644
    a b class URLNode(Node):  
    357357
    358358    def render(self, context):
    359359        from django.core.urlresolvers import reverse, NoReverseMatch
     360        view_name_parts = []
     361        for part in self.view_name[:-1]:
     362            try:
     363                view_name_parts.append(Variable(part).resolve(context))
     364            except VariableDoesNotExist:
     365                view_name_parts.append(part)
     366        view_name_parts.append(self.view_name[-1])
     367        view_name = ':'.join(view_name_parts)
    360368        args = [arg.resolve(context) for arg in self.args]
    361369        kwargs = dict([(smart_str(k,'ascii'), v.resolve(context))
    362370                       for k, v in self.kwargs.items()])
    class URLNode(Node):  
    367375        # {% url ... as var %} construct in which cause return nothing.
    368376        url = ''
    369377        try:
    370             url = reverse(self.view_name, args=args, kwargs=kwargs)
     378            url = reverse(view_name, args=args, kwargs=kwargs)
    371379        except NoReverseMatch, e:
    372380            if settings.SETTINGS_MODULE:
    373381                project_name = settings.SETTINGS_MODULE.split('.')[0]
    374382                try:
    375                     url = reverse(project_name + '.' + self.view_name,
     383                    url = reverse(project_name + '.' + view_name,
    376384                              args=args, kwargs=kwargs)
    377385                except NoReverseMatch:
    378386                    if self.asvar is None:
    379387                        # Re-raise the original exception, not the one with
    380                         # the path relative to the project. This makes a 
     388                        # the path relative to the project. This makes a
    381389                        # better error message.
    382390                        raise e
    383391            else:
    def url(parser, token):  
    11051113        raise TemplateSyntaxError("'%s' takes at least one argument"
    11061114                                  " (path to a view)" % bits[0])
    11071115    viewname = bits[1]
     1116    if ':' in viewname:
     1117        viewname = viewname.split(':')
     1118    else:
     1119        viewname = [viewname]
    11081120    args = []
    11091121    kwargs = {}
    11101122    asvar = None
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 8e7010b..283a41b 100644
    a b class AdminViewBasicTest(TestCase):  
    203203        response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'color__id__exact': 'StringNotInteger!'})
    204204        self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit)
    205205
     206    def testLogoutAndPasswordChangeURLs(self):
     207        response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit)
     208        self.failIf('<a href="/test_admin/%s/logout/">' % self.urlbit not in response.content)
     209        self.failIf('<a href="/test_admin/%s/password_change/">' % self.urlbit not in response.content)
     210
    206211    def testNamedGroupFieldChoicesChangeList(self):
    207212        """
    208213        Ensures the admin changelist shows correct values in the relevant column
  • tests/urls.py

    diff --git a/tests/urls.py b/tests/urls.py
    index 6704829..31faea5 100644
    a b urlpatterns = patterns('',  
    2121    # test urlconf for middleware tests
    2222    (r'^middleware/', include('regressiontests.middleware.urls')),
    2323
     24    # admin widget tests
     25    (r'widget_admin/', include('regressiontests.admin_widgets.urls')),
     26
    2427    # admin view tests
    2528    (r'^test_admin/', include('regressiontests.admin_views.urls')),
    2629    (r'^generic_inline_admin/', include('regressiontests.generic_inline_admin.urls')),
    2730
    28     # admin widget tests
    29     (r'widget_admin/', include('regressiontests.admin_widgets.urls')),
    3031
    3132    (r'^utils/', include('regressiontests.utils.urls')),
    3233
Back to Top