diff --git a/apps/logs/signals.py b/apps/logs/signals.py index 2520698..e493301 100644 --- a/apps/logs/signals.py +++ b/apps/logs/signals.py @@ -1,10 +1,10 @@ import getpass -from tfjm.middlewares import get_current_authenticated_user, get_current_ip from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from rest_framework.renderers import JSONRenderer from rest_framework.serializers import ModelSerializer +from tfjm.middlewares import get_current_authenticated_user, get_current_ip from .models import Changelog diff --git a/apps/participation/apps.py b/apps/participation/apps.py index bb84d56..2ec3fd0 100644 --- a/apps/participation/apps.py +++ b/apps/participation/apps.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.apps import AppConfig -from django.db.models.signals import post_save, pre_delete, pre_save +from django.db.models.signals import post_save, pre_save class ParticipationConfig(AppConfig): diff --git a/apps/participation/management/commands/fix_matrix_channels.py b/apps/participation/management/commands/fix_matrix_channels.py index 2dece36..7fbd742 100644 --- a/apps/participation/management/commands/fix_matrix_channels.py +++ b/apps/participation/management/commands/fix_matrix_channels.py @@ -4,9 +4,9 @@ import os from asgiref.sync import async_to_sync -from tfjm.matrix import Matrix, RoomPreset, RoomVisibility from django.core.management import BaseCommand from registration.models import AdminRegistration, Registration +from tfjm.matrix import Matrix, RoomPreset, RoomVisibility class Command(BaseCommand): diff --git a/apps/participation/management/commands/fix_sympa_lists.py b/apps/participation/management/commands/fix_sympa_lists.py index 3892e0d..bbe1af9 100644 --- a/apps/participation/management/commands/fix_sympa_lists.py +++ b/apps/participation/management/commands/fix_sympa_lists.py @@ -1,11 +1,11 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later -from tfjm.lists import get_sympa_client from django.core.management import BaseCommand from django.db.models import Q from participation.models import Team from registration.models import CoachRegistration, StudentRegistration +from tfjm.lists import get_sympa_client class Command(BaseCommand): diff --git a/apps/participation/models.py b/apps/participation/models.py index f2b7123..380936d 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -2,21 +2,17 @@ # SPDX-License-Identifier: GPL-3.0-or-later import os -import re -from registration.models import VolunteerRegistration -from tfjm.lists import get_sympa_client -from tfjm.matrix import Matrix, RoomPreset, RoomVisibility -from django.core.exceptions import ObjectDoesNotExist from django.core.validators import RegexValidator from django.db import models from django.db.models import Index -from django.template.loader import render_to_string from django.urls import reverse_lazy from django.utils import timezone from django.utils.crypto import get_random_string -from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ +from registration.models import VolunteerRegistration +from tfjm.lists import get_sympa_client +from tfjm.matrix import Matrix, RoomPreset, RoomVisibility class Team(models.Model): @@ -197,6 +193,9 @@ class Tournament(models.Model): return Synthesis.objects.filter(final_solution=True) return Synthesis.objects.filter(participation__tournament=self) + def __str__(self): + return repr(self) + class Meta: verbose_name = _("tournament") verbose_name_plural = _("tournaments") @@ -271,12 +270,14 @@ class Pool(models.Model): def solutions(self): return Solution.objects.filter(participation__in=self.participations, final_solution=self.tournament.final) + def __str__(self): + return repr(self) + class Meta: verbose_name = _("pool") verbose_name_plural = _("pools") - class Solution(models.Model): participation = models.ForeignKey( Participation, @@ -302,6 +303,9 @@ class Solution(models.Model): default="", ) + def __str__(self): + return repr(self) + class Meta: verbose_name = _("solution") verbose_name_plural = _("solutions") @@ -337,6 +341,9 @@ class Synthesis(models.Model): default="", ) + def __str__(self): + return repr(self) + class Meta: verbose_name = _("synthesis") verbose_name_plural = _("syntheses") diff --git a/apps/participation/signals.py b/apps/participation/signals.py index 14f3830..1b7f68a 100644 --- a/apps/participation/signals.py +++ b/apps/participation/signals.py @@ -1,8 +1,8 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later -from tfjm.lists import get_sympa_client from participation.models import Participation, Team +from tfjm.lists import get_sympa_client def create_team_participation(instance, created, **_): @@ -33,4 +33,3 @@ def update_mailing_list(instance: Team, **_): for coach in instance.coachs.all(): get_sympa_client().subscribe(coach.user.email, f"equipe-{instance.trigram.lower()}", False, f"{coach.user.first_name} {coach.user.last_name}") - diff --git a/apps/participation/tables.py b/apps/participation/tables.py index d38cd90..075b317 100644 --- a/apps/participation/tables.py +++ b/apps/participation/tables.py @@ -54,20 +54,3 @@ class ParticipationTable(tables.Table): model = Team fields = ('name', 'trigram', 'problem',) template_name = 'django_tables2/bootstrap4.html' - - -class VideoTable(tables.Table): - participation_name = tables.LinkColumn( - 'participation:participation_detail', - args=[tables.A("participation__pk")], - verbose_name=lambda: _("name").capitalize(), - accessor=tables.A("participation__team__name"), - ) - - class Meta: - attrs = { - 'class': 'table table condensed table-striped', - } - model = Team - fields = ('participation_name', 'link',) - template_name = 'django_tables2/bootstrap4.html' diff --git a/apps/participation/views.py b/apps/participation/views.py index efd923c..9599615 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -4,9 +4,6 @@ from io import BytesIO from zipfile import ZipFile -from tfjm.lists import get_sympa_client -from tfjm.matrix import Matrix -from tfjm.views import AdminMixin from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.sites.models import Site from django.core.exceptions import PermissionDenied @@ -22,6 +19,9 @@ from django.views.generic.edit import FormMixin, ProcessFormView from django_tables2 import SingleTableView from magic import Magic from registration.models import AdminRegistration +from tfjm.lists import get_sympa_client +from tfjm.matrix import Matrix +from tfjm.views import AdminMixin from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, TeamForm, ValidateParticipationForm from .models import Participation, Team diff --git a/apps/registration/models.py b/apps/registration/models.py index 00ded2f..f096450 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -1,7 +1,6 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later -from tfjm.tokens import email_validation_token from django.contrib.sites.models import Site from django.db import models from django.template import loader @@ -11,6 +10,7 @@ from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode from django.utils.translation import gettext_lazy as _ from polymorphic.models import PolymorphicModel +from tfjm.tokens import email_validation_token class Registration(PolymorphicModel): diff --git a/apps/registration/signals.py b/apps/registration/signals.py index f8a3a82..a0b6a21 100644 --- a/apps/registration/signals.py +++ b/apps/registration/signals.py @@ -1,9 +1,9 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +from django.contrib.auth.models import User from tfjm.lists import get_sympa_client from tfjm.matrix import Matrix -from django.contrib.auth.models import User from .models import AdminRegistration, Registration diff --git a/apps/registration/templatetags/search_results_tables.py b/apps/registration/templatetags/search_results_tables.py index 795bd75..318e7d0 100644 --- a/apps/registration/templatetags/search_results_tables.py +++ b/apps/registration/templatetags/search_results_tables.py @@ -4,7 +4,7 @@ from django import template from django_tables2 import Table from participation.models import Participation, Team -from participation.tables import ParticipationTable, TeamTable, VideoTable +from participation.tables import ParticipationTable, TeamTable from ..models import Registration from ..tables import RegistrationTable diff --git a/apps/registration/tests.py b/apps/registration/tests.py index b4384e3..9317ed2 100644 --- a/apps/registration/tests.py +++ b/apps/registration/tests.py @@ -3,7 +3,6 @@ import os -from tfjm.tokens import email_validation_token from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site @@ -14,6 +13,7 @@ from django.urls import reverse from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode from participation.models import Team +from tfjm.tokens import email_validation_token from .models import AdminRegistration, CoachRegistration, StudentRegistration diff --git a/apps/registration/views.py b/apps/registration/views.py index fa5d476..6df0e26 100644 --- a/apps/registration/views.py +++ b/apps/registration/views.py @@ -3,8 +3,6 @@ import os -from tfjm.tokens import email_validation_token -from tfjm.views import AdminMixin from django.conf import settings from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.models import User @@ -18,6 +16,8 @@ from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, DetailView, RedirectView, TemplateView, UpdateView, View from django_tables2 import SingleTableView from magic import Magic +from tfjm.tokens import email_validation_token +from tfjm.views import AdminMixin from .forms import CoachRegistrationForm, PhotoAuthorizationForm, SignupForm, StudentRegistrationForm, UserForm from .models import Registration, StudentRegistration diff --git a/tfjm/settings.py b/tfjm/settings.py index 6e47c82..c3f7b3b 100644 --- a/tfjm/settings.py +++ b/tfjm/settings.py @@ -68,7 +68,7 @@ INSTALLED_APPS = [ 'participation', ] -if "test" not in sys.argv and not "makemigrations" in sys.argv: # pragma: no cover +if "test" not in sys.argv and "makemigrations" not in sys.argv: # pragma: no cover INSTALLED_APPS += [ 'cas_server', 'django_extensions',