Skip to content

Commit 1d98d27

Browse files
fix: marketing consent should default to True (#5416)
1 parent d5b5e97 commit 1d98d27

5 files changed

Lines changed: 56 additions & 3 deletions

File tree

api/custom_auth/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Meta(UserCreateSerializer.Meta): # type: ignore[misc]
6464
"marketing_consent_given",
6565
"uuid",
6666
)
67-
read_only_fields = ("is_active", "uuid")
67+
read_only_fields = ("is_active", "uuid", "marketing_consent_given")
6868
write_only_fields = ("sign_up_type",)
6969
extra_kwargs = {
7070
"email": {

api/tests/integration/custom_auth/end_to_end/test_custom_auth_integration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections import ChainMap
44

55
import pyotp
6+
import pytest
67
from django.conf import settings
78
from django.core import mail
89
from django.urls import reverse
@@ -701,3 +702,31 @@ def test_cannot_create_superuser_if_any_user_exists(
701702
"A superuser can only be created through this endpoint if no other users exist."
702703
]
703704
assert FFAdminUser.objects.filter(email=email).exists() is False
705+
706+
707+
@pytest.mark.parametrize("marketing_consent_given", [None, True, False])
708+
def test_marketing_consent_given_defaults_to_true(
709+
api_client: APIClient,
710+
marketing_consent_given: bool | None,
711+
db: None,
712+
) -> None:
713+
# Given
714+
password = FFAdminUser.objects.make_random_password()
715+
register_data = {
716+
"email": "test@example.com",
717+
"password": password,
718+
"re_password": password,
719+
"first_name": "user",
720+
"last_name": "test",
721+
"marketing_consent_given": marketing_consent_given,
722+
}
723+
url = reverse("api-v1:custom_auth:ffadminuser-list")
724+
725+
# When
726+
response = api_client.post(
727+
url, data=json.dumps(register_data), content_type="application/json"
728+
)
729+
730+
# Then
731+
assert response.status_code == status.HTTP_201_CREATED
732+
assert response.json()["marketing_consent_given"] is True

api/tests/unit/integrations/lead_tracking/pipedrive/test_unit_pipedrive_lead_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_create_lead_creates_person_if_none_found(db, mocker, settings): # type
235235
)
236236
mock_pipedrive_client.create_organization.assert_not_called()
237237
mock_pipedrive_client.create_person.assert_called_once_with(
238-
user.full_name, user.email, MarketingStatus.NO_CONSENT
238+
user.full_name, user.email, MarketingStatus.SUBSCRIBED
239239
)
240240

241241

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.18 on 2025-05-02 15:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("users", "0039_alter_ffadminuser_first_name"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="ffadminuser",
15+
name="marketing_consent_given",
16+
field=models.BooleanField(
17+
default=True,
18+
help_text="Determines whether the user has agreed to receive marketing mails",
19+
),
20+
),
21+
]

api/users/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ class FFAdminUser(LifecycleModel, AbstractUser): # type: ignore[django-manager-
111111
last_name = models.CharField("last name", max_length=150)
112112
google_user_id = models.CharField(max_length=50, null=True, blank=True)
113113
github_user_id = models.CharField(max_length=50, null=True, blank=True)
114+
115+
# Default to True, since it is covered in our Terms of Service.
114116
marketing_consent_given = models.BooleanField(
115-
default=False,
117+
default=True,
116118
help_text="Determines whether the user has agreed to receive marketing mails",
117119
)
120+
118121
sign_up_type = models.CharField(
119122
choices=SignUpType.choices, max_length=100, blank=True, null=True
120123
)

0 commit comments

Comments
 (0)