Newer
Older
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import gettext_lazy as _
"""
"""
year = models.PositiveIntegerField(
unique=True,
verbose_name=_("year"),
)
def update_membership_dates(self):
"""
We can't join the WEI next years.
"""
return
class Bus(models.Model):
"""
The best bus for the best WEI
"""
wei = models.ForeignKey(
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
on_delete=models.PROTECT,
related_name="buses",
verbose_name=_("WEI"),
)
name = models.CharField(
max_length=255,
verbose_name=_("name"),
)
def __str__(self):
return self.name
class Meta:
unique_together = ('wei', 'name',)
class BusTeam(models.Model):
"""
A bus has multiple teams
"""
bus = models.ForeignKey(
Bus,
on_delete=models.CASCADE,
related_name="teams",
verbose_name=_("bus"),
)
name = models.CharField(
max_length=255,
)
color = models.PositiveIntegerField( # Use a color picker to get the hexa code
verbose_name=_("color"),
help_text=_("The color of the T-Shirt, stored with its number equivalent"),
)
def __str__(self):
return self.name + " (" + str(self.bus) + ")"
class Meta:
unique_together = ('bus', 'name',)
verbose_name = _("Bus team")
verbose_name_plural = _("Bus teams")
"""
A Role for the WEI can be bus chief, team chief, free electron, ...
"""
bus = models.ForeignKey(
Bus,
on_delete=models.CASCADE,
related_name="roles",
verbose_name=_("bus"),
"""
Store personal data that can be useful for the WEI.
"""
user = models.ForeignKey(
User,
on_delete=models.PROTECT,
related_name="wei",
verbose_name=_("user"),
)
wei = models.ForeignKey(
on_delete=models.PROTECT,
related_name="users",
verbose_name=_("WEI"),
)
null=True, # null = no credit, paid with note
related_name="+",
verbose_name=_("payment method"),
)
soge_credit = models.BooleanField(
verbose_name=_("Credit from Société générale"),
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
)
birth_date = models.DateField(
verbose_name=_("birth date"),
)
gender = models.CharField(
max_length=16,
choices=(
('male', _("Male")),
('female', _("Female")),
('nonbinary', _("Non binary")),
),
verbose_name=_("gender"),
)
health_issues = models.TextField(
verbose_name=_("health issues"),
)
emergency_contact_name = models.CharField(
max_length=255,
verbose_name=_("emergency contact name"),
)
emergency_contact_phone = models.CharField(
max_length=32,
verbose_name=_("emergency contact phone"),
)
verbose_name=_("Register on the mailing list to stay informed of the events of the campus (1 mail/week)"),
)
verbose_name=_("Register on the mailing list to stay informed of the sport events of the campus (1 mail/week)"),
)
verbose_name=_("Register on the mailing list to stay informed of the art events of the campus (1 mail/week)"),
)
information_json = models.TextField(
verbose_name=_("registration information"),
help_text=_("Information about the registration (buses for old members, survey fot the new members), "
"encoded in JSON"),
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
@property
def information(self):
"""
The information about the registration (the survey for the new members, the bus for the older members, ...)
are stored in a dictionary that can evolve following the years. The dictionary is stored as a JSON string.
"""
return json.loads(self.information_json)
@information.setter
def information(self, information):
"""
Store information as a JSON string
"""
self.information_json = json.dumps(information)
@property
def is_1A(self):
"""
We assume that a user is a new member if it not fully registered yet.
"""
return not self.user.profile.registration_valid
def __str__(self):
return str(self.user)
class Meta:
unique_together = ('user', 'wei',)
verbose_name = _("WEI User")
verbose_name_plural = _("WEI Users")
class WEIMembership(Membership):
bus = models.ForeignKey(
on_delete=models.PROTECT,
null=True,
blank=True,
default=None,
related_name="membership",
verbose_name=_("WEI registration"),