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

Compare commits

...

14 Commits

Author SHA1 Message Date
4c9e63be3d Merge branch 'improvements' into 'master'
Questions can be seen during the third phase

See merge request animath/si/plateforme-corres2math!11
2021-01-08 12:42:44 +00:00
35a197be07 Questions can be seen during the third phase 2021-01-08 13:37:14 +01:00
01f6d74cae Merge branch 'improvements' into 'master'
Improvements

See merge request animath/si/plateforme-corres2math!10
2021-01-01 15:00:33 +00:00
d55671efd1 Use warning background for teams that didn't sent their video 2021-01-01 15:54:50 +01:00
bcdbc445c6 Fix the fix sympa lists script 2021-01-01 15:41:23 +01:00
95a69f35d2 A user can have no team 2020-12-28 11:52:34 +01:00
eec941c816 Admins can change email validation status 2020-12-27 21:19:09 +01:00
64d471936f Add copyright information 2020-12-26 21:26:26 +01:00
a82c6b4673 Merge branch 'improvements' into 'master'
django-cas-server does not support Django 3.1 and Python 3.9 yet

See merge request animath/si/plateforme-corres2math!9
2020-12-22 22:29:51 +00:00
4ee5ac309d Merge branch 'improvements' into 'master'
Improvements, bug fixes

See merge request animath/si/plateforme-corres2math!8
2020-12-22 20:36:57 +00:00
24e1cf3845 Merge branch 'improvements' into 'master'
Improvements

See merge request animath/si/plateforme-corres2math!7
2020-12-11 13:11:23 +00:00
91640f8fb1 Merge branch 'improvements' into 'master'
Fix signup

See merge request animath/si/plateforme-corres2math!6
2020-12-04 00:49:30 +00:00
ce048a30d6 Invite people in Matrix rooms at registration 2020-11-16 19:07:18 +01:00
d104c2ff1f Merge branch 'improvements' into 'master'
Improvements

See merge request animath/si/plateforme-corres2math!5
2020-11-16 11:06:10 +00:00
61 changed files with 212 additions and 26 deletions

View File

@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
Copyright (C) 2020 Animath
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
<program> Copyright (C) 2020 Animath
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

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

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.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.contrib.auth.models import User
from rest_framework import serializers

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from unittest.case import skipIf
from django.conf import settings

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.conf import settings
from django.conf.urls import include, url
from rest_framework import routers

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.models import User
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import SearchFilter

View File

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

View File

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

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.urls import path
from django.views.generic import TemplateView

View File

@ -0,0 +1,2 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later

