mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-11-27 00:07:11 +00:00
f26f102650
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
144 lines
5.4 KiB
Python
144 lines
5.4 KiB
Python
# Copyright (C) 2024 by Animath
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from django.core.management import BaseCommand
|
|
from django.utils.translation import activate
|
|
from participation.models import Team, Tournament
|
|
from tfjm.permissions import PermissionType
|
|
|
|
from ...models import Channel
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **kwargs):
|
|
activate('fr')
|
|
|
|
Channel.objects.update_or_create(
|
|
name="Annonces",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.GENERAL,
|
|
read_access=PermissionType.AUTHENTICATED,
|
|
write_access=PermissionType.ADMIN,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name="Aide jurys et orgas",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.GENERAL,
|
|
read_access=PermissionType.VOLUNTEER,
|
|
write_access=PermissionType.VOLUNTEER,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name="Général",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.GENERAL,
|
|
read_access=PermissionType.AUTHENTICATED,
|
|
write_access=PermissionType.AUTHENTICATED,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name="Je cherche une équipe",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.GENERAL,
|
|
read_access=PermissionType.AUTHENTICATED,
|
|
write_access=PermissionType.AUTHENTICATED,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name="Détente",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.GENERAL,
|
|
read_access=PermissionType.AUTHENTICATED,
|
|
write_access=PermissionType.AUTHENTICATED,
|
|
),
|
|
)
|
|
|
|
for tournament in Tournament.objects.all():
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Annonces",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.TOURNAMENT_MEMBER,
|
|
write_access=PermissionType.TOURNAMENT_ORGANIZER,
|
|
tournament=tournament,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Général",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.TOURNAMENT_MEMBER,
|
|
write_access=PermissionType.TOURNAMENT_MEMBER,
|
|
tournament=tournament,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Détente",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.TOURNAMENT_MEMBER,
|
|
write_access=PermissionType.TOURNAMENT_MEMBER,
|
|
tournament=tournament,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Juré⋅es",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.JURY_MEMBER,
|
|
write_access=PermissionType.JURY_MEMBER,
|
|
tournament=tournament,
|
|
),
|
|
)
|
|
|
|
if tournament.remote:
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Président⋅es de jury",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.TOURNAMENT_JURY_PRESIDENT,
|
|
write_access=PermissionType.TOURNAMENT_JURY_PRESIDENT,
|
|
tournament=tournament,
|
|
),
|
|
)
|
|
|
|
for pool in tournament.pools.all():
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Poule {pool.short_name}",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.POOL_MEMBER,
|
|
write_access=PermissionType.POOL_MEMBER,
|
|
pool=pool,
|
|
),
|
|
)
|
|
|
|
Channel.objects.update_or_create(
|
|
name=f"{tournament.name} - Poule {pool.short_name} - Jury",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TOURNAMENT,
|
|
read_access=PermissionType.JURY_MEMBER,
|
|
write_access=PermissionType.JURY_MEMBER,
|
|
pool=pool,
|
|
),
|
|
)
|
|
|
|
for team in Team.objects.filter(participation__valid=True).all():
|
|
Channel.objects.update_or_create(
|
|
name=f"Équipe {team.trigram}",
|
|
defaults=dict(
|
|
category=Channel.ChannelCategory.TEAM,
|
|
read_access=PermissionType.TEAM_MEMBER,
|
|
write_access=PermissionType.TEAM_MEMBER,
|
|
team=team,
|
|
),
|
|
)
|