From 125cfdfcad8f1d37fd5581a148220f1c29294d78 Mon Sep 17 00:00:00 2001 From: Kevin Etchells Date: Wed, 18 Sep 2024 11:57:38 +0100 Subject: [PATCH] Hide profile overlay for now --- .../redbox_core/views/auth_views.py | 2 +- .../redbox_core/views/demographics_views.py | 11 ++++++++ django_app/redbox_app/templates/chats.html | 28 ++++++++++--------- .../redbox_app/templates/demographics.html | 2 ++ tests/test_journey.py | 5 ++-- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/django_app/redbox_app/redbox_core/views/auth_views.py b/django_app/redbox_app/redbox_core/views/auth_views.py index 196b0926d..9b7e93d11 100644 --- a/django_app/redbox_app/redbox_core/views/auth_views.py +++ b/django_app/redbox_app/redbox_core/views/auth_views.py @@ -25,7 +25,7 @@ def sign_in_view(request: HttpRequest): try: user = models.User.objects.get(email=email) - link = MagicLink.objects.create(user=user, redirect_to="/chats") + link = MagicLink.objects.create(user=user, redirect_to="/check-demographics") # Switch this to "/chats" once profile overlay is added to Chats page full_link = request.build_absolute_uri(link.get_absolute_url()) body = render_to_string("email/verification.txt", {"url": full_link}) send_mail( diff --git a/django_app/redbox_app/redbox_core/views/demographics_views.py b/django_app/redbox_app/redbox_core/views/demographics_views.py index 8eb395d64..7a3f3c6db 100644 --- a/django_app/redbox_app/redbox_core/views/demographics_views.py +++ b/django_app/redbox_app/redbox_core/views/demographics_views.py @@ -14,6 +14,17 @@ logger = logging.getLogger(__name__) +# This can be removed once profile overlay added to /chats +class CheckDemographicsView(View): + @method_decorator(login_required) + def get(self, request: HttpRequest) -> HttpResponse: + user: User = request.user + if all([user.name, user.ai_experience, user.grade, user.business_unit, user.profession]): + return redirect("chats") + else: + return redirect("demographics") + + class DemographicsView(LoginRequiredMixin, UpdateView): model = User template_name = "demographics.html" diff --git a/django_app/redbox_app/templates/chats.html b/django_app/redbox_app/templates/chats.html index 4a6efc914..88fcc2180 100644 --- a/django_app/redbox_app/templates/chats.html +++ b/django_app/redbox_app/templates/chats.html @@ -6,9 +6,11 @@ {% block content %} +{# To be added back in once profile overlay is required {% if not request.user.name %} {{ profile_overlay(csrf_token, request.user, True) }} {% endif %} +#}
@@ -28,21 +30,21 @@

Chats

New chat -
-

Recent chats

-
- {% for date_group, chats in chat_grouped_by_date_group %} -

{{ date_group }}

-
    - {% for chat in chats %} -
  • - {{ chat.name }} -
  • +
    +

    Recent chats

    +
    + {% for date_group, chats in chat_grouped_by_date_group %} +

    {{ date_group }}

    + {% endfor %} -
- {% endfor %} +
-
diff --git a/django_app/redbox_app/templates/demographics.html b/django_app/redbox_app/templates/demographics.html index f9703e8f7..eaceef7af 100644 --- a/django_app/redbox_app/templates/demographics.html +++ b/django_app/redbox_app/templates/demographics.html @@ -48,6 +48,7 @@

My details

+ {# To be added in when profile overlay ready to go live
{{ form.redbox_response_preferences }}
+ #}
{{ govukButton(text="Update") }} diff --git a/tests/test_journey.py b/tests/test_journey.py index 0b59ba820..f9bd24dfc 100644 --- a/tests/test_journey.py +++ b/tests/test_journey.py @@ -52,8 +52,9 @@ def test_user_journey(page: Page, email_address: str): my_details_page = chats_page.navigate_my_details() my_details_page.name = "Roland Hamilton-Jones" my_details_page.ai_experience = "Enthusiastic Experimenter" - my_details_page.info_about_user = "Information about user" - my_details_page.redbox_response_preferences = "Respond concisely" + # Add these in once profile overlay is added + #my_details_page.info_about_user = "Information about user" + #my_details_page.redbox_response_preferences = "Respond concisely" chats_page = my_details_page.update() # Documents page