From cbb73bc82f620ff756bd205d2a3602f2d7145322 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Wed, 11 Sep 2024 09:00:22 +0000 Subject: [PATCH] accounts_accept_terms: Check if imported user wants marketing emails. --- templates/zerver/accounts_accept_terms.html | 10 ++++++++++ zerver/forms.py | 1 + zerver/views/home.py | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/templates/zerver/accounts_accept_terms.html b/templates/zerver/accounts_accept_terms.html index 5849b00d27..a53bb1517c 100644 --- a/templates/zerver/accounts_accept_terms.html +++ b/templates/zerver/accounts_accept_terms.html @@ -59,6 +59,16 @@ the registration flow has its own (nearly identical) copy of the fields below in {% endfor %} {% endif %} + {% if first_time_terms_of_service_message_template %} +
+ +
+ {% endif %} {% endif %}
diff --git a/zerver/forms.py b/zerver/forms.py index 9bf19c001f..0ff3c95499 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -234,6 +234,7 @@ class RegistrationForm(RealmDetailsForm): class ToSForm(forms.Form): terms = forms.BooleanField(required=False) + enable_marketing_emails = forms.BooleanField(required=False) email_address_visibility = forms.TypedChoiceField( required=False, coerce=int, diff --git a/zerver/views/home.py b/zerver/views/home.py index 1fa4751ccd..ffafb969f0 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -57,6 +57,18 @@ def accounts_accept_terms(request: HttpRequest) -> HttpResponse: email_address_visibility, acting_user=request.user, ) + + enable_marketing_emails = form.cleaned_data["enable_marketing_emails"] + if ( + enable_marketing_emails is not None + and enable_marketing_emails != request.user.enable_marketing_emails + ): + do_change_user_setting( + request.user, + "enable_marketing_emails", + enable_marketing_emails, + acting_user=request.user, + ) return redirect(home) else: form = ToSForm()