1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-30 04:13:01 +00:00

Memberships are optional for clubs

This commit is contained in:
Yohann D'ANELLO 2020-03-31 16:22:11 +02:00
parent dd3b7bd7e5
commit e98693b214
5 changed files with 54 additions and 12 deletions

View File

@ -5,6 +5,7 @@
"fields": { "fields": {
"name": "BDE", "name": "BDE",
"email": "tresorerie.bde@example.com", "email": "tresorerie.bde@example.com",
"require_memberships": true,
"membership_fee": 500, "membership_fee": 500,
"membership_duration": "396 00:00:00", "membership_duration": "396 00:00:00",
"membership_start": "213 00:00:00", "membership_start": "213 00:00:00",
@ -17,6 +18,7 @@
"fields": { "fields": {
"name": "Kfet", "name": "Kfet",
"email": "tresorerie.bde@example.com", "email": "tresorerie.bde@example.com",
"require_memberships": true,
"membership_fee": 3500, "membership_fee": 3500,
"membership_duration": "396 00:00:00", "membership_duration": "396 00:00:00",
"membership_start": "213 00:00:00", "membership_start": "213 00:00:00",

View File

@ -77,22 +77,34 @@ class Club(models.Model):
) )
# Memberships # 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( membership_fee = models.PositiveIntegerField(
default=0,
verbose_name=_('membership fee'), verbose_name=_('membership fee'),
) )
membership_duration = models.DurationField( membership_duration = models.DurationField(
blank=True,
null=True, null=True,
verbose_name=_('membership duration'), verbose_name=_('membership duration'),
help_text=_('The longest time a membership can last ' help_text=_('The longest time a membership can last '
'(NULL = infinite).'), '(NULL = infinite).'),
) )
membership_start = models.DurationField( membership_start = models.DurationField(
blank=True,
null=True, null=True,
verbose_name=_('membership start'), verbose_name=_('membership start'),
help_text=_('How long after January 1st the members can renew ' help_text=_('How long after January 1st the members can renew '
'their membership.'), 'their membership.'),
) )
membership_end = models.DurationField( membership_end = models.DurationField(
blank=True,
null=True, null=True,
verbose_name=_('membership end'), verbose_name=_('membership end'),
help_text=_('How long the membership can last after January 1st ' help_text=_('How long the membership can last after January 1st '
@ -100,6 +112,15 @@ class Club(models.Model):
'membership.'), '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: class Meta:
verbose_name = _("club") verbose_name = _("club")
verbose_name_plural = _("clubs") verbose_name_plural = _("clubs")

View File

@ -842,7 +842,7 @@
35, 35,
36, 36,
39, 39,
40, 40
] ]
} }
}, },

View File

@ -9,3 +9,23 @@
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button> <button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
</form> </form>
{% endblock %} {% endblock %}
{% block extrajavascript %}
<script>
require_memberships_obj = $("#id_require_memberships");
if (!require_memberships_obj.is(":checked")) {
$("#div_id_membership_fee").toggle();
$("#div_id_membership_duration").toggle();
$("#div_id_membership_start").toggle();
$("#div_id_membership_end").toggle();
}
require_memberships_obj.change(function () {
$("#div_id_membership_fee").toggle();
$("#div_id_membership_duration").toggle();
$("#div_id_membership_start").toggle();
$("#div_id_membership_end").toggle();
});
</script>
{% endblock %}

View File

@ -18,6 +18,7 @@
<dd class="col-xl-6"> {{ club.parent_club.name}}</dd> <dd class="col-xl-6"> {{ club.parent_club.name}}</dd>
{% endif %} {% endif %}
{% if club.require_memberships %}
<dt class="col-xl-6">{% trans 'membership start'|capfirst %}</dt> <dt class="col-xl-6">{% trans 'membership start'|capfirst %}</dt>
<dd class="col-xl-6">{{ club.membership_start }}</dd> <dd class="col-xl-6">{{ club.membership_start }}</dd>
@ -29,15 +30,13 @@
<dt class="col-xl-6">{% trans 'membership fee'|capfirst %}</dt> <dt class="col-xl-6">{% trans 'membership fee'|capfirst %}</dt>
<dd class="col-xl-6">{{ club.membership_fee|pretty_money }}</dd> <dd class="col-xl-6">{{ club.membership_fee|pretty_money }}</dd>
{% endif %}
<dt class="col-xl-6"><a href="{% url 'member:club_alias' club.pk %}">{% trans 'aliases'|capfirst %}</a></dt> <dt class="col-xl-6"><a href="{% url 'member:club_alias' club.pk %}">{% trans 'aliases'|capfirst %}</a></dt>
<dd class="col-xl-6 text-truncate">{{ object.note.alias_set.all|join:", " }}</dd> <dd class="col-xl-6 text-truncate">{{ object.note.alias_set.all|join:", " }}</dd>
<dt class="col-xl-3">{% trans 'email'|capfirst %}</dt> <dt class="col-xl-3">{% trans 'email'|capfirst %}</dt>
<dd class="col-xl-9"><a href="mailto:{{ club.email }}">{{ club.email }}</a></dd> <dd class="col-xl-9"><a href="mailto:{{ club.email }}">{{ club.email }}</a></dd>
<dt class="col-xl-6"><a href="{% url 'member:club_linked_note_list' pk=club.pk %}">{% trans 'linked notes'|capfirst %}</a></dt>
<dd class="col-xl-6 text-truncate">{{ club.linked_notes.all|join:", " }}</dd>
</dl> </dl>
</div> </div>
<div class="card-footer text-center"> <div class="card-footer text-center">