mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 12:38:26 +02:00
Display tournament list
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from django.core.management import BaseCommand
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
|
||||
from member.models import TFJMUser, Document, Solution, Synthesis, Authorization, MotivationLetter
|
||||
@ -61,6 +61,17 @@ class Command(BaseCommand):
|
||||
Tournament.objects.create(**obj_dict)
|
||||
print(self.style.SUCCESS("Tournaments imported"))
|
||||
|
||||
@staticmethod
|
||||
def validation_status(status):
|
||||
if status == "NOT_READY":
|
||||
return "0invalid"
|
||||
elif status == "WAITING":
|
||||
return "1waiting"
|
||||
elif status == "VALIDATED":
|
||||
return "2valid"
|
||||
else:
|
||||
raise CommandError("Unknown status: {}".format(status))
|
||||
|
||||
@transaction.atomic
|
||||
def import_teams(self):
|
||||
self.stdout.write("Importing teams...")
|
||||
@ -84,7 +95,7 @@ class Command(BaseCommand):
|
||||
"trigram": args[2],
|
||||
"tournament": Tournament.objects.get(pk=args[3]),
|
||||
"inscription_date": args[13],
|
||||
"validation_status": args[14].lower(),
|
||||
"validation_status": Command.validation_status(args[14]),
|
||||
"selected_for_final": args[15],
|
||||
"access_code": args[16],
|
||||
"year": args[17],
|
||||
@ -93,6 +104,19 @@ class Command(BaseCommand):
|
||||
Team.objects.create(**obj_dict)
|
||||
print(self.style.SUCCESS("Teams imported"))
|
||||
|
||||
@staticmethod
|
||||
def role(role):
|
||||
if role == "ADMIN":
|
||||
return "0admin"
|
||||
elif role == "ORGANIZER":
|
||||
return "1volunteer"
|
||||
elif role == "ENCADRANT":
|
||||
return "2coach"
|
||||
elif role == "PARTICIPANT":
|
||||
return "3participant"
|
||||
else:
|
||||
raise CommandError("Unknown role: {}".format(role))
|
||||
|
||||
@transaction.atomic
|
||||
def import_users(self):
|
||||
self.stdout.write("Importing users...")
|
||||
@ -130,7 +154,7 @@ class Command(BaseCommand):
|
||||
"responsible_phone": args[15],
|
||||
"responsible_email": args[16],
|
||||
"description": args[17].replace("\\n", "\n") if args[17] else None,
|
||||
"role": args[18].lower(),
|
||||
"role": Command.role(args[18]),
|
||||
"team": Team.objects.get(pk=args[19]) if args[19] else None,
|
||||
"year": args[20],
|
||||
"date_joined": args[23],
|
||||
|
@ -127,10 +127,10 @@ class TFJMUser(AbstractUser):
|
||||
role = models.CharField(
|
||||
max_length=16,
|
||||
choices=[
|
||||
("admin", _("admin")),
|
||||
("organizer", _("organizer")),
|
||||
("encadrant", _("encadrant")),
|
||||
("participant", _("participant")),
|
||||
("0admin", _("admin")),
|
||||
("1volunteer", _("organizer")),
|
||||
("2coach", _("coach")),
|
||||
("3participant", _("participant")),
|
||||
]
|
||||
)
|
||||
|
||||
@ -141,15 +141,15 @@ class TFJMUser(AbstractUser):
|
||||
|
||||
@property
|
||||
def participates(self):
|
||||
return self.role == "participant" or self.role == "encadrant"
|
||||
return self.role == "3participant" or self.role == "2encadrant"
|
||||
|
||||
@property
|
||||
def organizes(self):
|
||||
return self.role == "organizer" or self.role == "admin"
|
||||
return self.role == "1volunteer" or self.role == "0admin"
|
||||
|
||||
@property
|
||||
def admin(self):
|
||||
return self.role == "admin"
|
||||
return self.role == "0admin"
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("user")
|
||||
|
Reference in New Issue
Block a user