Skip to content

Commit

Permalink
Django 4 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
winslowdibona committed Apr 16, 2024
1 parent c6551fb commit d5deef2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions impersonate/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.shortcuts import redirect
from django.utils.http import urlquote
from urllib.parse import quote

from .helpers import check_allow_impersonate, get_redir_path

Expand All @@ -24,7 +24,7 @@ def _checkuser(request, *args, **kwargs):
return redirect(u'{0}?{1}={2}'.format(
get_login_url(),
REDIRECT_FIELD_NAME,
urlquote(request.get_full_path()),
quote(request.get_full_path()),
))

if check_allow_impersonate(request):
Expand Down
8 changes: 2 additions & 6 deletions impersonate/signals.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from django.dispatch import Signal

# signal sent when an impersonation session begins
session_begin = Signal(
providing_args=['impersonator', 'impersonating', 'request']
)
session_begin = Signal()

# signal sent when an impersonation session ends
session_end = Signal(
providing_args=['impersonator', 'impersonating', 'request']
)
session_end = Signal()
18 changes: 5 additions & 13 deletions impersonate/urls.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
from django.conf.urls import url
from django.urls import re_path

from .views import impersonate, list_users, search_users, stop_impersonate

try:
# Django <=1.9
from django.conf.urls import patterns
except ImportError:
patterns = None

urlpatterns = [
url(r'^stop/$',
re_path(r'^stop/$',
stop_impersonate,
name='impersonate-stop'),
url(r'^list/$',
re_path(r'^list/$',
list_users,
{'template': 'impersonate/list_users.html'},
name='impersonate-list'),
url(r'^search/$',
re_path(r'^search/$',
search_users,
{'template': 'impersonate/search_users.html'},
name='impersonate-search'),
url(r'^(?P<uid>.+)/$',
re_path(r'^(?P<uid>.+)/$',
impersonate,
name='impersonate-start'),
]

if patterns is not None:
urlpatterns = patterns('', *urlpatterns)

0 comments on commit d5deef2

Please sign in to comment.