View File

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

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
@ -85,5 +88,7 @@ class Command(BaseCommand):
f"@{admin.matrix_username}:correspondances-maths.fr", 95)
Matrix.set_room_power_level("#faq:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)
Matrix.set_room_power_level("#je-cherche-une-equipe:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)
Matrix.set_room_power_level("#flood:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)

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
@ -35,6 +38,6 @@ class Command(BaseCommand):
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
@ -285,7 +288,7 @@ class Phase(models.Model):
)
@classmethod
def current_phase(cls):
def current_phase(cls) -> "Phase":
"""
Retrieve the current phase of this day
"""

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

@ -194,13 +194,14 @@
{% trans "This video platform is not supported yet." as unsupported_platform %}
{% include "base_modal.html" with modal_id="displayOtherSolution" modal_action="" modal_button="" modal_additional_class="modal-lg" modal_content=participation.received_participation.solution.as_iframe|default:unsupported_platform %}
{% endif %}
{% endif %}
{% if user.registration.participates and current_phase.phase_number == 2 %}
{% trans "Add question" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:add_question" pk=participation.pk as modal_action %}
{% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
{% if current_phase.phase_number == 2 %}
{% trans "Add question" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:add_question" pk=participation.pk as modal_action %}
{% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
{% endif %}
{% for question in participation.questions.all %}
{% with number_str=forloop.counter|stringformat:"d"%}
{% with modal_id="updateQuestion"|add:number_str %}
@ -260,27 +261,29 @@
});
{% endif %}
{% if user.registration.participates and current_phase.phase_number == 2 %}
{% if current_phase.phase_number == 2 %}
$('button[data-target="#addQuestionModal"]').click(function() {
let modalBody = $("#addQuestionModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:add_question" pk=participation.pk %} #form-content");
});
{% endif %}
{% for question in participation.questions.all %}
$('button[data-target="#updateQuestion{{ forloop.counter }}Modal"]').click(function() {
let modalBody = $("#updateQuestion{{ forloop.counter }}Modal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:update_question" pk=question.pk %} #form-content");
});
{% for question in participation.questions.all %}
$('button[data-target="#updateQuestion{{ forloop.counter }}Modal"]').click(function() {
let modalBody = $("#updateQuestion{{ forloop.counter }}Modal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:update_question" pk=question.pk %} #form-content");
});
{% if current_phase.phase_number == 2 %}
$('button[data-target="#deleteQuestion{{ forloop.counter }}Modal"]').click(function() {
let modalBody = $("#deleteQuestion{{ forloop.counter }}Modal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:delete_question" pk=question.pk %} #form-content");
});
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
$('button[data-target="#uploadSolutionModal"]').click(function() {
let modalBody = $("#uploadSolutionModal div.modal-body");

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

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
@ -474,6 +477,12 @@ class UpdateQuestionView(LoginRequiredMixin, UpdateView):
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied
def form_valid(self, form):
if not self.request.user.registration.is_admin and Phase.current_phase().phase_number != 2:
form.add_error(None, _("You can update your questions now."))
return self.form_invalid(form)
return super().form_valid(form)
def get_success_url(self):
return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,))
@ -496,6 +505,11 @@ class DeleteQuestionView(LoginRequiredMixin, DeleteView):
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied
def delete(self, request, *args, **kwargs):
if not request.user.registration.is_admin and Phase.current_phase().phase_number != 2:
raise PermissionDenied(_("You can update your questions now."))
return super().delete(request, *args, **kwargs)
def get_success_url(self):
return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,))

View File

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

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 polymorphic.admin import PolymorphicChildModelAdmin, PolymorphicParentModelAdmin

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_save

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from cas_server.auth import DjangoAuthUser # pragma: no cover

View File

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

View File

@ -50,7 +50,7 @@ class Migration(migrations.Migration):
('student_class', models.IntegerField(choices=[(12, '12th grade'), (11, '11th grade'), (10, '10th grade or lower')], verbose_name='student class')),
('school', models.CharField(max_length=255, verbose_name='school')),
('photo_authorization', models.FileField(blank=True, default='', upload_to=registration.models.get_random_filename, verbose_name='photo authorization')),
('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='students', to='participation.team', verbose_name='team')),
('team', models.ForeignKey(default=None, blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='students', to='participation.team', verbose_name='team')),
],
options={
'verbose_name': 'student registration',
@ -63,7 +63,7 @@ class Migration(migrations.Migration):
fields=[
('registration_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registration.registration')),
('professional_activity', models.TextField(verbose_name='professional activity')),
('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='coachs', to='participation.team', verbose_name='team')),
('team', models.ForeignKey(default=None, blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='coachs', to='participation.team', verbose_name='team')),
],
options={
'verbose_name': 'coach registration',

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 corres2math.tokens import email_validation_token
from django.contrib.sites.models import Site
from django.db import models
@ -102,6 +105,7 @@ class StudentRegistration(Registration):
related_name="students",
on_delete=models.PROTECT,
null=True,
blank=True,
default=None,
verbose_name=_("team"),
)
@ -151,6 +155,7 @@ class CoachRegistration(Registration):
related_name="coachs",
on_delete=models.PROTECT,
null=True,
blank=True,
default=None,
verbose_name=_("team"),
)

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 Registration

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 corres2math.matrix import Matrix
from django.contrib.auth.models import User
@ -45,9 +48,9 @@ def invite_to_public_rooms(instance: Registration, created: bool, **_):
"""
When a user got registered, automatically invite the Matrix user into public rooms.
"""
if not created:
if created:
Matrix.invite("#annonces:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
Matrix.invite("#faq:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
Matrix.invite("#je-cherche-une-equip:correspondances-maths.fr",
Matrix.invite("#je-cherche-une-equipe:correspondances-maths.fr",
f"@{instance.matrix_username}:correspondances-maths.fr")
Matrix.invite("#flood:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")

View File

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

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 django_tables2 import Table
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 datetime import timedelta
import os

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 .views import MyAccountDetailView, ResetAdminView, SignupView, UserDetailView, UserImpersonateView, \

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from corres2math.tokens import email_validation_token
@ -210,7 +213,7 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
context["title"] = _("Update user {user}").format(user=str(self.object.registration))
context["registration_form"] = user.registration.form_class(data=self.request.POST or None,
instance=self.object.registration)
if not user.registration.is_admin:
if not self.request.user.registration.is_admin:
if "team" in context["registration_form"].fields:
del context["registration_form"].fields["team"]
del context["registration_form"].fields["email_confirmed"]
@ -221,7 +224,7 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
user = form.instance
registration_form = user.registration.form_class(data=self.request.POST or None,
instance=self.object.registration)
if not user.registration.is_admin:
if not self.request.user.registration.is_admin:
if "team" in registration_form.fields:
del registration_form.fields["team"]
del registration_form.fields["email_confirmed"]

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
"""
ASGI config for corres2math project.

View File

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

View File

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

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from threading import local
from django.conf import settings

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
"""
Django settings for corres2math project.

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

View File

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

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from django.core.handlers.asgi import ASGIHandler

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.tokens import PasswordResetTokenGenerator

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
"""corres2math URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from haystack.generic_views import SearchView

View File

@ -1,3 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
"""
WSGI config for corres2math project.