diff --git a/subscription/forms.py b/subscription/forms.py index ed9978d4..babc613c 100644 --- a/subscription/forms.py +++ b/subscription/forms.py @@ -94,6 +94,13 @@ class SubscriptionNewUserForm(SubscriptionForm): return email def clean(self) -> dict[str, Any]: + """Initialize the [User][core.models.User] linked to this subscription. + + Warning: + The `User` is initialized, but not saved. + Don't use it for operations that expect + a persisted object. + """ member = User( first_name=self.cleaned_data.get("first_name"), last_name=self.cleaned_data.get("last_name"), diff --git a/subscription/models.py b/subscription/models.py index 4d68d979..38d6c0f5 100644 --- a/subscription/models.py +++ b/subscription/models.py @@ -92,9 +92,13 @@ class Subscription(models.Model): self.member.make_home() def get_absolute_url(self): - return reverse("core:user_edit", kwargs={"user_id": self.member.pk}) + return reverse("core:user_edit", kwargs={"user_id": self.member_id}) def clean(self): + if self.member._state.adding: + # if the user is being created, then it makes no sense + # to check if the user is already subscribed + return today = localdate() threshold = timedelta(weeks=settings.SITH_SUBSCRIPTION_END) # a user may subscribe if :