1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-02-12 07:01:18 +00:00

Compare commits

..

No commits in common. "52c8a836f19528f766f72d266498b18a15272038" and "e9c56104df19aae21c507f16fe32e603607a0a84" have entirely different histories.

10 changed files with 21 additions and 111 deletions

View File

@ -115,35 +115,6 @@ class ReceiveParticipationForm(forms.ModelForm):
fields = ('received_participation',)
class SendParticipationForm(forms.ModelForm):
"""
Update the sent participation of a participation.
"""
sent_participation = forms.ModelChoiceField(
queryset=Participation.objects,
label=lambda: _("Send to team"),
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["sent_participation"].initial = self.instance.sent_participation
self.fields["sent_participation"].queryset = Participation.objects.filter(
~Q(pk=self.instance.pk) & Q(problem=self.instance.problem, valid=True)
)
def clean(self, commit=True):
cleaned_data = super().clean()
participation = cleaned_data["sent_participation"]
participation.received_participation = self.instance
self.instance = participation
return cleaned_data
class Meta:
model = Participation
fields = ('sent_participation',)
class PhaseForm(forms.ModelForm):
"""
Form to update the calendar of a phase.

View File

@ -17,7 +17,7 @@ class Migration(migrations.Migration):
name='Participation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('problem', models.IntegerField(choices=[(1, 'Problem #1'), (2, 'Problem #2'), (3, 'Problem #3')], default=None, null=True, verbose_name='problem number')),
('problem', models.IntegerField(choices=[(1, 'Problem #1'), (2, 'Problem #2'), (3, 'Problem #3'), (4, 'Problem #4')], default=None, null=True, verbose_name='problem number')),
],
options={
'verbose_name': 'participation',

View File

@ -116,7 +116,7 @@ class Participation(models.Model):
)
problem = models.IntegerField(
choices=[(i, format_lazy(_("Problem #{problem:d}"), problem=i)) for i in range(1, 4)],
choices=[(i, format_lazy(_("Problem #{problem:d}"), problem=i)) for i in range(1, 5)],
null=True,
default=None,
verbose_name=_("problem number"),

View File

@ -50,7 +50,7 @@
<dd class="col-md-5">{{ participation.sent_participation.team|default:any }}</dd>
{% if user.registration.is_admin %}
<dd class="col-xs-2">
<button class="btn btn-primary" data-toggle="modal" data-target="#defineSentParticipationModal">{% trans "Change" %}</button>
<button class="btn btn-primary">{% trans "Change" %}</button>
</dd>
{% endif %}
</dl>
@ -125,11 +125,6 @@
{% trans "Update" as modal_button %}
{% url "participation:participation_receive_participation" pk=participation.pk as modal_action %}
{% include "base_modal.html" with modal_id="defineReceivedParticipation" %}
{% trans "Define team that receives your video" as modal_title %}
{% trans "Update" as modal_button %}
{% url "participation:participation_send_participation" pk=participation.pk as modal_action %}
{% include "base_modal.html" with modal_id="defineSentParticipation" %}
{% endif %}
{% trans "Upload video" as modal_title %}
@ -150,11 +145,6 @@
if (!modalBody.html().trim())
modalBody.load("{% url "participation:participation_receive_participation" pk=participation.pk %} #form-content");
});
$('button[data-target="#defineSentParticipationModal"]').click(function() {
let modalBody = $("#defineSentParticipationModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:participation_send_participation" pk=participation.pk %} #form-content");
});
{% endif %}
$('button[data-target="#uploadSolutionModal"]').click(function() {
let modalBody = $("#uploadSolutionModal div.modal-body");

View File

@ -1,14 +0,0 @@
{% extends "base.html" %}
{% load crispy_forms_filters i18n %}
{% block content %}
<form method="post">
<div id="form-content">
{% csrf_token %}
{{ form|crispy }}
</div>
<button class="btn btn-primary" type="submit">{% trans "Update" %}</button>
</form>
{% endblock content %}

View File

@ -2,9 +2,8 @@ from django.urls import path
from django.views.generic import TemplateView
from .views import CalendarView, CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, \
ParticipationDetailView, PhaseUpdateView, SetParticipationReceiveParticipationView, \
SetParticipationSendParticipationView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamUpdateView, \
UploadVideoView
ParticipationDetailView, PhaseUpdateView, SetParticipationReceiveParticipationView, TeamAuthorizationsView, \
TeamDetailView, TeamLeaveView, TeamUpdateView, UploadVideoView
app_name = "participation"
@ -22,8 +21,6 @@ urlpatterns = [
path("detail/upload-video/<int:pk>/", UploadVideoView.as_view(), name="upload_video"),
path("detail/<int:pk>/receive-participation/", SetParticipationReceiveParticipationView.as_view(),
name="participation_receive_participation"),
path("detail/<int:pk>/send-participation/", SetParticipationSendParticipationView.as_view(),
name="participation_send_participation"),
path("calendar/", CalendarView.as_view(), name="calendar"),
path("calendar/<int:pk>/", PhaseUpdateView.as_view(), name="update_phase"),
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")

View File

@ -21,7 +21,7 @@ from magic import Magic
from registration.models import AdminRegistration
from .forms import JoinTeamForm, ParticipationForm, PhaseForm, ReceiveParticipationForm, RequestValidationForm,\
SendParticipationForm, TeamForm, UploadVideoForm, ValidateParticipationForm
TeamForm, UploadVideoForm, ValidateParticipationForm
from .models import Participation, Phase, Team, Video
from .tables import CalendarTable
@ -370,18 +370,6 @@ class SetParticipationReceiveParticipationView(AdminMixin, UpdateView):
return reverse_lazy("participation:participation_detail", args=(self.object.pk,))
class SetParticipationSendParticipationView(AdminMixin, UpdateView):
"""
Define the team where the solution will be sent.
"""
model = Participation
form_class = SendParticipationForm
template_name = "participation/send_participation_form.html"
def get_success_url(self):
return reverse_lazy("participation:participation_detail", args=(self.object.pk,))
class UploadVideoView(LoginRequiredMixin, UpdateView):
"""
Upload a solution video for a team.

View File

@ -9,9 +9,7 @@ class RegistrationConfig(AppConfig):
name = 'registration'
def ready(self):
from registration.signals import create_admin_registration, invite_to_public_rooms, \
set_username, send_email_link
from registration.signals import set_username, send_email_link, create_admin_registration
pre_save.connect(set_username, "auth.User")
pre_save.connect(send_email_link, "auth.User")
post_save.connect(create_admin_registration, "auth.User")
post_save.connect(invite_to_public_rooms, "registration.Registration")

View File

@ -1,7 +1,6 @@
from corres2math.lists import get_sympa_client
from django.contrib.auth.models import User
from corres2math.matrix import Matrix
from .models import AdminRegistration, Registration
@ -39,12 +38,3 @@ def create_admin_registration(instance, **_):
"""
if instance.is_superuser:
AdminRegistration.objects.get_or_create(user=instance)
def invite_to_public_rooms(instance: Registration, **_):
"""
When a user got registered, automatically invite the Matrix user into public rooms.
"""
if not instance.pk:
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")

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Corres2math\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-10-31 13:32+0100\n"
"POT-Creation-Date: 2020-10-31 12:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -99,39 +99,35 @@ msgstr "changelogs"
msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
#: apps/participation/forms.py:20 apps/participation/models.py:33
#: apps/participation/forms.py:19 apps/participation/models.py:33
msgid "The trigram must be composed of three uppercase letters."
msgstr "Le trigramme doit être composé de trois lettres majuscules."
#: apps/participation/forms.py:35
#: apps/participation/forms.py:34
msgid "No team was found with this access code."
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
#: apps/participation/forms.py:69
#: apps/participation/forms.py:68
msgid "I engage myself to participate to the whole \"Correspondances\"."
msgstr "Je m'engage à participer à l'intégralité des Correspondances."
#: apps/participation/forms.py:84
#: apps/participation/forms.py:83
msgid "Message to address to the team:"
msgstr "Message à adresser à l'équipe :"
#: apps/participation/forms.py:99
#: apps/participation/forms.py:98
msgid "You can't upload your video after the deadline."
msgstr "Vous ne pouvez pas envoyer de vidéo après la date limite."
#: apps/participation/forms.py:124
msgid "Send to team"
msgstr "Envoyer à l'équipe"
#: apps/participation/forms.py:162
#: apps/participation/forms.py:127
msgid "Start date must be before the end date."
msgstr "La date de début doit être avant la date de fin."
#: apps/participation/forms.py:164
#: apps/participation/forms.py:129
msgid "This phase must start after the previous phases."
msgstr "Cette phase doit commencer après les phases précédentes."
#: apps/participation/forms.py:166
#: apps/participation/forms.py:131
msgid "This phase must end after the next phases."
msgstr "Cette phase doit finir avant les phases suivantes."
@ -316,7 +312,7 @@ msgid "Proposed solution:"
msgstr "Solution proposée :"
#: apps/participation/templates/participation/participation_detail.html:27
#: apps/participation/templates/participation/participation_detail.html:136
#: apps/participation/templates/participation/participation_detail.html:131
#: apps/participation/templates/participation/upload_video.html:11
#: apps/registration/templates/registration/upload_photo_authorization.html:18
#: apps/registration/templates/registration/user_detail.html:78
@ -401,11 +397,9 @@ msgid "Define received video"
msgstr "Définir la vidéo reçue"
#: apps/participation/templates/participation/participation_detail.html:125
#: apps/participation/templates/participation/participation_detail.html:130
#: apps/participation/templates/participation/phase_form.html:11
#: apps/participation/templates/participation/phase_list.html:18
#: apps/participation/templates/participation/receive_participation_form.html:11
#: apps/participation/templates/participation/send_participation_form.html:11
#: apps/participation/templates/participation/team_detail.html:64
#: apps/participation/templates/participation/team_detail.html:123
#: apps/participation/templates/participation/update_team.html:12
@ -415,19 +409,15 @@ msgstr "Définir la vidéo reçue"
msgid "Update"
msgstr "Modifier"
#: apps/participation/templates/participation/participation_detail.html:129
msgid "Define team that receives your video"
msgstr "Définir l'équipe qui recevra votre vidéo"
#: apps/participation/templates/participation/participation_detail.html:135
#: apps/participation/templates/participation/participation_detail.html:130
msgid "Upload video"
msgstr "Envoyer la vidéo"
#: apps/participation/templates/participation/participation_detail.html:139
#: apps/participation/templates/participation/participation_detail.html:134
msgid "Display solution"
msgstr "Afficher la solution"
#: apps/participation/templates/participation/participation_detail.html:140
#: apps/participation/templates/participation/participation_detail.html:135
msgid "This video platform is not supported yet."
msgstr "La plateforme de cette vidéo n'est pas encore supportée."