mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 09:02:11 +01:00 
			
		
		
		
	Display payment information on the sidebar
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -14,7 +14,7 @@ from django.utils import timezone
 | 
			
		||||
from django.utils.crypto import get_random_string
 | 
			
		||||
from django.utils.text import format_lazy
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from registration.models import VolunteerRegistration
 | 
			
		||||
from registration.models import VolunteerRegistration, Payment
 | 
			
		||||
from tfjm.lists import get_sympa_client
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -195,6 +195,8 @@ class Team(models.Model):
 | 
			
		||||
                'priority': 2,
 | 
			
		||||
                'content': content,
 | 
			
		||||
            })
 | 
			
		||||
        else:
 | 
			
		||||
            informations.extend(self.participation.important_informations())
 | 
			
		||||
 | 
			
		||||
        return informations
 | 
			
		||||
 | 
			
		||||
@@ -460,6 +462,42 @@ class Participation(models.Model):
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return _("Participation of the team {name} ({trigram})").format(name=self.team.name, trigram=self.team.trigram)
 | 
			
		||||
 | 
			
		||||
    def important_informations(self):
 | 
			
		||||
        informations = []
 | 
			
		||||
 | 
			
		||||
        missing_payments = Payment.objects.filter(registration__in=self.team.participants.all(), valid=False)
 | 
			
		||||
        if missing_payments.exists():
 | 
			
		||||
            text = _("<p>The team {trigram} has {nb_missing_payments} missing payments. Each member of the team "
 | 
			
		||||
                     "must have a valid payment (or send a scholarship notification) "
 | 
			
		||||
                     "to participate to the tournament.</p>"
 | 
			
		||||
                     "<p>Participants that have not paid yet are: {participants}.</p>")
 | 
			
		||||
            content = format_lazy(text, trigram=self.team.trigram, nb_missing_payments=missing_payments.count(),
 | 
			
		||||
                                  participants=", ".join(str(p.registration) for p in missing_payments.all()))
 | 
			
		||||
            informations.append({
 | 
			
		||||
                'title': _("Missing payments"),
 | 
			
		||||
                'type': "danger",
 | 
			
		||||
                'priority': 10,
 | 
			
		||||
                'content': content,
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
        if timezone.now() <= self.tournament.solution_limit:
 | 
			
		||||
            text = _("<p>The solutions for the tournament of {tournament} are due on the {date:%Y-%m-%d %H:%M}.</p>"
 | 
			
		||||
                     "<p>You have currently sent <strong>{nb_solutions}</strong> solutions. "
 | 
			
		||||
                     "We suggest to send at least <strong>{min_solutions}</strong> different solutions.</p>"
 | 
			
		||||
                     "<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>")
 | 
			
		||||
            url = reverse_lazy("participation:participation_detail", args=(self.pk,))
 | 
			
		||||
            content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solution_limit,
 | 
			
		||||
                                  nb_solutions=self.solutions.count(), min_solutions=len(settings.PROBLEMS) - 3,
 | 
			
		||||
                                  url=url)
 | 
			
		||||
            informations.append({
 | 
			
		||||
                'title': _("Solutions due"),
 | 
			
		||||
                'type': "info",
 | 
			
		||||
                'priority': 1,
 | 
			
		||||
                'content': content,
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
        return informations
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        verbose_name = _("participation")
 | 
			
		||||
        verbose_name_plural = _("participations")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user