mirror of
https://github.com/ae-utbm/sith.git
synced 2025-03-25 22:57:12 +00:00
skip useless checks when creating a subscription for a new member
This commit is contained in:
parent
7f2ee24cb9
commit
8a38ebb09d
@ -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"),
|
||||
|
@ -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 :
|
||||
|
Loading…
x
Reference in New Issue
Block a user