mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-12 07:01:18 +00:00
Compare commits
3 Commits
e9c56104df
...
52c8a836f1
Author | SHA1 | Date | |
---|---|---|---|
|
52c8a836f1 | ||
|
2273cbfbc6 | ||
|
95e1c4f821 |
@ -115,6 +115,35 @@ class ReceiveParticipationForm(forms.ModelForm):
|
|||||||
fields = ('received_participation',)
|
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):
|
class PhaseForm(forms.ModelForm):
|
||||||
"""
|
"""
|
||||||
Form to update the calendar of a phase.
|
Form to update the calendar of a phase.
|
||||||
|
@ -17,7 +17,7 @@ class Migration(migrations.Migration):
|
|||||||
name='Participation',
|
name='Participation',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('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'), (4, 'Problem #4')], default=None, null=True, verbose_name='problem number')),
|
('problem', models.IntegerField(choices=[(1, 'Problem #1'), (2, 'Problem #2'), (3, 'Problem #3')], default=None, null=True, verbose_name='problem number')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name': 'participation',
|
'verbose_name': 'participation',
|
||||||
|
@ -116,7 +116,7 @@ class Participation(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
problem = models.IntegerField(
|
problem = models.IntegerField(
|
||||||
choices=[(i, format_lazy(_("Problem #{problem:d}"), problem=i)) for i in range(1, 5)],
|
choices=[(i, format_lazy(_("Problem #{problem:d}"), problem=i)) for i in range(1, 4)],
|
||||||
null=True,
|
null=True,
|
||||||
default=None,
|
default=None,
|
||||||
verbose_name=_("problem number"),
|
verbose_name=_("problem number"),
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<dd class="col-md-5">{{ participation.sent_participation.team|default:any }}</dd>
|
<dd class="col-md-5">{{ participation.sent_participation.team|default:any }}</dd>
|
||||||
{% if user.registration.is_admin %}
|
{% if user.registration.is_admin %}
|
||||||
<dd class="col-xs-2">
|
<dd class="col-xs-2">
|
||||||
<button class="btn btn-primary">{% trans "Change" %}</button>
|
<button class="btn btn-primary" data-toggle="modal" data-target="#defineSentParticipationModal">{% trans "Change" %}</button>
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
@ -125,6 +125,11 @@
|
|||||||
{% trans "Update" as modal_button %}
|
{% trans "Update" as modal_button %}
|
||||||
{% url "participation:participation_receive_participation" pk=participation.pk as modal_action %}
|
{% url "participation:participation_receive_participation" pk=participation.pk as modal_action %}
|
||||||
{% include "base_modal.html" with modal_id="defineReceivedParticipation" %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
{% trans "Upload video" as modal_title %}
|
{% trans "Upload video" as modal_title %}
|
||||||
@ -145,6 +150,11 @@
|
|||||||
if (!modalBody.html().trim())
|
if (!modalBody.html().trim())
|
||||||
modalBody.load("{% url "participation:participation_receive_participation" pk=participation.pk %} #form-content");
|
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 %}
|
{% endif %}
|
||||||
$('button[data-target="#uploadSolutionModal"]').click(function() {
|
$('button[data-target="#uploadSolutionModal"]').click(function() {
|
||||||
let modalBody = $("#uploadSolutionModal div.modal-body");
|
let modalBody = $("#uploadSolutionModal div.modal-body");
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
{% 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 %}
|
||||||
|
|
@ -2,8 +2,9 @@ from django.urls import path
|
|||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from .views import CalendarView, CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, \
|
from .views import CalendarView, CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, \
|
||||||
ParticipationDetailView, PhaseUpdateView, SetParticipationReceiveParticipationView, TeamAuthorizationsView, \
|
ParticipationDetailView, PhaseUpdateView, SetParticipationReceiveParticipationView, \
|
||||||
TeamDetailView, TeamLeaveView, TeamUpdateView, UploadVideoView
|
SetParticipationSendParticipationView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamUpdateView, \
|
||||||
|
UploadVideoView
|
||||||
|
|
||||||
|
|
||||||
app_name = "participation"
|
app_name = "participation"
|
||||||
@ -21,6 +22,8 @@ urlpatterns = [
|
|||||||
path("detail/upload-video/<int:pk>/", UploadVideoView.as_view(), name="upload_video"),
|
path("detail/upload-video/<int:pk>/", UploadVideoView.as_view(), name="upload_video"),
|
||||||
path("detail/<int:pk>/receive-participation/", SetParticipationReceiveParticipationView.as_view(),
|
path("detail/<int:pk>/receive-participation/", SetParticipationReceiveParticipationView.as_view(),
|
||||||
name="participation_receive_participation"),
|
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/", CalendarView.as_view(), name="calendar"),
|
||||||
path("calendar/<int:pk>/", PhaseUpdateView.as_view(), name="update_phase"),
|
path("calendar/<int:pk>/", PhaseUpdateView.as_view(), name="update_phase"),
|
||||||
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
|
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
|
||||||
|
@ -21,7 +21,7 @@ from magic import Magic
|
|||||||
from registration.models import AdminRegistration
|
from registration.models import AdminRegistration
|
||||||
|
|
||||||
from .forms import JoinTeamForm, ParticipationForm, PhaseForm, ReceiveParticipationForm, RequestValidationForm, \
|
from .forms import JoinTeamForm, ParticipationForm, PhaseForm, ReceiveParticipationForm, RequestValidationForm, \
|
||||||
TeamForm, UploadVideoForm, ValidateParticipationForm
|
SendParticipationForm, TeamForm, UploadVideoForm, ValidateParticipationForm
|
||||||
from .models import Participation, Phase, Team, Video
|
from .models import Participation, Phase, Team, Video
|
||||||
from .tables import CalendarTable
|
from .tables import CalendarTable
|
||||||
|
|
||||||
@ -370,6 +370,18 @@ class SetParticipationReceiveParticipationView(AdminMixin, UpdateView):
|
|||||||
return reverse_lazy("participation:participation_detail", args=(self.object.pk,))
|
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):
|
class UploadVideoView(LoginRequiredMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
Upload a solution video for a team.
|
Upload a solution video for a team.
|
||||||
|
@ -9,7 +9,9 @@ class RegistrationConfig(AppConfig):
|
|||||||
name = 'registration'
|
name = 'registration'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from registration.signals import set_username, send_email_link, create_admin_registration
|
from registration.signals import create_admin_registration, invite_to_public_rooms, \
|
||||||
|
set_username, send_email_link
|
||||||
pre_save.connect(set_username, "auth.User")
|
pre_save.connect(set_username, "auth.User")
|
||||||
pre_save.connect(send_email_link, "auth.User")
|
pre_save.connect(send_email_link, "auth.User")
|
||||||
post_save.connect(create_admin_registration, "auth.User")
|
post_save.connect(create_admin_registration, "auth.User")
|
||||||
|
post_save.connect(invite_to_public_rooms, "registration.Registration")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from corres2math.lists import get_sympa_client
|
from corres2math.lists import get_sympa_client
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from corres2math.matrix import Matrix
|
||||||
from .models import AdminRegistration, Registration
|
from .models import AdminRegistration, Registration
|
||||||
|
|
||||||
|
|
||||||
@ -38,3 +39,12 @@ def create_admin_registration(instance, **_):
|
|||||||
"""
|
"""
|
||||||
if instance.is_superuser:
|
if instance.is_superuser:
|
||||||
AdminRegistration.objects.get_or_create(user=instance)
|
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")
|
||||||
|
@ -7,7 +7,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Corres2math\n"
|
"Project-Id-Version: Corres2math\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2020-10-31 12:36+0100\n"
|
"POT-Creation-Date: 2020-10-31 13:32+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
|
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -99,35 +99,39 @@ msgstr "changelogs"
|
|||||||
msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
|
msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
|
||||||
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
|
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
|
||||||
|
|
||||||
#: apps/participation/forms.py:19 apps/participation/models.py:33
|
#: apps/participation/forms.py:20 apps/participation/models.py:33
|
||||||
msgid "The trigram must be composed of three uppercase letters."
|
msgid "The trigram must be composed of three uppercase letters."
|
||||||
msgstr "Le trigramme doit être composé de trois lettres majuscules."
|
msgstr "Le trigramme doit être composé de trois lettres majuscules."
|
||||||
|
|
||||||
#: apps/participation/forms.py:34
|
#: apps/participation/forms.py:35
|
||||||
msgid "No team was found with this access code."
|
msgid "No team was found with this access code."
|
||||||
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
|
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
|
||||||
|
|
||||||
#: apps/participation/forms.py:68
|
#: apps/participation/forms.py:69
|
||||||
msgid "I engage myself to participate to the whole \"Correspondances\"."
|
msgid "I engage myself to participate to the whole \"Correspondances\"."
|
||||||
msgstr "Je m'engage à participer à l'intégralité des Correspondances."
|
msgstr "Je m'engage à participer à l'intégralité des Correspondances."
|
||||||
|
|
||||||
#: apps/participation/forms.py:83
|
#: apps/participation/forms.py:84
|
||||||
msgid "Message to address to the team:"
|
msgid "Message to address to the team:"
|
||||||
msgstr "Message à adresser à l'équipe :"
|
msgstr "Message à adresser à l'équipe :"
|
||||||
|
|
||||||
#: apps/participation/forms.py:98
|
#: apps/participation/forms.py:99
|
||||||
msgid "You can't upload your video after the deadline."
|
msgid "You can't upload your video after the deadline."
|
||||||
msgstr "Vous ne pouvez pas envoyer de vidéo après la date limite."
|
msgstr "Vous ne pouvez pas envoyer de vidéo après la date limite."
|
||||||
|
|
||||||
#: apps/participation/forms.py:127
|
#: apps/participation/forms.py:124
|
||||||
|
msgid "Send to team"
|
||||||
|
msgstr "Envoyer à l'équipe"
|
||||||
|
|
||||||
|
#: apps/participation/forms.py:162
|
||||||
msgid "Start date must be before the end date."
|
msgid "Start date must be before the end date."
|
||||||
msgstr "La date de début doit être avant la date de fin."
|
msgstr "La date de début doit être avant la date de fin."
|
||||||
|
|
||||||
#: apps/participation/forms.py:129
|
#: apps/participation/forms.py:164
|
||||||
msgid "This phase must start after the previous phases."
|
msgid "This phase must start after the previous phases."
|
||||||
msgstr "Cette phase doit commencer après les phases précédentes."
|
msgstr "Cette phase doit commencer après les phases précédentes."
|
||||||
|
|
||||||
#: apps/participation/forms.py:131
|
#: apps/participation/forms.py:166
|
||||||
msgid "This phase must end after the next phases."
|
msgid "This phase must end after the next phases."
|
||||||
msgstr "Cette phase doit finir avant les phases suivantes."
|
msgstr "Cette phase doit finir avant les phases suivantes."
|
||||||
|
|
||||||
@ -312,7 +316,7 @@ msgid "Proposed solution:"
|
|||||||
msgstr "Solution proposée :"
|
msgstr "Solution proposée :"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/participation_detail.html:27
|
#: apps/participation/templates/participation/participation_detail.html:27
|
||||||
#: apps/participation/templates/participation/participation_detail.html:131
|
#: apps/participation/templates/participation/participation_detail.html:136
|
||||||
#: apps/participation/templates/participation/upload_video.html:11
|
#: apps/participation/templates/participation/upload_video.html:11
|
||||||
#: apps/registration/templates/registration/upload_photo_authorization.html:18
|
#: apps/registration/templates/registration/upload_photo_authorization.html:18
|
||||||
#: apps/registration/templates/registration/user_detail.html:78
|
#: apps/registration/templates/registration/user_detail.html:78
|
||||||
@ -397,9 +401,11 @@ msgid "Define received video"
|
|||||||
msgstr "Définir la vidéo reçue"
|
msgstr "Définir la vidéo reçue"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/participation_detail.html:125
|
#: 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_form.html:11
|
||||||
#: apps/participation/templates/participation/phase_list.html:18
|
#: apps/participation/templates/participation/phase_list.html:18
|
||||||
#: apps/participation/templates/participation/receive_participation_form.html:11
|
#: 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:64
|
||||||
#: apps/participation/templates/participation/team_detail.html:123
|
#: apps/participation/templates/participation/team_detail.html:123
|
||||||
#: apps/participation/templates/participation/update_team.html:12
|
#: apps/participation/templates/participation/update_team.html:12
|
||||||
@ -409,15 +415,19 @@ msgstr "Définir la vidéo reçue"
|
|||||||
msgid "Update"
|
msgid "Update"
|
||||||
msgstr "Modifier"
|
msgstr "Modifier"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/participation_detail.html:130
|
#: 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
|
||||||
msgid "Upload video"
|
msgid "Upload video"
|
||||||
msgstr "Envoyer la vidéo"
|
msgstr "Envoyer la vidéo"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/participation_detail.html:134
|
#: apps/participation/templates/participation/participation_detail.html:139
|
||||||
msgid "Display solution"
|
msgid "Display solution"
|
||||||
msgstr "Afficher la solution"
|
msgstr "Afficher la solution"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/participation_detail.html:135
|
#: apps/participation/templates/participation/participation_detail.html:140
|
||||||
msgid "This video platform is not supported yet."
|
msgid "This video platform is not supported yet."
|
||||||
msgstr "La plateforme de cette vidéo n'est pas encore supportée."
|
msgstr "La plateforme de cette vidéo n'est pas encore supportée."
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user