mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 11:52:20 +01:00 
			
		
		
		
	Send mails to organizers properly
This commit is contained in:
		@@ -110,6 +110,21 @@ class Tournament(models.Model):
 | 
				
			|||||||
        verbose_name = _("tournament")
 | 
					        verbose_name = _("tournament")
 | 
				
			||||||
        verbose_name_plural = _("tournaments")
 | 
					        verbose_name_plural = _("tournaments")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def send_mail_to_organizers(self, template_name, subject="Contact TFJM²", **kwargs):
 | 
				
			||||||
 | 
					        context = kwargs
 | 
				
			||||||
 | 
					        context["tournament"] = self
 | 
				
			||||||
 | 
					        for user in self.organizers.all():
 | 
				
			||||||
 | 
					            context["user"] = user
 | 
				
			||||||
 | 
					            message = render_to_string("mail_templates/" + template_name + ".txt", context=context)
 | 
				
			||||||
 | 
					            message_html = render_to_string("mail_templates/" + template_name + ".html", context=context)
 | 
				
			||||||
 | 
					            send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html)
 | 
				
			||||||
 | 
					        from member.models import TFJMUser
 | 
				
			||||||
 | 
					        for user in TFJMUser.objects.get(is_superuser=True).all():
 | 
				
			||||||
 | 
					            context["user"] = user
 | 
				
			||||||
 | 
					            message = render_to_string("mail_templates/" + template_name + ".txt", context=context)
 | 
				
			||||||
 | 
					            message_html = render_to_string("mail_templates/" + template_name + ".html", context=context)
 | 
				
			||||||
 | 
					            send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return self.name
 | 
					        return self.name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -142,7 +142,7 @@ class TeamDetailView(LoginRequiredMixin, DetailView):
 | 
				
			|||||||
        elif "request_validation" in request.POST and request.user.participates:
 | 
					        elif "request_validation" in request.POST and request.user.participates:
 | 
				
			||||||
            team.validation_status = "1waiting"
 | 
					            team.validation_status = "1waiting"
 | 
				
			||||||
            team.save()
 | 
					            team.save()
 | 
				
			||||||
            team.send_mail("request_validation", "Demande de validation TFJM²")
 | 
					            team.tournament.send_mail_to_organizers("request_validation", "Demande de validation TFJM²", team=team)
 | 
				
			||||||
            return redirect('tournament:team_detail', pk=team.pk)
 | 
					            return redirect('tournament:team_detail', pk=team.pk)
 | 
				
			||||||
        elif "validate" in request.POST and request.user.organizes:
 | 
					        elif "validate" in request.POST and request.user.organizes:
 | 
				
			||||||
            team.validation_status = "2valid"
 | 
					            team.validation_status = "2valid"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user