1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-03 04:42:48 +02:00

Merge branch 'improvements' into 'master'

Improvements

See merge request animath/si/plateforme-corres2math!10
This commit is contained in:
Yohann D'ANELLO
2021-01-01 15:00:33 +00:00
60 changed files with 182 additions and 16 deletions

View File

@ -1 +1,4 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
default_app_config = 'participation.apps.ParticipationConfig'

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib import admin
from django.utils.translation import gettext_lazy as _

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# 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

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import re
from bootstrap_datepicker_plus import DateTimePickerInput

View File

@ -0,0 +1,2 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from asgiref.sync import async_to_sync

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from corres2math.lists import get_sympa_client
from django.core.management import BaseCommand
from django.db.models import Q
@ -26,13 +29,15 @@ class Command(BaseCommand):
f" des Correspondances.", "education", raise_error=False)
for team in Team.objects.filter(participation__valid=True).all():
sympa.subscribe(team.email, "equipes", f"Equipe {team.name}", True, True)
team.create_mailing_list()
sympa.subscribe(team.email, "equipes", f"Equipe {team.name}", True)
sympa.subscribe(team.email, f"probleme-{team.participation.problem}", f"Equipe {team.name}", True)
for team in Team.objects.filter(Q(participation__valid=False) | Q(participation__valid__isnull=True)).all():
team.create_mailing_list()
sympa.subscribe(team.email, "equipes-non-valides", f"Equipe {team.name}", True)
for student in StudentRegistration.objects.filter(team__isnull=False).all():
sympa.subscribe(student.user.email, f"equipe-{student.team.trigram.lower}", True, f"{student}")
sympa.subscribe(student.user.email, f"equipe-{student.team.trigram.lower()}", True, f"{student}")
for coach in CoachRegistration.objects.filter(team__isnull=False).all():
sympa.subscribe(coach.user.email, f"equipe-{coach.team.trigram.lower}", True, f"{coach}")
sympa.subscribe(coach.user.email, f"equipe-{coach.team.trigram.lower()}", True, f"{coach}")

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from corres2math.matrix import Matrix, RoomVisibility
from django.core.management import BaseCommand
from participation.models import Participation

View File

@ -0,0 +1,2 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import re

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from haystack import indexes
from .models import Participation, Team, Video

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from corres2math.lists import get_sympa_client
from participation.models import Participation, Team, Video

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
import django_tables2 as tables
@ -39,6 +42,9 @@ class TeamTable(tables.Table):
attrs = {
'class': 'table table condensed table-striped',
}
row_attrs = {
'class': lambda record: '' if record.participation.solution.link else 'bg-warning',
}
model = Team
fields = ('name', 'trigram', 'problem',)
template_name = 'django_tables2/bootstrap4.html'

View File

@ -0,0 +1,2 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django import template
from ..models import Phase

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from datetime import timedelta
from django.contrib.auth.models import User
@ -409,12 +412,6 @@ class TestStudentParticipation(TestCase):
self.user.registration.team = self.team
self.user.registration.save()
# Team is pending validation
self.team.participation.valid = False
self.team.participation.save()
response = self.client.post(reverse("participation:team_leave"))
self.assertEqual(response.status_code, 403)
# Team is valid
self.team.participation.valid = True
self.team.participation.save()

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.urls import path
from django.views.generic import TemplateView

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from io import BytesIO
from zipfile import ZipFile
@ -341,7 +344,7 @@ class TeamLeaveView(LoginRequiredMixin, TemplateView):
return self.handle_no_permission()
if not request.user.registration.participates or not request.user.registration.team:
raise PermissionDenied(_("You are not in a team."))
if request.user.registration.team.participation.valid is not None:
if request.user.registration.team.participation.valid:
raise PermissionDenied(_("The team is already validated or the validation is pending."))
return super().dispatch(request, *args, **kwargs)