mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 20:09:25 +00:00
clubs: move Membership form validation outside of model and fix and add tests
This commit is contained in:
@ -276,18 +276,6 @@ class Membership(models.Model):
|
||||
_("description"), max_length=128, null=False, blank=True
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
sub = User.objects.filter(pk=self.user.pk).first()
|
||||
if sub is None or not sub.is_subscribed:
|
||||
raise ValidationError(_("User must be subscriber to take part to a club"))
|
||||
if (
|
||||
Membership.objects.filter(user=self.user)
|
||||
.filter(club=self.club)
|
||||
.filter(end_date=None)
|
||||
.exists()
|
||||
):
|
||||
raise ValidationError(_("User is already member of that club"))
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
self.club.name
|
||||
|
Reference in New Issue
Block a user