Ticket #17189: 17189.patch

File 17189.patch, 4.2 KB (added by michal@…, 13 years ago)

Fixes passing form_url to change_password.html template

  • django/contrib/auth/admin.py

    diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
    index 5e9ac9d..dbcf52d 100644
    a b from django.shortcuts import get_object_or_404  
    1111from django.template.response import TemplateResponse
    1212from django.utils.html import escape
    1313from django.utils.decorators import method_decorator
     14from django.utils.safestring import mark_safe
    1415from django.utils.translation import ugettext, ugettext_lazy as _
    1516from django.views.decorators.csrf import csrf_protect
    1617from django.views.decorators.debug import sensitive_post_parameters
    class UserAdmin(admin.ModelAdmin):  
    113114                                               extra_context)
    114115
    115116    @sensitive_post_parameters()
    116     def user_change_password(self, request, id):
     117    def user_change_password(self, request, id, form_url=''):
    117118        if not self.has_change_permission(request):
    118119            raise PermissionDenied
    119120        user = get_object_or_404(self.model, pk=id)
    class UserAdmin(admin.ModelAdmin):  
    133134        context = {
    134135            'title': _('Change password: %s') % escape(user.username),
    135136            'adminForm': adminForm,
     137            'form_url': mark_safe(form_url),
    136138            'form': form,
    137139            'is_popup': '_popup' in request.REQUEST,
    138140            'add': True,
  • django/contrib/auth/fixtures/authtestdata.json

    diff --git a/django/contrib/auth/fixtures/authtestdata.json b/django/contrib/auth/fixtures/authtestdata.json
    index c286743..4e88a07 100644
    a b  
    5252            "email": "staffmember@example.com",
    5353            "date_joined": "2006-12-17 07:03:31"
    5454        }
     55    },
     56    {
     57        "pk": "4",
     58        "model": "auth.user",
     59        "fields": {
     60            "username": "superuser",
     61            "first_name": "Superuser",
     62            "last_name": "Member",
     63            "is_active": true,
     64            "is_superuser": true,
     65            "is_staff": true,
     66            "last_login": "2006-12-17 07:03:31",
     67            "groups": [],
     68            "user_permissions": [],
     69            "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
     70            "email": "superusermember@example.com",
     71            "date_joined": "2006-12-17 07:03:31"
     72        }
    5573    }
    5674]
  • django/contrib/auth/tests/urls.py

    diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py
    index dbbd35e..f08e63b 100644
    a b  
    1 from django.conf.urls import patterns, url
     1from django.conf.urls import patterns, url, include
    22from django.contrib.auth import context_processors
    33from django.contrib.auth.urls import urlpatterns
    44from django.contrib.auth.views import password_reset
    from django.shortcuts import render_to_response  
    99from django.template import Template, RequestContext
    1010from django.views.decorators.cache import never_cache
    1111
     12from django.contrib import admin
     13admin.autodiscover()
     14
    1215@never_cache
    1316def remote_user_auth_view(request):
    1417    "Dummy view for remote user tests"
    urlpatterns = urlpatterns + patterns('',  
    6063    (r'^auth_processor_perms/$', auth_processor_perms),
    6164    (r'^auth_processor_messages/$', auth_processor_messages),
    6265    url(r'^userpage/(.+)/$', userpage, name="userpage"),
     66    url(r'^admin/', include(admin.site.urls))
    6367)
    6468
  • django/contrib/auth/tests/views.py

    diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
    index 1975266..5b345bd 100644
    a b class PasswordResetTest(AuthViewsTestCase):  
    183183
    184184class ChangePasswordTest(AuthViewsTestCase):
    185185
     186    def test_form_url_present_in_context(self, password='password'):
     187        response = self.client.post('/login/', {
     188            'username': 'superuser',
     189            'password': password,
     190        })
     191
     192        response = self.client.get('/admin/auth/user/4/password/')
     193        self.assertEqual(response.status_code, 200)
     194        self.assertTrue('form_url' in response.context, msg = 'form_url not present in response context')
     195
    186196    def fail_login(self, password='password'):
    187197        response = self.client.post('/login/', {
    188198            'username': 'testclient',
Back to Top