Ticket #18923: 18923.diff

File 18923.diff, 2.0 KB (added by Tim Graham, 11 years ago)
  • django/contrib/auth/admin.py

    diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
    index e7cf8a3..ff08f41 100644
    a b from django.views.decorators.csrf import csrf_protect  
    1717from django.views.decorators.debug import sensitive_post_parameters
    1818
    1919csrf_protect_m = method_decorator(csrf_protect)
     20sensitive_post_parameters_m = method_decorator(sensitive_post_parameters())
    2021
    2122
    2223class GroupAdmin(admin.ModelAdmin):
    class UserAdmin(admin.ModelAdmin):  
    8788            return False
    8889        return super(UserAdmin, self).lookup_allowed(lookup, value)
    8990
    90     @sensitive_post_parameters()
     91    @sensitive_post_parameters_m
    9192    @csrf_protect_m
    9293    @transaction.atomic
    9394    def add_view(self, request, form_url='', extra_context=None):
    class UserAdmin(admin.ModelAdmin):  
    118119        return super(UserAdmin, self).add_view(request, form_url,
    119120                                               extra_context)
    120121
    121     @sensitive_post_parameters()
     122    @sensitive_post_parameters_m
    122123    def user_change_password(self, request, id, form_url=''):
    123124        if not self.has_change_permission(request):
    124125            raise PermissionDenied
  • django/views/decorators/debug.py

    diff --git a/django/views/decorators/debug.py b/django/views/decorators/debug.py
    index 78ae6b1..a611981 100644
    a b  
    11import functools
    22
     3from django.http import HttpRequest
     4
    35
    46def sensitive_variables(*variables):
    57    """
    def sensitive_post_parameters(*parameters):  
    6264    def decorator(view):
    6365        @functools.wraps(view)
    6466        def sensitive_post_parameters_wrapper(request, *args, **kwargs):
     67            assert isinstance(request, HttpRequest), (
     68              "sensitive_post_parameters didn't receive an HttpRequest. If you "
     69              "are decorating a classmethod, be sure to use @method_decorator."
     70            )
    6571            if parameters:
    6672                request.sensitive_post_parameters = parameters
    6773            else:
Back to Top