From 9164ea8a0542e5afb53a8dfcb8d6106934269a1f Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 8 Feb 2021 14:40:37 +0000 Subject: [PATCH] feat: use django-hijack to switch user accounts Resolves #74 --- breccia_mapper/settings.py | 11 ++++++++++- breccia_mapper/templates/base.html | 7 +++++++ breccia_mapper/urls.py | 3 +++ people/templates/people/person/detail_full.html | 7 +++++++ requirements.txt | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/breccia_mapper/settings.py b/breccia_mapper/settings.py index 75b92c4..9e55f4f 100644 --- a/breccia_mapper/settings.py +++ b/breccia_mapper/settings.py @@ -158,6 +158,8 @@ THIRD_PARTY_APPS = [ 'rest_framework', 'post_office', 'bootstrap_datepicker_plus', + 'hijack', + 'compat', ] FIRST_PARTY_APPS = [ @@ -265,7 +267,7 @@ AUTH_USER_MODEL = 'people.User' LOGIN_URL = reverse_lazy('login') -LOGIN_REDIRECT_URL = reverse_lazy('index') +LOGIN_REDIRECT_URL = reverse_lazy('people:person.profile') # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ @@ -353,6 +355,13 @@ CONSTANCE_CONFIG_FIELDSETS = { CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' + +# Django Hijack settings +# See https://django-hijack.readthedocs.io/en/stable/ + +HIJACK_USE_BOOTSTRAP = True + + # Bootstrap settings # See https://django-bootstrap4.readthedocs.io/en/latest/settings.html diff --git a/breccia_mapper/templates/base.html b/breccia_mapper/templates/base.html index ed255c7..182f665 100644 --- a/breccia_mapper/templates/base.html +++ b/breccia_mapper/templates/base.html @@ -27,6 +27,10 @@ {% load staticfiles %} + + {% if 'javascript_in_head'|bootstrap_setting %} {% if 'include_jquery'|bootstrap_setting %} {# jQuery JavaScript if it is in head #} @@ -144,6 +148,9 @@ {% endif %} + {% load hijack_tags %} + {% hijack_notification %} + {% if request.user.is_authenticated and not request.user.has_person %}