diff --git a/apps/member/fixtures/initial.json b/apps/member/fixtures/initial.json index bba1e7ac..649cbbc1 100644 --- a/apps/member/fixtures/initial.json +++ b/apps/member/fixtures/initial.json @@ -5,6 +5,7 @@ "fields": { "name": "BDE", "email": "tresorerie.bde@example.com", + "require_memberships": true, "membership_fee": 500, "membership_duration": "396 00:00:00", "membership_start": "213 00:00:00", @@ -17,6 +18,7 @@ "fields": { "name": "Kfet", "email": "tresorerie.bde@example.com", + "require_memberships": true, "membership_fee": 3500, "membership_duration": "396 00:00:00", "membership_start": "213 00:00:00", diff --git a/apps/member/models.py b/apps/member/models.py index d0051e59..377cc010 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -77,22 +77,34 @@ class Club(models.Model): ) # Memberships + + # When set to False, the membership system won't be used. + # Useful to create notes for activities or departments. + require_memberships = models.BooleanField( + default=True, + verbose_name=_("require memberships"), + ) + membership_fee = models.PositiveIntegerField( + default=0, verbose_name=_('membership fee'), ) membership_duration = models.DurationField( + blank=True, null=True, verbose_name=_('membership duration'), help_text=_('The longest time a membership can last ' '(NULL = infinite).'), ) membership_start = models.DurationField( + blank=True, null=True, verbose_name=_('membership start'), help_text=_('How long after January 1st the members can renew ' 'their membership.'), ) membership_end = models.DurationField( + blank=True, null=True, verbose_name=_('membership end'), help_text=_('How long the membership can last after January 1st ' @@ -100,6 +112,15 @@ class Club(models.Model): 'membership.'), ) + def save(self, force_insert=False, force_update=False, using=None, + update_fields=None): + if not self.require_memberships: + self.membership_fee = 0 + self.membership_duration = None + self.membership_start = None + self.membership_end = None + super().save(force_insert, force_update, update_fields) + class Meta: verbose_name = _("club") verbose_name_plural = _("clubs") diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 04920cfb..5bf0d77d 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -842,7 +842,7 @@ 35, 36, 39, - 40, + 40 ] } }, diff --git a/templates/member/club_form.html b/templates/member/club_form.html index 99c254e3..7abe9db9 100644 --- a/templates/member/club_form.html +++ b/templates/member/club_form.html @@ -9,3 +9,23 @@ {% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/templates/member/club_info.html b/templates/member/club_info.html index 907914be..039583c5 100644 --- a/templates/member/club_info.html +++ b/templates/member/club_info.html @@ -18,26 +18,25 @@