Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit ace77db

Browse files
fix: Remove tos input defaults and separate out more new vs deprecated
1 parent 7bc85a9 commit ace77db

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

codecov_auth/commands/owner/interactors/save_terms_agreement.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,25 @@ def validate(self, input: TermsAgreementInput) -> None:
3939
if not self.current_user.is_authenticated:
4040
raise Unauthenticated()
4141

42-
def update_terms_agreement(self, input: TermsAgreementInput) -> None:
42+
def update_terms_agreement_deprecated(self, input: TermsAgreementInput) -> None:
4343
self.current_user.terms_agreement = input.terms_agreement
4444
self.current_user.terms_agreement_at = timezone.now()
45+
self.current_user.customer_intent = input.customer_intent
4546
self.current_user.email_opt_in = input.marketing_consent
47+
self.current_user.save()
48+
49+
if input.business_email and input.business_email != "":
50+
self.current_user.email = input.business_email
51+
self.current_user.save()
52+
53+
if input.marketing_consent:
54+
self.send_data_to_marketo()
55+
56+
def update_terms_agreement(self, input: TermsAgreementInput) -> None:
57+
self.current_user.terms_agreement = input.terms_agreement
58+
self.current_user.terms_agreement_at = timezone.now()
4659
self.current_user.name = input.name
60+
self.current_user.email_opt_in = input.marketing_consent
4761
self.current_user.save()
4862

4963
if input.business_email and input.business_email != "":
@@ -61,15 +75,22 @@ def send_data_to_marketo(self) -> None:
6175

6276
@sync_to_async
6377
def execute(self, input: Any) -> None:
64-
typed_input = TermsAgreementInput(
65-
business_email=input.get("business_email", ""),
66-
terms_agreement=input.get("terms_agreement", False),
67-
marketing_consent=input.get("marketing_consent", False),
68-
customer_intent=input.get("customer_intent"),
69-
name=input.get("name", ""),
70-
)
71-
if input.get("customer_intent"):
72-
self.validate_deprecated(typed_input)
73-
else:
78+
if input.get("name"):
79+
typed_input = TermsAgreementInput(
80+
business_email=input.get("business_email"),
81+
terms_agreement=input.get("terms_agreement"),
82+
marketing_consent=input.get("marketing_consent"),
83+
name=input.get("name", ""),
84+
)
7485
self.validate(typed_input)
75-
return self.update_terms_agreement(typed_input)
86+
self.update_terms_agreement(typed_input)
87+
# this handles the deprecated inputs
88+
else:
89+
typed_input = TermsAgreementInput(
90+
business_email=input.get("business_email"),
91+
terms_agreement=input.get("terms_agreement"),
92+
marketing_consent=input.get("marketing_consent"),
93+
customer_intent=input.get("customer_intent"),
94+
)
95+
self.validate_deprecated(typed_input)
96+
self.update_terms_agreement_deprecated(typed_input)

0 commit comments

Comments
 (0)