mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 03:02:14 +01:00 
			
		
		
		
	Ensure that all mails are translated
This commit is contained in:
		@@ -230,6 +230,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
 | 
			
		||||
        self.object.participation.save()
 | 
			
		||||
 | 
			
		||||
        mail_context = dict(team=self.object, domain=Site.objects.first().domain)
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            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,
 | 
			
		||||
@@ -265,6 +266,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
 | 
			
		||||
                                          message=form.cleaned_data["message"])
 | 
			
		||||
                mail_context_html = dict(domain=domain, registration=registration, team=self.object, payment=payment,
 | 
			
		||||
                                         message=form.cleaned_data["message"].replace('\n', '<br>'))
 | 
			
		||||
                with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
                    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,
 | 
			
		||||
@@ -274,6 +276,7 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
 | 
			
		||||
            self.object.participation.save()
 | 
			
		||||
            mail_context_plain = dict(team=self.object, message=form.cleaned_data["message"])
 | 
			
		||||
            mail_context_html = dict(team=self.object, message=form.cleaned_data["message"].replace('\n', '<br>'))
 | 
			
		||||
            with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
                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,
 | 
			
		||||
@@ -1147,11 +1150,14 @@ class PoolJuryView(VolunteerMixin, FormView, DetailView):
 | 
			
		||||
            # Send welcome mail
 | 
			
		||||
            subject = f"[{settings.APP_NAME}] " + str(_("New jury account"))
 | 
			
		||||
            site = Site.objects.first()
 | 
			
		||||
            message = render_to_string('registration/mails/add_organizer.txt', dict(user=user,
 | 
			
		||||
            with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
                message = render_to_string('registration/mails/add_organizer.txt',
 | 
			
		||||
                                           dict(user=user,
 | 
			
		||||
                                                inviter=self.request.user,
 | 
			
		||||
                                                password=password,
 | 
			
		||||
                                                domain=site.domain))
 | 
			
		||||
            html = render_to_string('registration/mails/add_organizer.html', dict(user=user,
 | 
			
		||||
                html = render_to_string('registration/mails/add_organizer.html',
 | 
			
		||||
                                        dict(user=user,
 | 
			
		||||
                                             inviter=self.request.user,
 | 
			
		||||
                                             password=password,
 | 
			
		||||
                                             domain=site.domain))
 | 
			
		||||
@@ -1845,9 +1851,8 @@ class NotationSheetTemplateView(VolunteerMixin, DetailView):
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
    def render_to_response(self, context, **response_kwargs):
 | 
			
		||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
			
		||||
 | 
			
		||||
        template_name = self.get_template_names()[0]
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            tex = render_to_string(template_name, context=context, request=self.request)
 | 
			
		||||
        temp_dir = mkdtemp()
 | 
			
		||||
        with open(os.path.join(temp_dir, "texput.tex"), "w") as f:
 | 
			
		||||
 
 | 
			
		||||
@@ -308,7 +308,7 @@ class ParticipantRegistration(Registration):
 | 
			
		||||
        """
 | 
			
		||||
        The team is selected for final.
 | 
			
		||||
        """
 | 
			
		||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            subject = f"[{settings.APP_NAME}] " + str(_("Team selected for the final tournament"))
 | 
			
		||||
            site = Site.objects.first()
 | 
			
		||||
            from participation.models import Tournament
 | 
			
		||||
@@ -802,7 +802,7 @@ class Payment(models.Model):
 | 
			
		||||
        return checkout_intent
 | 
			
		||||
 | 
			
		||||
    def send_remind_mail(self):
 | 
			
		||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            subject = f"[{settings.APP_NAME}] " + str(_("Reminder for your payment"))
 | 
			
		||||
            site = Site.objects.first()
 | 
			
		||||
            for registration in self.registrations.all():
 | 
			
		||||
@@ -813,7 +813,7 @@ class Payment(models.Model):
 | 
			
		||||
                registration.user.email_user(subject, message, html_message=html)
 | 
			
		||||
 | 
			
		||||
    def send_helloasso_payment_confirmation_mail(self):
 | 
			
		||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            subject = f"[{settings.APP_NAME}] " + str(_("Payment confirmation"))
 | 
			
		||||
            site = Site.objects.first()
 | 
			
		||||
            for registration in self.registrations.all():
 | 
			
		||||
 
 | 
			
		||||
@@ -137,6 +137,7 @@ class AddOrganizerView(VolunteerMixin, CreateView):
 | 
			
		||||
        form.instance.set_password(password)
 | 
			
		||||
        form.instance.save()
 | 
			
		||||
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            subject = f"[{settings.APP_NAME}] " + str(_("New organizer account"))
 | 
			
		||||
            site = Site.objects.first()
 | 
			
		||||
            message = render_to_string('registration/mails/add_organizer.txt', dict(user=registration.user,
 | 
			
		||||
@@ -461,9 +462,8 @@ class AuthorizationTemplateView(TemplateView):
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
    def render_to_response(self, context, **response_kwargs):
 | 
			
		||||
        translation.activate(settings.PREFERRED_LANGUAGE_CODE)
 | 
			
		||||
 | 
			
		||||
        template_name = self.get_template_names()[0]
 | 
			
		||||
        with translation.override(settings.PREFERRED_LANGUAGE_CODE):
 | 
			
		||||
            tex = render_to_string(template_name, context=context, request=self.request)
 | 
			
		||||
        temp_dir = mkdtemp()
 | 
			
		||||
        with open(os.path.join(temp_dir, "texput.tex"), "w") as f:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user