mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-04 01:32:11 +02:00
Drop AdminRegistration in favour of a new boolean field, closes #19
This commit is contained in:
@ -22,7 +22,7 @@ class Registration(PolymorphicModel):
|
||||
"""
|
||||
Registrations store extra content that are not asked in the User Model.
|
||||
This is specific to the role of the user, see StudentRegistration,
|
||||
ClassRegistration or AdminRegistration..
|
||||
CoachRegistration or VolunteerRegistration.
|
||||
"""
|
||||
user = models.OneToOneField(
|
||||
"auth.User",
|
||||
@ -79,7 +79,7 @@ class Registration(PolymorphicModel):
|
||||
|
||||
@property
|
||||
def is_admin(self):
|
||||
return isinstance(self, AdminRegistration) or self.user.is_superuser
|
||||
return isinstance(self, VolunteerRegistration) and self.admin or self.user.is_superuser
|
||||
|
||||
@property
|
||||
def is_volunteer(self):
|
||||
@ -287,13 +287,19 @@ class VolunteerRegistration(Registration):
|
||||
verbose_name=_("professional activity"),
|
||||
)
|
||||
|
||||
admin = models.BooleanField(
|
||||
verbose_name=_("administrator"),
|
||||
help_text=_("An administrator has all rights. Please don't give this right to all juries and volunteers."),
|
||||
default=False,
|
||||
)
|
||||
|
||||
@property
|
||||
def interesting_tournaments(self) -> set:
|
||||
return set(self.organized_tournaments.all()).union(map(lambda pool: pool.tournament, self.jury_in.all()))
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return _('volunteer')
|
||||
return _('admin') if self.is_admin else _('volunteer')
|
||||
|
||||
@property
|
||||
def form_class(self):
|
||||
@ -301,29 +307,6 @@ class VolunteerRegistration(Registration):
|
||||
return VolunteerRegistrationForm
|
||||
|
||||
|
||||
class AdminRegistration(VolunteerRegistration):
|
||||
"""
|
||||
Specific registration for admins.
|
||||
They have a field to justify they status.
|
||||
"""
|
||||
role = models.TextField(
|
||||
verbose_name=_("role of the administrator"),
|
||||
)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return _("admin")
|
||||
|
||||
@property
|
||||
def form_class(self):
|
||||
from registration.forms import AdminRegistrationForm
|
||||
return AdminRegistrationForm
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("admin registration")
|
||||
verbose_name_plural = _("admin registrations")
|
||||
|
||||
|
||||
def get_scholarship_filename(instance, filename):
|
||||
return f"authorization/scholarship/scholarship_{instance.registration.pk}"
|
||||
|
||||
|
Reference in New Issue
Block a user