mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-03 19:22:51 +02:00
Add survey notification in the menu
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.db.models.signals import post_save, pre_save
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class ParticipationConfig(AppConfig):
|
||||
@ -10,6 +11,7 @@ class ParticipationConfig(AppConfig):
|
||||
The participation app contains the data about the teams, solutions, ...
|
||||
"""
|
||||
name = 'participation'
|
||||
verbose_name = _("participations")
|
||||
|
||||
def ready(self):
|
||||
from participation import signals
|
||||
|
@ -3,13 +3,12 @@
|
||||
|
||||
from datetime import date, timedelta
|
||||
import math
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
|
||||
from django.db import models
|
||||
from django.db.models import Index
|
||||
from django.db.models import Index, Q
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils import timezone, translation
|
||||
@ -847,6 +846,8 @@ class Participation(models.Model):
|
||||
return _("Participation of the team {name} ({trigram})").format(name=self.team.name, trigram=self.team.trigram)
|
||||
|
||||
def important_informations(self):
|
||||
from survey.models import Survey
|
||||
|
||||
informations = []
|
||||
|
||||
missing_payments = Payment.objects.filter(registrations__in=self.team.participants.all(), valid=False)
|
||||
@ -865,6 +866,19 @@ class Participation(models.Model):
|
||||
'content': content,
|
||||
})
|
||||
|
||||
if self.valid:
|
||||
for survey in Survey.objects.filter(Q(tournament__isnull=True) | Q(tournament=self.tournament), Q(invite_team=True),
|
||||
~Q(completed_teams=self.team)).all():
|
||||
text = _("Please answer to the survey \"{name}\". You can go to the survey on <a href=\"{survey_link}\">that link</a>, "
|
||||
"using the token code you received by mail.")
|
||||
content = format_lazy(text, name=survey.name, survey_link=f"{settings.LIMESURVEY_URL}/index.php/{survey.survey_id}")
|
||||
informations.append({
|
||||
'title': _("Required answer to survey"),
|
||||
'type': "warning",
|
||||
'priority': 12,
|
||||
'content': content
|
||||
})
|
||||
|
||||
if self.tournament:
|
||||
informations.extend(self.informations_for_tournament(self.tournament))
|
||||
if self.final:
|
||||
|
@ -234,7 +234,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
||||
mail_plain = render_to_string("participation/mails/request_validation.txt", mail_context)
|
||||
mail_html = render_to_string("participation/mails/request_validation.html", mail_context)
|
||||
send_mail(f"[{settings.APP_NAME}] {_('Team validation')}", mail_plain, settings.DEFAULT_FROM_EMAIL,
|
||||
[self.object.participation.tournament.organizers_email], html_message=mail_html)
|
||||
[self.object.participation.tournament.organizers_email], html_message=mail_html)
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
@ -270,7 +270,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
||||
mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context_plain)
|
||||
mail_html = render_to_string("participation/mails/team_validated.html", mail_context_html)
|
||||
registration.user.email_user(f"[{settings.APP_NAME}] {_('Team validated')}", mail_plain,
|
||||
html_message=mail_html)
|
||||
html_message=mail_html)
|
||||
elif "invalidate" in self.request.POST:
|
||||
self.object.participation.valid = None
|
||||
self.object.participation.save()
|
||||
@ -280,7 +280,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
||||
mail_plain = render_to_string("participation/mails/team_not_validated.txt", mail_context_plain)
|
||||
mail_html = render_to_string("participation/mails/team_not_validated.html", mail_context_html)
|
||||
send_mail(f"[{settings.APP_NAME}] {_('Team not validated')}", mail_plain,
|
||||
None, [self.object.email], html_message=mail_html)
|
||||
None, [self.object.email], html_message=mail_html)
|
||||
else:
|
||||
form.add_error(None, _("You must specify if you validate the registration or not."))
|
||||
return self.form_invalid(form)
|
||||
|
Reference in New Issue
Block a user