fix: Replace available_attrs helper (dropped by Django 3.0)

This commit is contained in:
Jennifer Richards 2023-05-08 15:19:33 -03:00
parent e1b783ead9
commit 9fda268853
No known key found for this signature in database
GPG key ID: 9B2BF5C5ADDA6A6E

View file

@ -7,7 +7,7 @@
import oidc_provider.lib.claims
from functools import wraps
from functools import wraps, WRAPPER_ASSIGNMENTS
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
@ -15,7 +15,6 @@ from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.decorators import available_attrs
from django.utils.http import urlquote
import debug # pyflakes:ignore
@ -113,7 +112,7 @@ def passes_test_decorator(test_func, message):
error. The test function should be on the form fn(user) ->
true/false."""
def decorate(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
@wraps(view_func, assigned=WRAPPER_ASSIGNMENTS)
def inner(request, *args, **kwargs):
if not request.user.is_authenticated:
return HttpResponseRedirect('%s?%s=%s' % (settings.LOGIN_URL, REDIRECT_FIELD_NAME, urlquote(request.get_full_path())))