From 0cca9f0861af044ef875fbafdf8538db037f17d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Nov 2016 15:39:14 +0100 Subject: [PATCH 01/13] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20django=5Fdebu?= =?UTF-8?q?g=5Ftoolbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cof/settings_dev.py | 1 + cof/urls.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 6747963b..5cb0c826 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -53,6 +53,7 @@ INSTALLED_APPS = ( ) MIDDLEWARE_CLASSES = ( + 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/cof/urls.py b/cof/urls.py index 263fc3a0..f5b507f1 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -1,24 +1,27 @@ # -*- coding: utf-8 -*- +""" +Fichier principal de configuration des urls du projet GestioCOF +""" + from __future__ import division from __future__ import print_function from __future__ import unicode_literals +import autocomplete_light + from django.conf import settings from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin from django.views.generic.base import TemplateView - -import autocomplete_light - from django.contrib.auth import views as django_views from django_cas_ng import views as django_cas_views + from gestioncof import views as gestioncof_views, csv_views from gestioncof.urls import export_patterns, petitcours_patterns, \ surveys_patterns, events_patterns, calendar_patterns, \ clubs_patterns - from gestioncof.autocomplete import autocomplete autocomplete_light.autodiscover() @@ -89,6 +92,13 @@ my_urlpatterns = [ # Si on est en production, MEDIA_ROOT est servi par Apache. # Il faut dire à Django de servir MEDIA_ROOT lui-même en développement. +if settings.DEBUG: + import debug_toolbar + my_urlpatterns += [ + url(r'^__debug__/', + include(debug_toolbar.urls)), + ] + urlpatterns = [ url(r'^gestion/', include(my_urlpatterns)) ] From 41b54cec9e41fb399887cac485ef8d865a5ead4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Nov 2016 15:39:50 +0100 Subject: [PATCH 02/13] Utilisation d'un virtualenv --- provisioning/bootstrap.sh | 14 ++++++++++---- provisioning/prepare_django.sh | 6 +++--- provisioning/supervisor.conf | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index f072e6fc..55c7bacb 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -8,7 +8,7 @@ DBNAME="cof_gestion" DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" # Installation de paquets utiles -apt-get update && apt-get install -y mercurial python-pip python-dev \ +apt-get update && apt-get install -y mercurial python3-pip python3-dev \ libmysqlclient-dev libjpeg-dev git redis-server # Configuration et installation de mysql. Le mot de passe root est le même que @@ -44,6 +44,9 @@ export DBPASSWD="$DBPASSWD" # Permet d'utiliser les utilitaires pythons locaux export PATH="\$PATH:\$HOME/.local/bin" +# Charge le virtualenv +source ~/venv/bin/activate + # On va dans /vagrant où se trouve le code de gestioCOF cd /vagrant EOF @@ -52,8 +55,11 @@ chown vagrant: ~vagrant/.bash_profile # On va dans /vagrant où se trouve gestioCOF cd /vagrant -# Installation des dépendances python -sudo -H -u vagrant pip install --user -r requirements.txt -r requirements-devel.txt +# Installation du virtualenv, on utilise désormais python3 +pip3 install -U pip +pip3 install virtualenv +sudo -H -u vagrant virtualenv ~vagrant/venv -p /usr/bin/python3 +sudo -H -u vagrant ~vagrant/venv/bin/pip install -r requirements.txt -r requirements-devel.txt # Préparation de Django sudo -H -u vagrant DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNAME=$DBNAME DBPASSWD=$DBPASSWD sh provisioning/prepare_django.sh @@ -62,7 +68,7 @@ sudo -H -u vagrant DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNA sudo -H -u vagrant crontab provisioning/cron.dev # On installe Daphne et on demande à supervisor de le lancer -pip install daphne +~vagrant/venv/bin/pip install daphne apt-get install -y supervisor cp /vagrant/provisioning/supervisor.conf /etc/supervisor/conf.d/gestiocof.conf sed "s/{DBUSER}/$DBUSER/" -i /etc/supervisor/conf.d/gestiocof.conf diff --git a/provisioning/prepare_django.sh b/provisioning/prepare_django.sh index 8988e834..f4f8c199 100644 --- a/provisioning/prepare_django.sh +++ b/provisioning/prepare_django.sh @@ -1,5 +1,5 @@ # Doit être lancé par bootstrap.sh -python manage.py migrate -python manage.py loaddata users root bda gestion sites -python manage.py collectstatic --noinput +~/venv/bin/python manage.py migrate +~/venv/bin/python manage.py loaddata users root bda gestion sites +~/venv/bin/python manage.py collectstatic --noinput diff --git a/provisioning/supervisor.conf b/provisioning/supervisor.conf index 4c46b952..fe8b4e56 100644 --- a/provisioning/supervisor.conf +++ b/provisioning/supervisor.conf @@ -1,5 +1,5 @@ [program:worker] -command=/usr/bin/python /vagrant/manage.py runworker +command=/home/vagrant/venv/bin/python /vagrant/manage.py runworker directory=/vagrant/ user=vagrant environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev" @@ -10,7 +10,7 @@ stopasgroup=true redirect_stderr=true [program:interface] -command=/usr/local/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer +command=/home/vagrant/venv/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev" directory=/vagrant/ redirect_stderr=true From d1c6c2151a954a80c1ca156f3895cf9dd70076ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Nov 2016 19:01:30 +0100 Subject: [PATCH 03/13] Ubuntu 16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On passe à ubuntu 16 ce qui permet d'utiliser python3.5 et le paquet python3-venv. Fichier `provisioning/prepare_django.sh` plus propre --- Vagrantfile | 2 +- provisioning/bootstrap.sh | 20 +++++++++----------- provisioning/prepare_django.sh | 8 +++++--- provisioning/supervisor.conf | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index c84c3dd9..e12a45ed 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure(2) do |config| # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. - config.vm.box = "ubuntu/trusty64" + config.vm.box = "ubuntu/xenial64" # On associe le port 80 dans la machine virtuelle avec le port 8080 de notre # ordinateur, et le port 8000 avec le port 8000. diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index 55c7bacb..7c3e1b46 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -8,7 +8,7 @@ DBNAME="cof_gestion" DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" # Installation de paquets utiles -apt-get update && apt-get install -y mercurial python3-pip python3-dev \ +apt-get update && apt-get install -y python3-pip python3-dev python3-venv \ libmysqlclient-dev libjpeg-dev git redis-server # Configuration et installation de mysql. Le mot de passe root est le même que @@ -29,10 +29,10 @@ a2ensite gestiocof a2dissite 000-default service apache2 restart mkdir /var/www/static -chown -R vagrant:www-data /var/www/static +chown -R ubuntu:www-data /var/www/static # Mise en place du .bash_profile pour tout configurer lors du `vagrant ssh` -cat > ~vagrant/.bash_profile <> ~ubuntu/.bashrc < Date: Sun, 6 Nov 2016 19:28:47 +0100 Subject: [PATCH 04/13] typo --- provisioning/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index 7c3e1b46..1b3c39d3 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -66,7 +66,7 @@ sudo -H -u ubuntu DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNAM sudo -H -u ubuntu crontab provisioning/cron.dev # On installe Daphne et on demande à supervisor de le lancer -~ubuntu/venv/bin/pip install daphne +sudo -H -u ubuntu ~ubuntu/venv/bin/pip install daphne apt-get install -y supervisor cp /vagrant/provisioning/supervisor.conf /etc/supervisor/conf.d/gestiocof.conf sed "s/{DBUSER}/$DBUSER/" -i /etc/supervisor/conf.d/gestiocof.conf From 1f1419c5f19b0b0c6e8415d9581b40b68a9a5340 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Tue, 8 Nov 2016 07:34:19 +0100 Subject: [PATCH 05/13] Supprime `render_template` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GestioCOF définit une fonction `render_template` qui permet de calculer l'interpolation d'un gabarit en une chaîne de caractères, par exemple pour l'envoi de mails. Ce patch supprime cette fonction et remplace son utilisation par la fonction `django.template.loader.render_to_string` au comportement identique. --- bda/models.py | 20 +++++++--------- bda/views.py | 6 ++--- gestioncof/petits_cours_views.py | 39 +++++++++++++++----------------- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/bda/models.py b/bda/models.py index 6fb22189..41550507 100644 --- a/bda/models.py +++ b/bda/models.py @@ -11,19 +11,13 @@ from datetime import timedelta from django.contrib.sites.models import Site from django.db import models from django.contrib.auth.models import User -from django.template import loader, Context +from django.template import loader from django.core import mail from django.conf import settings from django.utils import timezone from django.utils.encoding import python_2_unicode_compatible -def render_template(template_name, data): - tmpl = loader.get_template(template_name) - ctxt = Context(data) - return tmpl.render(ctxt) - - @python_2_unicode_compatible class Tirage(models.Model): title = models.CharField("Titre", max_length=300) @@ -117,7 +111,7 @@ class Spectacle(models.Model): mail_object = "%s - %s - %s" % (self.title, self.date_no_seconds(), self.location) for member in members.values(): - mail_body = render_template('mail-rappel.txt', { + mail_body = loader.render_to_string('mail-rappel.txt', { 'name': member[0], 'nb_attr': member[1], 'show': self}) @@ -277,7 +271,7 @@ class SpectacleRevente(models.Model): mails_to_send = [] mail_object = "%s" % (self.attribution.spectacle) for participant in inscrits: - mail_body = render_template('mail-revente.txt', { + mail_body = loader.render_to_string('mail-revente.txt', { 'user': participant.user, 'spectacle': self.attribution.spectacle, 'revente': self, @@ -301,7 +295,7 @@ class SpectacleRevente(models.Model): mails_to_send = [] mail_object = "%s" % (self.attribution.spectacle) for participant in inscrits: - mail_body = render_template('mail-shotgun.txt', { + mail_body = loader.render_to_string('mail-shotgun.txt', { 'user': participant.user, 'spectacle': self.attribution.spectacle, 'domain': Site.objects.get_current(), @@ -337,13 +331,15 @@ class SpectacleRevente(models.Model): 'spectacle': spectacle, } mails.append(mail.EmailMessage( - mail_subject, loader.render_to_string('mail-revente-winner.txt', context), + mail_subject, + loader.render_to_string('mail-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('mail-revente-seller.txt', context), + mail_subject, + loader.render_to_string('mail-revente-seller.txt', context), from_email=settings.MAIL_DATA['revente']['FROM'], to=[seller.user.email], reply_to=[winner.user.email], diff --git a/bda/views.py b/bda/views.py index 8beeb84b..ddc0596e 100644 --- a/bda/views.py +++ b/bda/views.py @@ -27,7 +27,7 @@ from datetime import timedelta from gestioncof.decorators import cof_required, buro_required from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\ - Tirage, render_template, SpectacleRevente + Tirage, SpectacleRevente from bda.algorithm import Algorithm from bda.forms import BaseBdaFormSet, TokenForm, ResellForm, AnnulForm,\ @@ -571,11 +571,11 @@ def send_rappel(request, spectacle_id): # Mails d'exemples fake_member = request.user fake_member.nb_attr = 1 - exemple_mail_1place = render_template('mail-rappel.txt', { + exemple_mail_1place = loader.render_to_string('mail-rappel.txt', { 'member': fake_member, 'show': show}) fake_member.nb_attr = 2 - exemple_mail_2places = render_template('mail-rappel.txt', { + exemple_mail_2places = loader.render_to_string('mail-rappel.txt', { 'member': fake_member, 'show': show}) # Contexte diff --git a/gestioncof/petits_cours_views.py b/gestioncof/petits_cours_views.py index e9fe511e..d49e942f 100644 --- a/gestioncof/petits_cours_views.py +++ b/gestioncof/petits_cours_views.py @@ -14,7 +14,7 @@ from django.contrib.auth.models import User from django.views.generic import ListView from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.template import loader, Context +from django.template import loader from django.conf import settings from django.contrib.auth.decorators import login_required from django.db.models import Min @@ -33,12 +33,6 @@ import base64 import simplejson -def render_template(template_path, data): - tmpl = loader.get_template(template_path) - context = Context(data) - return tmpl.render(context) - - class DemandeListView(ListView): model = PetitCoursDemande template_name = "petits_cours_demandes_list.html" @@ -137,14 +131,14 @@ 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 = render_template("petits-cours-mail-demandeur.txt", - {"proposals": proposals, - "unsatisfied": unsatisfied, - "extra": - '' - }) + mainmail = loader.render_to_string("petits-cours-mail-demandeur.txt", { + "proposals": proposals, + "unsatisfied": unsatisfied, + "extra": + '' + }) return render(request, "traitement_demande_petit_cours.html", {"demande": demande, "unsatisfied": unsatisfied, @@ -163,8 +157,10 @@ def _finalize_traitement(request, demande, proposals, proposed_for, def _generate_eleve_email(demande, proposed_for): proposed_mails = [] for user, matieres in proposed_for: - msg = render_template("petits-cours-mail-eleve.txt", - {"demande": demande, "matieres": matieres}) + msg = loader.render_to_string("petits-cours-mail-eleve.txt", { + "demande": demande, + "matieres": matieres + }) proposed_mails.append((user, msg)) return proposed_mails @@ -278,10 +274,11 @@ def _traitement_post(request, demande): proposals_list = proposals.items() proposed_for = proposed_for.items() proposed_mails = _generate_eleve_email(demande, proposed_for) - mainmail = render_template("petits-cours-mail-demandeur.txt", - {"proposals": proposals_list, - "unsatisfied": unsatisfied, - "extra": extra}) + mainmail = loader.render_to_string("petits-cours-mail-demandeur.txt", { + "proposals": proposals_list, + "unsatisfied": unsatisfied, + "extra": extra, + }) frommail = settings.MAIL_DATA['petits_cours']['FROM'] bccaddress = settings.MAIL_DATA['petits_cours']['BCC'] replyto = settings.MAIL_DATA['petits_cours']['REPLYTO'] From 53a44134929a983403740599cfa73d1504a67178 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Tue, 8 Nov 2016 09:53:54 +0100 Subject: [PATCH 06/13] =?UTF-8?q?D=C3=A9place=20les=20gabarits=20d?= =?UTF-8?q?=E2=80=99email=20du=20bda=20dans=20un=20dossier=20sp=C3=A9cifiq?= =?UTF-8?q?ue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/models.py | 12 ++++++------ .../{mail-rappel.txt => bda/mails/rappel.txt} | 0 .../mails/revente-loser.txt} | 0 .../mails/revente-new.txt} | 0 .../mails/revente-seller.txt} | 0 .../mails/revente-winner.txt} | 0 .../{mail-revente.txt => bda/mails/revente.txt} | 0 .../{mail-shotgun.txt => bda/mails/shotgun.txt} | 0 bda/views.py | 6 +++--- 9 files changed, 9 insertions(+), 9 deletions(-) rename bda/templates/{mail-rappel.txt => bda/mails/rappel.txt} (100%) rename bda/templates/{mail-revente-loser.txt => bda/mails/revente-loser.txt} (100%) rename bda/templates/{mail-revente-new.txt => bda/mails/revente-new.txt} (100%) rename bda/templates/{mail-revente-seller.txt => bda/mails/revente-seller.txt} (100%) rename bda/templates/{mail-revente-winner.txt => bda/mails/revente-winner.txt} (100%) rename bda/templates/{mail-revente.txt => bda/mails/revente.txt} (100%) rename bda/templates/{mail-shotgun.txt => bda/mails/shotgun.txt} (100%) diff --git a/bda/models.py b/bda/models.py index 41550507..5c87be1e 100644 --- a/bda/models.py +++ b/bda/models.py @@ -111,7 +111,7 @@ class Spectacle(models.Model): mail_object = "%s - %s - %s" % (self.title, self.date_no_seconds(), self.location) for member in members.values(): - mail_body = loader.render_to_string('mail-rappel.txt', { + mail_body = loader.render_to_string('bda/mails/rappel.txt', { 'name': member[0], 'nb_attr': member[1], 'show': self}) @@ -271,7 +271,7 @@ class SpectacleRevente(models.Model): mails_to_send = [] mail_object = "%s" % (self.attribution.spectacle) for participant in inscrits: - mail_body = loader.render_to_string('mail-revente.txt', { + mail_body = loader.render_to_string('bda/mails/revente.txt', { 'user': participant.user, 'spectacle': self.attribution.spectacle, 'revente': self, @@ -295,7 +295,7 @@ class SpectacleRevente(models.Model): mails_to_send = [] mail_object = "%s" % (self.attribution.spectacle) for participant in inscrits: - mail_body = loader.render_to_string('mail-shotgun.txt', { + mail_body = loader.render_to_string('bda/mails/shotgun.txt', { 'user': participant.user, 'spectacle': self.attribution.spectacle, 'domain': Site.objects.get_current(), @@ -332,14 +332,14 @@ class SpectacleRevente(models.Model): } mails.append(mail.EmailMessage( mail_subject, - loader.render_to_string('mail-revente-winner.txt', context), + 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('mail-revente-seller.txt', context), + 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], @@ -350,7 +350,7 @@ class SpectacleRevente(models.Model): if inscrit == winner: continue - mail_body = loader.render_to_string('mail-revente-loser.txt', { + mail_body = loader.render_to_string('bda/mails/revente-loser.txt', { 'acheteur': inscrit.user, 'vendeur': seller.user, 'spectacle': spectacle, diff --git a/bda/templates/mail-rappel.txt b/bda/templates/bda/mails/rappel.txt similarity index 100% rename from bda/templates/mail-rappel.txt rename to bda/templates/bda/mails/rappel.txt diff --git a/bda/templates/mail-revente-loser.txt b/bda/templates/bda/mails/revente-loser.txt similarity index 100% rename from bda/templates/mail-revente-loser.txt rename to bda/templates/bda/mails/revente-loser.txt diff --git a/bda/templates/mail-revente-new.txt b/bda/templates/bda/mails/revente-new.txt similarity index 100% rename from bda/templates/mail-revente-new.txt rename to bda/templates/bda/mails/revente-new.txt diff --git a/bda/templates/mail-revente-seller.txt b/bda/templates/bda/mails/revente-seller.txt similarity index 100% rename from bda/templates/mail-revente-seller.txt rename to bda/templates/bda/mails/revente-seller.txt diff --git a/bda/templates/mail-revente-winner.txt b/bda/templates/bda/mails/revente-winner.txt similarity index 100% rename from bda/templates/mail-revente-winner.txt rename to bda/templates/bda/mails/revente-winner.txt diff --git a/bda/templates/mail-revente.txt b/bda/templates/bda/mails/revente.txt similarity index 100% rename from bda/templates/mail-revente.txt rename to bda/templates/bda/mails/revente.txt diff --git a/bda/templates/mail-shotgun.txt b/bda/templates/bda/mails/shotgun.txt similarity index 100% rename from bda/templates/mail-shotgun.txt rename to bda/templates/bda/mails/shotgun.txt diff --git a/bda/views.py b/bda/views.py index ddc0596e..fb183d6c 100644 --- a/bda/views.py +++ b/bda/views.py @@ -305,7 +305,7 @@ def revente(request, tirage_id): revente.seller = participant revente.date = timezone.now() mail_subject = "BdA-Revente : {:s}".format(attribution.spectacle.title) - mail_body = loader.render_to_string('mail-revente-new.txt', { + mail_body = loader.render_to_string('bda/mails/revente-new.txt', { 'vendeur': participant.user, 'spectacle': attribution.spectacle, 'revente': revente, @@ -571,11 +571,11 @@ def send_rappel(request, spectacle_id): # Mails d'exemples fake_member = request.user fake_member.nb_attr = 1 - exemple_mail_1place = loader.render_to_string('mail-rappel.txt', { + 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('mail-rappel.txt', { + exemple_mail_2places = loader.render_to_string('bda/mails/rappel.txt', { 'member': fake_member, 'show': show}) # Contexte From afed3479b0959331a281bffedd1b4810cdbfedf3 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Tue, 8 Nov 2016 10:01:01 +0100 Subject: [PATCH 07/13] Remplace le dernier email en dur par un template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Il restait un unique email (envoyé lors de l’achat d’une place au shotgun) dont le texte est inscrit en dur dans `bda.views`. Pour éviter d’avoir trop de systèmes d’envoi de mails différents, il utilise maintenant une template dans `bda/mails` comme le reste des emails envoyés par l’application bda. --- bda/templates/bda/mails/buy-shotgun.txt | 6 ++++++ bda/views.py | 13 +++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 bda/templates/bda/mails/buy-shotgun.txt diff --git a/bda/templates/bda/mails/buy-shotgun.txt b/bda/templates/bda/mails/buy-shotgun.txt new file mode 100644 index 00000000..d06e0a39 --- /dev/null +++ b/bda/templates/bda/mails/buy-shotgun.txt @@ -0,0 +1,6 @@ +Bonjour {{ vendeur.first_name }} ! + +Je souhaiterais racheter ta place pour {{ spectacle.title }} le {{ spectacle.date_no_seconds }} ({{ 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/views.py b/bda/views.py index fb183d6c..28e8054e 100644 --- a/bda/views.py +++ b/bda/views.py @@ -471,14 +471,11 @@ def buy_revente(request, spectacle_id): revente = random.choice(reventes_shotgun) revente.soldTo = participant revente.save() - mail = """Bonjour ! - -Je souhaiterais racheter ta place pour %s le %s (%s) à %.02f€. -Contacte-moi si tu es toujours intéressé·e ! - -%s (%s)""" % (spectacle.title, spectacle.date_no_seconds(), - spectacle.location, spectacle.price, - request.user.get_full_name(), request.user.email) + mail = loader.render_to_string('bda/mails/buy-shotgun.txt', { + 'spectacle': spectacle, + 'acheteur': request.user, + 'vendeur': revente.seller.user, + }) send_mail("BdA-Revente : %s" % spectacle.title, mail, request.user.email, [revente.seller.user.email], From 567c9a0a6d58c5d542613f4112ec57817739859b Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Tue, 8 Nov 2016 10:24:17 +0100 Subject: [PATCH 08/13] Meilleur affichage des dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configure la localisation (i10n) de Django afin d’afficher un format plus user-friendly par défaut pour les dates (par exemple, afficher "21 septembre 2016 à 15:00" plutôt que "21 septembre 2016 15:00"). Ceci permet d’éliminer les utilisations de `date_no_seconds` pour simplement les remplacer par l’affichage de la date, le format par défaut étant maintenant satisfaisant. Attention : le bon fonctionnement de ceci nécessite de changer les settings afin d’utiliser le module `cof.locale` comme module de localisation (définir `FORMAT_MODULE_PATH = "cof.locale"`). Le module `cof.locale` définit le format d’affichage des dates+heures (`DATETIME_FORMAT`) afin d’incorporer le "à" qui n'est pas présent dans la localisation française de Django. --- bda/models.py | 23 +++++++++------------- bda/templates/bda-attrib.html | 2 +- bda/templates/bda/mails/buy-shotgun.txt | 2 +- bda/templates/bda/mails/rappel.txt | 2 +- bda/templates/bda/mails/revente-winner.txt | 2 +- bda/templates/bda/mails/revente.txt | 2 +- bda/templates/bda/mails/shotgun.txt | 2 +- bda/templates/etat-places.html | 2 +- bda/templates/resume_places.html | 2 +- bda/templates/spectacle_list.html | 2 +- cof/locale/__init__.py | 0 cof/locale/fr/__init__.py | 0 cof/locale/fr/formats.py | 4 ++++ cof/settings_dev.py | 2 ++ 14 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 cof/locale/__init__.py create mode 100644 cof/locale/fr/__init__.py create mode 100644 cof/locale/fr/formats.py diff --git a/bda/models.py b/bda/models.py index 5c87be1e..cb642b4f 100644 --- a/bda/models.py +++ b/bda/models.py @@ -14,7 +14,7 @@ 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 +from django.utils import timezone, formats from django.utils.encoding import python_2_unicode_compatible @@ -28,12 +28,8 @@ class Tirage(models.Model): enable_do_tirage = models.BooleanField("Le tirage peut être lancé", default=False) - def date_no_seconds(self): - return self.fermeture.astimezone(timezone.get_current_timezone()) \ - .strftime('%d %b %Y %H:%M') - def __str__(self): - return "%s - %s" % (self.title, self.date_no_seconds()) + return "%s - %s" % (self.title, formats.localize(timezone.template_localtime(self.fermeture))) @python_2_unicode_compatible @@ -86,13 +82,13 @@ class Spectacle(models.Model): def timestamp(self): return "%d" % calendar.timegm(self.date.utctimetuple()) - def date_no_seconds(self): - return self.date.astimezone(timezone.get_current_timezone()) \ - .strftime('%d %b %Y %H:%M') - def __str__(self): - return "%s - %s, %s, %.02f€" % (self.title, self.date_no_seconds(), - self.location, self.price) + return "%s - %s, %s, %.02f€" % ( + self.title, + formats.localize(timezone.template_localtime(self.date)), + self.location, + self.price + ) def send_rappel(self): # On récupère la liste des participants @@ -108,8 +104,7 @@ class Spectacle(models.Model): members[-1] = ['BdA', 2, 'bda@ens.fr'] # On écrit un mail personnalisé à chaque participant mails_to_send = [] - mail_object = "%s - %s - %s" % (self.title, self.date_no_seconds(), - self.location) + mail_object = str(self) for member in members.values(): mail_body = loader.render_to_string('bda/mails/rappel.txt', { 'name': member[0], diff --git a/bda/templates/bda-attrib.html b/bda/templates/bda-attrib.html index 5c705a79..5c22d2b3 100644 --- a/bda/templates/bda-attrib.html +++ b/bda/templates/bda-attrib.html @@ -22,7 +22,7 @@ {% for show, members, losers in results %}
-

{{ show.title }} - {{ show.date_no_seconds }} @ {{ show.location }}

+

{{ show.title }} - {{ show.date }} @ {{ show.location }}

{{ show.nrequests }} demandes pour {{ show.slots }} places {{ show.price }}€ par place{% if user.profile.is_buro and show.nrequests < show.slots %}, {{ show.deficit }}€ de déficit{% endif %} diff --git a/bda/templates/bda/mails/buy-shotgun.txt b/bda/templates/bda/mails/buy-shotgun.txt index d06e0a39..d7855143 100644 --- a/bda/templates/bda/mails/buy-shotgun.txt +++ b/bda/templates/bda/mails/buy-shotgun.txt @@ -1,6 +1,6 @@ Bonjour {{ vendeur.first_name }} ! -Je souhaiterais racheter ta place pour {{ spectacle.title }} le {{ spectacle.date_no_seconds }} ({{ spectacle.location }}) à {{ spectacle.price|floatformat:2 }}€. +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 index 4759a849..c6433f8a 100644 --- a/bda/templates/bda/mails/rappel.txt +++ b/bda/templates/bda/mails/rappel.txt @@ -1,7 +1,7 @@ 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_no_seconds }} au {{ show.location }}. N'oublie pas de t'y rendre ! +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. diff --git a/bda/templates/bda/mails/revente-winner.txt b/bda/templates/bda/mails/revente-winner.txt index 8ca7236a..01ecfb86 100644 --- a/bda/templates/bda/mails/revente-winner.txt +++ b/bda/templates/bda/mails/revente-winner.txt @@ -1,6 +1,6 @@ Bonjour {{ acheteur.first_name }}, -Tu as été tiré-e au sort pour racheter une place pour {{ spectacle.title }} le {{ spectacle.date_no_seconds }} ({{ spectacle.location }}) à {{ spectacle.price|floatformat:2 }}€. +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, diff --git a/bda/templates/bda/mails/revente.txt b/bda/templates/bda/mails/revente.txt index 899afe3b..397a58d8 100644 --- a/bda/templates/bda/mails/revente.txt +++ b/bda/templates/bda/mails/revente.txt @@ -1,6 +1,6 @@ Bonjour {{ user.first_name }} -Une place pour le spectacle {{ spectacle.title }} ({{ spectacle.date_no_seconds }}) +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 diff --git a/bda/templates/bda/mails/shotgun.txt b/bda/templates/bda/mails/shotgun.txt index 899d5c85..53462fb3 100644 --- a/bda/templates/bda/mails/shotgun.txt +++ b/bda/templates/bda/mails/shotgun.txt @@ -1,6 +1,6 @@ Bonjour {{ user.first_name }} -Une place pour le spectacle {{ spectacle.title }} ({{ spectacle.date_no_seconds }}) +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 diff --git a/bda/templates/etat-places.html b/bda/templates/etat-places.html index ebd15c38..4aa72ba1 100644 --- a/bda/templates/etat-places.html +++ b/bda/templates/etat-places.html @@ -18,7 +18,7 @@ {% for spectacle in spectacles %} {{ spectacle.title }} - {{ spectacle.date_no_seconds }} + {{ spectacle.date }} {{ spectacle.location }} {{ spectacle.slots }} places {{ spectacle.total }} demandes diff --git a/bda/templates/resume_places.html b/bda/templates/resume_places.html index 9ca5c78f..614a1656 100644 --- a/bda/templates/resume_places.html +++ b/bda/templates/resume_places.html @@ -11,7 +11,7 @@ {{place.spectacle.title}} {{place.spectacle.location}} - {{place.spectacle.date_no_seconds}} + {{place.spectacle.date}} {% if place.double %}deux places{%else%}une place{% endif %} {% endfor %} diff --git a/bda/templates/spectacle_list.html b/bda/templates/spectacle_list.html index 816461db..c7456f6e 100644 --- a/bda/templates/spectacle_list.html +++ b/bda/templates/spectacle_list.html @@ -19,7 +19,7 @@ {% for spectacle in object_list %} {{ spectacle.title }} - {{ spectacle.date_no_seconds }} + {{ spectacle.date }} {{ spectacle.location }} {{ spectacle.price |floatformat }}€ diff --git a/cof/locale/__init__.py b/cof/locale/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cof/locale/fr/__init__.py b/cof/locale/fr/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cof/locale/fr/formats.py b/cof/locale/fr/formats.py new file mode 100644 index 00000000..2a926447 --- /dev/null +++ b/cof/locale/fr/formats.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- +from __future__ import unicode_literals + +DATETIME_FORMAT = r'j F Y \à H:i' diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 6747963b..12a58b26 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -202,3 +202,5 @@ def show_toolbar(request): DEBUG_TOOLBAR_CONFIG = { 'SHOW_TOOLBAR_CALLBACK': show_toolbar, } + +FORMAT_MODULE_PATH = 'cof.locale' From 03f7dff813867c37fc42e6d41f243cc958c13550 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Sat, 12 Nov 2016 11:09:40 +0100 Subject: [PATCH 09/13] Garde la locale par defaut dans les management commands --- bda/management/commands/manage_reventes.py | 1 + bda/management/commands/sendrappels.py | 1 + 2 files changed, 2 insertions(+) diff --git a/bda/management/commands/manage_reventes.py b/bda/management/commands/manage_reventes.py index 45b9c91a..a10c1ca5 100644 --- a/bda/management/commands/manage_reventes.py +++ b/bda/management/commands/manage_reventes.py @@ -11,6 +11,7 @@ from bda.models import SpectacleRevente class Command(BaseCommand): help = "Envoie les mails de notification et effectue " \ "les tirages au sort des reventes" + leave_locale_alone = True def handle(self, *args, **options): now = timezone.now() diff --git a/bda/management/commands/sendrappels.py b/bda/management/commands/sendrappels.py index 1e8da240..aa54337b 100644 --- a/bda/management/commands/sendrappels.py +++ b/bda/management/commands/sendrappels.py @@ -11,6 +11,7 @@ from bda.models import Spectacle class Command(BaseCommand): help = 'Envoie les mails de rappel des spectacles dont la date ' \ 'approche.\nNe renvoie pas les mails déjà envoyés.' + leave_locale_alone = True def handle(self, *args, **options): now = timezone.now() From f93b095e0fba71b3d94cb5529e56990ecdbabef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 20 Nov 2016 16:39:26 +0100 Subject: [PATCH 10/13] Styling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ou comment faire plaisir à pylint sur les bouts de code concernés par cette MR --- bda/management/commands/manage_reventes.py | 17 +++-- bda/management/commands/sendrappels.py | 9 ++- bda/models.py | 83 +++++++++++++--------- bda/templates/bda/mails/shotgun.txt | 2 +- cof/locale/fr/formats.py | 5 ++ cof/settings_dev.py | 2 +- 6 files changed, 77 insertions(+), 41 deletions(-) diff --git a/bda/management/commands/manage_reventes.py b/bda/management/commands/manage_reventes.py index a10c1ca5..310bb618 100644 --- a/bda/management/commands/manage_reventes.py +++ b/bda/management/commands/manage_reventes.py @@ -1,14 +1,21 @@ # -*- coding: utf-8 -*- +""" +Gestion en ligne de commande des reventes. +""" + from __future__ import unicode_literals +from datetime import timedelta from django.core.management import BaseCommand from django.utils import timezone -from datetime import timedelta from bda.models import SpectacleRevente class Command(BaseCommand): + """ + Objet `BaseCommand`, cf ``self.help`` pour plus d'informations. + """ help = "Envoie les mails de notification et effectue " \ "les tirages au sort des reventes" leave_locale_alone = True @@ -19,21 +26,21 @@ class Command(BaseCommand): for revente in reventes: # Check si < 24h if (revente.attribution.spectacle.date <= - revente.date + timedelta(days=1)) and \ - now >= revente.date + timedelta(minutes=15) and \ + revente.date + timedelta(days=1)) and \ + now >= revente.date + timedelta(minutes=15) and \ not revente.notif_sent: self.stdout.write(str(now)) revente.mail_shotgun() self.stdout.write("Mail de disponibilité immédiate envoyé") # Check si délai de retrait dépassé elif (now >= revente.date + timedelta(hours=1) and - not revente.notif_sent): + not revente.notif_sent): self.stdout.write(str(now)) revente.send_notif() self.stdout.write("Mail d'inscription à une revente envoyé") # Check si tirage à faire elif (now >= revente.expiration_time and - not revente.tirage_done): + not revente.tirage_done): self.stdout.write(str(now)) revente.tirage() self.stdout.write("Tirage effectué, mails envoyés") diff --git a/bda/management/commands/sendrappels.py b/bda/management/commands/sendrappels.py index aa54337b..3c42170c 100644 --- a/bda/management/commands/sendrappels.py +++ b/bda/management/commands/sendrappels.py @@ -1,14 +1,21 @@ # -*- coding: utf-8 -*- +""" +Gestion en ligne de commande des mails de rappel. +""" + from __future__ import unicode_literals +from datetime import timedelta from django.core.management.base import BaseCommand from django.utils import timezone -from datetime import timedelta from bda.models import Spectacle class Command(BaseCommand): + """ + Objet Command, cf ``self.help`` pour plus d'informations. + """ help = 'Envoie les mails de rappel des spectacles dont la date ' \ 'approche.\nNe renvoie pas les mails déjà envoyés.' leave_locale_alone = True diff --git a/bda/models.py b/bda/models.py index cb642b4f..29e3dccd 100644 --- a/bda/models.py +++ b/bda/models.py @@ -29,7 +29,8 @@ class Tirage(models.Model): default=False) def __str__(self): - return "%s - %s" % (self.title, formats.localize(timezone.template_localtime(self.fermeture))) + return "%s - %s" % (self.title, formats.localize( + timezone.template_localtime(self.fermeture))) @python_2_unicode_compatible @@ -91,6 +92,10 @@ class Spectacle(models.Model): ) def send_rappel(self): + """ + Envoie un mail de rappel à toutes les personnes qui ont une place pour + ce spectacle. + """ # On récupère la liste des participants members = {} for attr in Attribution.objects.filter(spectacle=self).all(): @@ -107,14 +112,14 @@ class Spectacle(models.Model): 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}) + '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']}) + 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() @@ -267,16 +272,16 @@ class SpectacleRevente(models.Model): 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}) + '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']}) + 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() @@ -285,22 +290,26 @@ class SpectacleRevente(models.Model): self.save() def mail_shotgun(self): + """ + Envoie un mail à toutes les personnes intéréssées par le spectacle pour + 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}) + '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']}) + 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() @@ -309,6 +318,11 @@ class SpectacleRevente(models.Model): self.save() def tirage(self): + """ + Lance le tirage au sort associé à la revente. Un gagnant est choisi + parmis les personnes intéressées par le spectacle. Les personnes sont + ensuites prévenues par mail du résultat du tirage. + """ inscrits = list(self.answered_mail.all()) spectacle = self.attribution.spectacle seller = self.seller @@ -327,14 +341,16 @@ class SpectacleRevente(models.Model): } mails.append(mail.EmailMessage( mail_subject, - loader.render_to_string('bda/mails/revente-winner.txt', context), + 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), + 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], @@ -345,11 +361,12 @@ class SpectacleRevente(models.Model): if inscrit == winner: continue - mail_body = loader.render_to_string('bda/mails/revente-loser.txt', { - 'acheteur': inscrit.user, - 'vendeur': seller.user, - 'spectacle': spectacle, - }) + mail_body = loader.render_to_string( + 'bda/mails/revente-loser.txt', + {'acheteur': inscrit.user, + 'vendeur': seller.user, + 'spectacle': spectacle} + ) mails.append(mail.EmailMessage( mail_subject, mail_body, from_email=settings.MAIL_DATA['revente']['FROM'], diff --git a/bda/templates/bda/mails/shotgun.txt b/bda/templates/bda/mails/shotgun.txt index 53462fb3..69bc704c 100644 --- a/bda/templates/bda/mails/shotgun.txt +++ b/bda/templates/bda/mails/shotgun.txt @@ -4,7 +4,7 @@ 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'addresse +cette place : elle est disponible immédiatement à l'adresse http://{{ domain }}{% url "bda-buy-revente" spectacle.id %}, à la disposition de tous. Chaleureusement, diff --git a/cof/locale/fr/formats.py b/cof/locale/fr/formats.py index 2a926447..879d5ab8 100644 --- a/cof/locale/fr/formats.py +++ b/cof/locale/fr/formats.py @@ -1,4 +1,9 @@ # -*- encoding: utf-8 -*- + +""" +Formats français. +""" + from __future__ import unicode_literals DATETIME_FORMAT = r'j F Y \à H:i' diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 12a58b26..0650eed4 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -45,7 +45,7 @@ INSTALLED_APPS = ( 'autocomplete_light', 'captcha', 'django_cas_ng', - 'debug_toolbar', +# 'debug_toolbar', 'bootstrapform', 'kfet', 'channels', From debc10213e0818bc28144ea66d4d5c3c2ab11439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 20 Nov 2016 16:52:07 +0100 Subject: [PATCH 11/13] Typo + docstrings inutiles --- bda/management/commands/manage_reventes.py | 3 --- bda/management/commands/sendrappels.py | 3 --- cof/settings_dev.py | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bda/management/commands/manage_reventes.py b/bda/management/commands/manage_reventes.py index 310bb618..4b90bc57 100644 --- a/bda/management/commands/manage_reventes.py +++ b/bda/management/commands/manage_reventes.py @@ -13,9 +13,6 @@ from bda.models import SpectacleRevente class Command(BaseCommand): - """ - Objet `BaseCommand`, cf ``self.help`` pour plus d'informations. - """ help = "Envoie les mails de notification et effectue " \ "les tirages au sort des reventes" leave_locale_alone = True diff --git a/bda/management/commands/sendrappels.py b/bda/management/commands/sendrappels.py index 3c42170c..88cf9d5c 100644 --- a/bda/management/commands/sendrappels.py +++ b/bda/management/commands/sendrappels.py @@ -13,9 +13,6 @@ from bda.models import Spectacle class Command(BaseCommand): - """ - Objet Command, cf ``self.help`` pour plus d'informations. - """ help = 'Envoie les mails de rappel des spectacles dont la date ' \ 'approche.\nNe renvoie pas les mails déjà envoyés.' leave_locale_alone = True diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 0650eed4..12a58b26 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -45,7 +45,7 @@ INSTALLED_APPS = ( 'autocomplete_light', 'captcha', 'django_cas_ng', -# 'debug_toolbar', + 'debug_toolbar', 'bootstrapform', 'kfet', 'channels', From 9a9ff69f5560386e30ffee244b37f202a14676c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 20 Nov 2016 18:42:47 +0100 Subject: [PATCH 12/13] Ajoute le jour en toutes lettres dans les dates --- cof/locale/fr/formats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cof/locale/fr/formats.py b/cof/locale/fr/formats.py index 879d5ab8..710fa6ed 100644 --- a/cof/locale/fr/formats.py +++ b/cof/locale/fr/formats.py @@ -6,4 +6,4 @@ Formats français. from __future__ import unicode_literals -DATETIME_FORMAT = r'j F Y \à H:i' +DATETIME_FORMAT = r'l j F Y \à H:i' From 4249524842d657a04e39bfdeb1d2c395ae2a74c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 21 Nov 2016 01:26:56 +0100 Subject: [PATCH 13/13] Typo vagrant -> ubuntu --- provisioning/supervisor.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provisioning/supervisor.conf b/provisioning/supervisor.conf index 41e75fbd..c806a13d 100644 --- a/provisioning/supervisor.conf +++ b/provisioning/supervisor.conf @@ -1,5 +1,5 @@ [program:worker] -command=/home/vagrant/venv/bin/python /vagrant/manage.py runworker +command=/home/ubuntu/venv/bin/python /vagrant/manage.py runworker directory=/vagrant/ user=ubuntu environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev" @@ -10,7 +10,7 @@ stopasgroup=true redirect_stderr=true [program:interface] -command=/home/vagrant/venv/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer +command=/home/ubuntu/venv/bin/daphne -b 127.0.0.1 -p 8001 cof.asgi:channel_layer environment=DBUSER={DBUSER},DBNAME={DBNAME},DBPASSWD={DBPASSWD},DJANGO_SETTINGS_MODULE="cof.settings_dev" directory=/vagrant/ redirect_stderr=true