diff --git a/bda/models.py b/bda/models.py index 85c7fa4d..b2dc1145 100644 --- a/bda/models.py +++ b/bda/models.py @@ -7,12 +7,11 @@ from __future__ import unicode_literals import calendar import random from datetime import timedelta +from custommail.utils import send_custom_mail, send_mass_custom_mail from django.contrib.sites.models import Site from django.db import models from django.contrib.auth.models import User -from django.template import loader -from django.core import mail from django.conf import settings from django.utils import timezone, formats from django.utils.encoding import python_2_unicode_compatible @@ -100,27 +99,24 @@ class Spectacle(models.Model): if member.id in members: members[member.id][1] = 2 else: - members[member.id] = [member.first_name, 1, member.email] - # Pour le BdA - members[0] = ['BdA', 1, 'bda@ens.fr'] - members[-1] = ['BdA', 2, 'bda@ens.fr'] + members[member.id] = [member, 1] + # FIXME : faire quelque chose de ça, un utilisateur bda_generic ? + # # Pour le BdA + # members[0] = ['BdA', 1, 'bda@ens.fr'] + # members[-1] = ['BdA', 2, 'bda@ens.fr'] # On écrit un mail personnalisé à chaque participant - mails_to_send = [] - mail_object = str(self) - for member in members.values(): - mail_body = loader.render_to_string('bda/mails/rappel.txt', { - 'name': member[0], - 'nb_attr': member[1], - 'show': self}) - mail_tot = mail.EmailMessage( - mail_object, mail_body, - settings.MAIL_DATA['rappels']['FROM'], [member[2]], - [], headers={ - 'Reply-To': settings.MAIL_DATA['rappels']['REPLYTO']}) - mails_to_send.append(mail_tot) - # On envoie les mails - connection = mail.get_connection() - connection.send_messages(mails_to_send) + mails_data = [ + ( + member[0].email, + {'member': member[0],'nb_attr': member[1], 'show': self} + ) + for member in members.values() + ] + send_mass_custom_mail( + 'bda-rappel', + mails_data, + from_email=settings.MAIL_DATA['rappels']['FROM'] + ) # On enregistre le fait que l'envoi a bien eu lieu self.rappel_sent = timezone.now() self.save() @@ -263,26 +259,28 @@ class SpectacleRevente(models.Model): verbose_name = "Revente" def send_notif(self): + """ + Envoie une notification pour indiquer la mise en vente d'une place sur + BdA-Revente à tous les intéressés. + """ inscrits = self.attribution.spectacle.subscribed.select_related('user') - - mails_to_send = [] - mail_object = "%s" % (self.attribution.spectacle) - for participant in inscrits: - mail_body = loader.render_to_string('bda/mails/revente.txt', { - 'user': participant.user, - 'spectacle': self.attribution.spectacle, - 'revente': self, - 'domain': Site.objects.get_current().domain}) - mail_tot = mail.EmailMessage( - mail_object, mail_body, - settings.MAIL_DATA['revente']['FROM'], - [participant.user.email], - [], headers={ - 'Reply-To': settings.MAIL_DATA['revente']['REPLYTO']}) - mails_to_send.append(mail_tot) - - connection = mail.get_connection() - connection.send_messages(mails_to_send) + mails_data = [ + ( + participant.user.email, + { + 'member': participant.user, + 'show': self.attribution.spectacle, + 'revente': self, + 'site': Site.objects.get_current() + } + ) + for participant in inscrits + ] + send_mass_custom_mail( + "bda-revente", + mails_data, + from_email=settings.MAIL_DATA['revente']['FROM'], + ) self.notif_sent = True self.save() @@ -292,25 +290,22 @@ class SpectacleRevente(models.Model): leur indiquer qu'il est désormais disponible au shotgun. """ inscrits = self.attribution.spectacle.subscribed.select_related('user') - - mails_to_send = [] - mail_object = "%s" % (self.attribution.spectacle) - for participant in inscrits: - mail_body = loader.render_to_string('bda/mails/shotgun.txt', { - 'user': participant.user, - 'spectacle': self.attribution.spectacle, - 'domain': Site.objects.get_current(), - 'mail': self.attribution.participant.user.email}) - mail_tot = mail.EmailMessage( - mail_object, mail_body, - settings.MAIL_DATA['revente']['FROM'], - [participant.user.email], - [], headers={ - 'Reply-To': settings.MAIL_DATA['revente']['REPLYTO']}) - mails_to_send.append(mail_tot) - - connection = mail.get_connection() - connection.send_messages(mails_to_send) + mails_data = [ + ( + participant.user.email, + { + 'member': participant.user, + 'show': self.attribution.spectacle, + 'site': Site.objects.get_current(), + } + ) + for participant in inscrits + ] + send_mass_custom_mail( + "bda-shotgun", + mails_data, + from_email=settings.MAIL_DATA['revente']['FROM'] + ) self.notif_sent = True self.save() @@ -325,51 +320,43 @@ class SpectacleRevente(models.Model): seller = self.seller if inscrits: - mails = [] - mail_subject = "BdA-Revente : {:s}".format(spectacle.title) - # Envoie un mail au gagnant et au vendeur winner = random.choice(inscrits) self.soldTo = winner context = { 'acheteur': winner.user, 'vendeur': seller.user, - 'spectacle': spectacle, + 'show': spectacle, } - mails.append(mail.EmailMessage( - mail_subject, - loader.render_to_string('bda/mails/revente-winner.txt', - context), - from_email=settings.MAIL_DATA['revente']['FROM'], - to=[winner.user.email], - reply_to=[seller.user.email], - )) - mails.append(mail.EmailMessage( - mail_subject, - loader.render_to_string('bda/mails/revente-seller.txt', - context), - from_email=settings.MAIL_DATA['revente']['FROM'], - to=[seller.user.email], - reply_to=[winner.user.email], - )) + send_custom_mail( + winner.user.email, + 'bda-revente-winner', + context=context, + from_email=settings.MAIL_DATA['revente']['FROM'] + ) + send_custom_mail( + seller.user.email, + 'bda-revente-seller', + context=context, + from_email=settings.MAIL_DATA['revente']['FROM'] + ) # Envoie un mail aux perdants - for inscrit in inscrits: - if inscrit == winner: - continue - - mail_body = loader.render_to_string( - 'bda/mails/revente-loser.txt', - {'acheteur': inscrit.user, - 'vendeur': seller.user, - 'spectacle': spectacle} + mails_data = [ + ( + inscrit.user.email, + { + 'acheteur': inscrit.user, + 'vendeur': seller.user, + 'show': spectacle + } ) - mails.append(mail.EmailMessage( - mail_subject, mail_body, - from_email=settings.MAIL_DATA['revente']['FROM'], - to=[inscrit.user.email], - reply_to=[settings.MAIL_DATA['revente']['REPLYTO']], - )) - mail.get_connection().send_messages(mails) + for inscrit in inscrits if inscrit == winner + ] + send_mass_custom_mail( + 'bda-revente-loser', + mails_data, + from_email=settings.MAIL_DATA['revente']['FROM'] + ) self.tirage_done = True self.save() diff --git a/bda/templates/bda/mails/buy-shotgun.txt b/bda/templates/bda/mails/buy-shotgun.txt deleted file mode 100644 index d7855143..00000000 --- a/bda/templates/bda/mails/buy-shotgun.txt +++ /dev/null @@ -1,6 +0,0 @@ -Bonjour {{ vendeur.first_name }} ! - -Je souhaiterais racheter ta place pour {{ spectacle.title }} le {{ spectacle.date }} ({{ spectacle.location }}) à {{ spectacle.price|floatformat:2 }}€. -Contacte-moi si tu es toujours intéressé·e ! - -{{ acheteur.get_full_name }} ({{ acheteur.email }}) diff --git a/bda/templates/bda/mails/rappel.txt b/bda/templates/bda/mails/rappel.txt deleted file mode 100644 index c6433f8a..00000000 --- a/bda/templates/bda/mails/rappel.txt +++ /dev/null @@ -1,23 +0,0 @@ -Bonjour {{ name }}, - -Nous te rappellons que tu as eu la chance d'obtenir {{ nb_attr|pluralize:"une place,deux places" }} -pour {{ show.title }}, le {{ show.date }} au {{ show.location }}. N'oublie pas de t'y rendre ! -{% if nb_attr == 2 %} -Tu as obtenu deux places pour ce spectacle. Nous te rappelons que -ces places sont strictement réservées aux personnes de moins de 28 ans. -{% endif %} -{% if show.listing %}Pour ce spectacle, tu as reçu des places sur -listing. Il te faudra donc te rendre 15 minutes en avance sur les lieux de la représentation -pour retirer {{ nb_attr|pluralize:"ta place,tes places" }}. -{% else %}Pour assister à ce spectacle, tu dois présenter les billets qui ont -été distribués au burô. -{% endif %} - -Si tu ne peux plus assister à cette représentation, tu peux -revendre ta place via BdA-revente, accessible directement sur -GestioCOF (lien "revendre une place du premier tirage" sur la page -d'accueil https://www.cof.ens.fr/gestion/). - -En te souhaitant un excellent spectacle, - -Le Bureau des Arts diff --git a/bda/templates/bda/mails/revente-loser.txt b/bda/templates/bda/mails/revente-loser.txt deleted file mode 100644 index 6b50944d..00000000 --- a/bda/templates/bda/mails/revente-loser.txt +++ /dev/null @@ -1,9 +0,0 @@ -Bonjour {{ acheteur.first_name }}, - -Tu t'étais inscrit-e pour la revente de la place de {{ vendeur.get_full_name }} -pour {{ spectacle.title }}. -Malheureusement, une autre personne a été tirée au sort pour racheter la place. -Tu pourras certainement retenter ta chance pour une autre revente ! - -À très bientôt, -Le Bureau des Arts diff --git a/bda/templates/bda/mails/revente-new.txt b/bda/templates/bda/mails/revente-new.txt deleted file mode 100644 index ffba3083..00000000 --- a/bda/templates/bda/mails/revente-new.txt +++ /dev/null @@ -1,13 +0,0 @@ -Bonjour {{ vendeur.first_name }}, - -Tu t’es bien inscrit-e pour la revente de {{ spectacle.title }}. - -{% with revente.expiration_time as time %} -Le tirage au sort entre tout-e-s les racheteuse-eur-s potentiel-le-s aura lieu -le {{ time|date:"DATE_FORMAT" }} à {{ time|time:"TIME_FORMAT" }} (dans {{time|timeuntil }}). -Si personne ne s’est inscrit pour racheter la place, celle-ci apparaitra parmi -les « Places disponibles immédiatement à la revente » sur GestioCOF. -{% endwith %} - -Bonne revente ! -Le Bureau des Arts diff --git a/bda/templates/bda/mails/revente-seller.txt b/bda/templates/bda/mails/revente-seller.txt deleted file mode 100644 index ec99b98b..00000000 --- a/bda/templates/bda/mails/revente-seller.txt +++ /dev/null @@ -1,7 +0,0 @@ -Bonjour {{ vendeur.first_name }}, - -La personne tirée au sort pour racheter ta place pour {{ spectacle.title }} est {{ acheteur.get_full_name }}. -Tu peux le/la contacter à l'adresse {{ acheteur.email }}, ou en répondant à ce mail. - -Chaleureusement, -Le BdA diff --git a/bda/templates/bda/mails/revente-winner.txt b/bda/templates/bda/mails/revente-winner.txt deleted file mode 100644 index 01ecfb86..00000000 --- a/bda/templates/bda/mails/revente-winner.txt +++ /dev/null @@ -1,7 +0,0 @@ -Bonjour {{ acheteur.first_name }}, - -Tu as été tiré-e au sort pour racheter une place pour {{ spectacle.title }} le {{ spectacle.date }} ({{ spectacle.location }}) à {{ spectacle.price|floatformat:2 }}€. -Tu peux contacter le/la vendeur-se à l'adresse {{ vendeur.email }}, ou en répondant à ce mail. - -Chaleureusement, -Le BdA diff --git a/bda/templates/bda/mails/revente.txt b/bda/templates/bda/mails/revente.txt deleted file mode 100644 index 397a58d8..00000000 --- a/bda/templates/bda/mails/revente.txt +++ /dev/null @@ -1,12 +0,0 @@ -Bonjour {{ user.first_name }} - -Une place pour le spectacle {{ spectacle.title }} ({{ spectacle.date }}) -a été postée sur BdA-Revente. - -Si ce spectacle t'intéresse toujours, merci de nous le signaler en cliquant -sur ce lien : http://{{ domain }}{% url "bda-revente-interested" revente.id %}. -Dans le cas où plusieurs personnes seraient intéressées, nous procèderons à -un tirage au sort le {{ revente.expiration_time_str }}. - -Chaleureusement, -Le BdA diff --git a/bda/templates/bda/mails/shotgun.txt b/bda/templates/bda/mails/shotgun.txt deleted file mode 100644 index 69bc704c..00000000 --- a/bda/templates/bda/mails/shotgun.txt +++ /dev/null @@ -1,11 +0,0 @@ -Bonjour {{ user.first_name }} - -Une place pour le spectacle {{ spectacle.title }} ({{ spectacle.date }}) -a été postée sur BdA-Revente. - -Puisque ce spectacle a lieu dans moins de 24h, il n'y a pas de tirage au sort pour -cette place : elle est disponible immédiatement à l'adresse -http://{{ domain }}{% url "bda-buy-revente" spectacle.id %}, à la disposition de tous. - -Chaleureusement, -Le BdA diff --git a/bda/views.py b/bda/views.py index 72fd5dd2..a0767c67 100644 --- a/bda/views.py +++ b/bda/views.py @@ -5,19 +5,19 @@ from __future__ import print_function from __future__ import unicode_literals import random +from custommail.utils import send_mass_custom_mail, send_custom_mail from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.db import models, transaction from django.db.models import Count, Q -from django.core import serializers, mail +from django.core import serializers from django.forms.models import inlineformset_factory from django.http import HttpResponseBadRequest, HttpResponseRedirect from django.core.urlresolvers import reverse from django.conf import settings import hashlib -from django.core.mail import send_mail from django.template import loader from django.utils import timezone from django.views.generic.list import ListView @@ -275,7 +275,7 @@ def revente(request, tirage_id): resellform = ResellForm(participant, request.POST, prefix='resell') annulform = AnnulForm(participant, prefix='annul') if resellform.is_valid(): - mails = [] + mails_data = [] attributions = resellform.cleaned_data["attributions"] with transaction.atomic(): for attribution in attributions: @@ -285,20 +285,18 @@ def revente(request, tirage_id): if not created: revente.seller = participant revente.date = timezone.now() - mail_subject = "BdA-Revente : {:s}".format(attribution.spectacle.title) - mail_body = loader.render_to_string('bda/mails/revente-new.txt', { + context = { 'vendeur': participant.user, - 'spectacle': attribution.spectacle, - 'revente': revente, - }) - mails.append(mail.EmailMessage( - mail_subject, mail_body, - from_email=settings.MAIL_DATA['revente']['FROM'], - to=[participant.user.email], - reply_to=[settings.MAIL_DATA['revente']['REPLYTO']], - )) + 'show': attribution.spectacle, + 'revente': revente + } + mails_data.append(participant.user.email, context) revente.save() - mail.get_connection().send_messages(mails) + send_mass_custom_mail( + 'bda-revente-new', + mails_data, + from_email=settings.MAIL_DATA['revente']['FROM'] + ) elif 'annul' in request.POST: annulform = AnnulForm(participant, request.POST, prefix='annul') @@ -453,15 +451,17 @@ def buy_revente(request, spectacle_id): revente = random.choice(reventes_shotgun) revente.soldTo = participant revente.save() - mail = loader.render_to_string('bda/mails/buy-shotgun.txt', { - 'spectacle': spectacle, + context = { + 'show': spectacle, 'acheteur': request.user, - 'vendeur': revente.seller.user, - }) - send_mail("BdA-Revente : %s" % spectacle.title, mail, - request.user.email, - [revente.seller.user.email], - fail_silently=False) + 'vendeur': revente.seller.user + } + send_custom_mail( + revente.seller.user.email, + 'bda-buy-shotgun', + context=context, + from_email='bda@ens.fr' + ) return render(request, "bda-success.html", {"seller": revente.attribution.participant.user, "spectacle": spectacle}) @@ -548,15 +548,16 @@ def unpaid(request, tirage_id): def send_rappel(request, spectacle_id): show = get_object_or_404(Spectacle, id=spectacle_id) # Mails d'exemples - fake_member = request.user - fake_member.nb_attr = 1 - exemple_mail_1place = loader.render_to_string('bda/mails/rappel.txt', { - 'member': fake_member, - 'show': show}) - fake_member.nb_attr = 2 - exemple_mail_2places = loader.render_to_string('bda/mails/rappel.txt', { - 'member': fake_member, - 'show': show}) + exemple_mail_1place = render_mail('bda-rappel', { + 'member': request.user, + 'show': show, + 'nb_attr': 1 + }) + exemple_mail_2place = render_mail('bda-rappel', { + 'member': request.user, + 'show': show, + 'nb_attr': 2 + }) # Contexte ctxt = {'show': show, 'exemple_mail_1place': exemple_mail_1place, diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 610ae549..50027803 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -50,6 +50,7 @@ INSTALLED_APPS = ( 'kfet', 'channels', 'widget_tweaks', + 'custommail', ) MIDDLEWARE_CLASSES = ( diff --git a/gestioncof/admin.py b/gestioncof/admin.py index eb8ad6c0..a177c26c 100644 --- a/gestioncof/admin.py +++ b/gestioncof/admin.py @@ -8,7 +8,7 @@ from django import forms from django.contrib import admin from django.utils.translation import ugettext_lazy as _ from gestioncof.models import SurveyQuestionAnswer, SurveyQuestion, \ - CofProfile, EventOption, EventOptionChoice, Event, Club, CustomMail, \ + CofProfile, EventOption, EventOptionChoice, Event, Club, \ Survey, EventCommentField, EventRegistration from gestioncof.petits_cours_models import PetitCoursDemande, \ PetitCoursSubject, PetitCoursAbility, PetitCoursAttribution, \ @@ -267,10 +267,6 @@ class PetitCoursDemandeAdmin(admin.ModelAdmin): search_fields = ('name', 'email', 'phone', 'lieu', 'remarques') -class CustomMailAdmin(admin.ModelAdmin): - search_fields = ('shortname', 'title') - - class ClubAdminForm(forms.ModelForm): def clean(self): cleaned_data = super(ClubAdminForm, self).clean() @@ -297,7 +293,6 @@ admin.site.unregister(User) admin.site.register(User, UserProfileAdmin) admin.site.register(CofProfile) admin.site.register(Club, ClubAdmin) -admin.site.register(CustomMail) admin.site.register(PetitCoursSubject) admin.site.register(PetitCoursAbility, PetitCoursAbilityAdmin) admin.site.register(PetitCoursAttribution, PetitCoursAttributionAdmin) diff --git a/gestioncof/models.py b/gestioncof/models.py index 19590aff..bafb9518 100644 --- a/gestioncof/models.py +++ b/gestioncof/models.py @@ -96,22 +96,6 @@ class Club(models.Model): return self.name -@python_2_unicode_compatible -class CustomMail(models.Model): - shortname = models.SlugField(max_length=50, blank=False) - title = models.CharField("Titre", max_length=200, blank=False) - content = models.TextField("Contenu", blank=False) - comments = models.TextField("Informations contextuelles sur le mail", - blank=True) - - class Meta: - verbose_name = "Mail personnalisable" - verbose_name_plural = "Mails personnalisables" - - def __str__(self): - return "%s: %s" % (self.shortname, self.title) - - @python_2_unicode_compatible class Event(models.Model): title = models.CharField("Titre", max_length=200) diff --git a/gestioncof/petits_cours_views.py b/gestioncof/petits_cours_views.py index 303cec2c..9474a087 100644 --- a/gestioncof/petits_cours_views.py +++ b/gestioncof/petits_cours_views.py @@ -4,9 +4,9 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals +from custommail.utils import send_custom_mail, render_mail + from django.shortcuts import render, get_object_or_404, redirect -from django.core import mail -from django.core.mail import EmailMessage from django.forms import ModelForm from django import forms from django.forms.models import inlineformset_factory, BaseInlineFormSet @@ -131,7 +131,7 @@ def _finalize_traitement(request, demande, proposals, proposed_for, proposed_for = proposed_for.items() attribdata = list(attribdata.items()) proposed_mails = _generate_eleve_email(demande, proposed_for) - mainmail = loader.render_to_string("petits-cours-mail-demandeur.txt", { + mainmail = render_mail("petits-cours-mail-demandeur", { "proposals": proposals, "unsatisfied": unsatisfied, "extra": @@ -155,14 +155,16 @@ def _finalize_traitement(request, demande, proposals, proposed_for, def _generate_eleve_email(demande, proposed_for): - proposed_mails = [] - for user, matieres in proposed_for: - msg = loader.render_to_string("petits-cours-mail-eleve.txt", { - "demande": demande, - "matieres": matieres - }) - proposed_mails.append((user, msg)) - return proposed_mails + return [ + ( + user, + render_mail('petit-cours-mail-eleve', { + "demande": demande, + "matieres": matieres + })[1] + ) + for user, matieres in proposed_for + ] def _traitement_other_preparing(request, demande): @@ -274,7 +276,7 @@ def _traitement_post(request, demande): proposals_list = proposals.items() proposed_for = proposed_for.items() proposed_mails = _generate_eleve_email(demande, proposed_for) - mainmail = loader.render_to_string("petits-cours-mail-demandeur.txt", { + mainmail = render_mail("petits-cours-mail-demandeur", { "proposals": proposals_list, "unsatisfied": unsatisfied, "extra": extra, diff --git a/gestioncof/shared.py b/gestioncof/shared.py index 8fe17d43..988b93ee 100644 --- a/gestioncof/shared.py +++ b/gestioncof/shared.py @@ -14,7 +14,7 @@ from django.db import connection from django.core.mail import send_mail from django.template import Template, Context -from gestioncof.models import CofProfile, CustomMail +from gestioncof.models import CofProfile User = get_user_model() @@ -99,18 +99,3 @@ def unlock_tables(*models): return row unlock_table = unlock_tables - - -def send_custom_mail(to, shortname, context=None, from_email="cof@ens.fr"): - if context is None: - context = {} - if isinstance(to, DjangoUser): - context["nom"] = to.get_full_name() - context["prenom"] = to.first_name - to = to.email - mail = CustomMail.objects.get(shortname=shortname) - template = Template(mail.content) - message = template.render(Context(context)) - send_mail(mail.title, message, - from_email, [to], - fail_silently=True) diff --git a/gestioncof/templates/petits-cours-mail-demandeur.txt b/gestioncof/templates/petits-cours-mail-demandeur.txt deleted file mode 100644 index 8c20834e..00000000 --- a/gestioncof/templates/petits-cours-mail-demandeur.txt +++ /dev/null @@ -1,17 +0,0 @@ -Bonjour, - -Je vous contacte au sujet de votre annonce passée sur le site du COF pour rentrer en contact avec un élève normalien pour des cours particuliers. Voici les coordonnées d'élèves qui sont motivés par de tels cours et correspondent aux critères que vous nous aviez transmis : - -{% for matiere, proposed in proposals %}¤ {{ matiere }} :{% for user in proposed %} - ¤ {{ user.get_full_name }}{% if user.profile.phone %}, {{ user.profile.phone }}{% endif %}{% if user.email %}, {{ user.email }}{% endif %}{% endfor %} - -{% endfor %}{% if unsatisfied %}Nous n'avons cependant pas pu trouver d'élève disponible pour des cours de {% for matiere in unsatisfied %}{% if forloop.counter0 > 0 %}, {% endif %}{{ matiere }}{% endfor %}. - -{% endif %}Si pour une raison ou une autre ces numéros ne suffisaient pas, n'hésitez pas à répondre à cet e-mail et je vous en ferai parvenir d'autres sans problème. -{% if extra|length > 0 %} -{{ extra|safe }} -{% endif %} -Cordialement, - --- -Le COF, BdE de l'ENS diff --git a/gestioncof/templates/petits-cours-mail-eleve.txt b/gestioncof/templates/petits-cours-mail-eleve.txt deleted file mode 100644 index f75fb33f..00000000 --- a/gestioncof/templates/petits-cours-mail-eleve.txt +++ /dev/null @@ -1,28 +0,0 @@ -Salut, - -Le COF a reçu une demande de petit cours qui te correspond. Tu es en haut de la liste d'attente donc on a transmis tes coordonnées, ainsi que celles de 2 autres qui correspondaient aussi (c'est la vie, on donne les numéros 3 par 3 pour que ce soit plus souple). Voici quelques infos sur l'annonce en question : - -¤ Nom : {{ demande.name }} - -¤ Période : {{ demande.quand }} - -¤ Fréquence : {{ demande.freq }} - -¤ Lieu (si préféré) : {{ demande.lieu }} - -¤ Niveau : {{ demande.get_niveau_display }} - -¤ Remarques diverses (désolé pour les balises HTML) : {{ demande.remarques }} - -{% if matieres|length > 1 %}¤ Matières : -{% for matiere in matieres %} ¤ {{ matiere }} -{% endfor %}{% else %}¤ Matière : {% for matiere in matieres %}{{ matiere }} -{% endfor %}{% endif %} -Voilà, cette personne te contactera peut-être sous peu, tu pourras voir les détails directement avec elle (prix, modalités, ...). Pour indication, 30 Euro/h semble être la moyenne. - -Si tu te rends compte qu'en fait tu ne peux pas/plus donner de cours en ce moment, ça serait cool que tu décoches la case "Recevoir des propositions de petits cours" sur GestioCOF. Ensuite dès que tu voudras réapparaître tu pourras recocher la case et tu seras à nouveau sur la liste. - -À bientôt, - --- -Le COF, pour les petits cours diff --git a/gestioncof/views.py b/gestioncof/views.py index 3bc8c2f9..e086b06c 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -8,6 +8,7 @@ import unicodecsv import uuid from datetime import timedelta from icalendar import Calendar, Event as Vevent +from custommail.utils import send_custom_mail from django.shortcuts import redirect, get_object_or_404, render from django.http import Http404, HttpResponse, HttpResponseForbidden @@ -24,7 +25,6 @@ from gestioncof.models import Event, EventRegistration, EventOption, \ EventOptionChoice from gestioncof.models import EventCommentField, EventCommentValue, \ CalendarSubscription -from gestioncof.shared import send_custom_mail from gestioncof.models import CofProfile, Clipper, Club from gestioncof.decorators import buro_required, cof_required from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \ @@ -438,7 +438,11 @@ def registration(request): # Enregistrement du profil profile = profile_form.save() if profile.is_cof and not was_cof: - send_custom_mail(member, "bienvenue") + send_custom_mail( + member.email, "welcome", + context={'member': member}, + from_email='cof@ens.fr' + ) # Enregistrement des inscriptions aux événements for form in event_formset: if 'status' not in form.cleaned_data: @@ -470,8 +474,12 @@ def registration(request): registration=current_registration).content except EventCommentValue.DoesNotExist: comments = field.default - send_custom_mail(member, "mega", - {"remarques": comments}) + # FIXME : il faut faire quelque chose de propre ici, + # par exemple écrire un mail générique pour + # l'inscription aux événements et/ou donner la + # possibilité d'associer un mail aux événements + # send_custom_mail(member, "mega", + # {"remarques": comments}) # Enregistrement des inscriptions aux clubs member.clubs.clear() for club in clubs_form.cleaned_data['clubs']: diff --git a/requirements.txt b/requirements.txt index f7f6deca..d0d53283 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,8 @@ django-bootstrap-form==3.2.1 asgiref==0.14.0 daphne==0.14.3 asgi-redis==0.14.0 -git+https://github.com/Aureplop/channels.git#egg=channel statistics==1.0.3.5 future==0.15.2 django-widget-tweaks==1.4.1 +git+https://github.com/Aureplop/channels.git#egg=channel +git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_custommail