From 7669b1db7957b1f8d20d2c8bfa1522f956d6371b Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 23 Jul 2014 01:13:13 +0200 Subject: [PATCH] add script fix message --- .../templates/exam/messages/script_fix.txt | 14 ++++++++ .../commands/teleforma-exam-message-bug.py | 33 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 teleforma/exam/templates/exam/messages/script_fix.txt create mode 100644 teleforma/management/commands/teleforma-exam-message-bug.py diff --git a/teleforma/exam/templates/exam/messages/script_fix.txt b/teleforma/exam/templates/exam/messages/script_fix.txt new file mode 100644 index 00000000..6c33ef62 --- /dev/null +++ b/teleforma/exam/templates/exam/messages/script_fix.txt @@ -0,0 +1,14 @@ +{% load i18n %}{% load telemeta_utils %}{% load teleforma_tags %}{% autoescape off %}Bonjour, + +Votre copie soumise le {{ script.date_created }} en {{ script.course }} pour la séance {{ script.session }} a été rejetée par erreur. + +Merci de re-soumettre votre copie dès que possible. L'ancienne sera effacée. + +Veuillez accepter toutes nos excuses pour ce problème technique. + +{% trans "Best regards" %}, +{% trans "The site administrator" %} {% trans "of the" %} {% organization %} + + +{% blocktrans %}Note: This message is issued by an automated system. +Do not reply, this would not be taken into account.{% endblocktrans %}{% endautoescape %} diff --git a/teleforma/management/commands/teleforma-exam-message-bug.py b/teleforma/management/commands/teleforma-exam-message-bug.py new file mode 100644 index 00000000..081aeff3 --- /dev/null +++ b/teleforma/management/commands/teleforma-exam-message-bug.py @@ -0,0 +1,33 @@ + +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from django.template.defaultfilters import slugify +from telemeta.models import * +from telemeta.util.unaccent import unaccent +from teleforma.exam.models import * +import logging +import codecs +import time, os + + +class Command(BaseCommand): + help = "Send a message" + + def handle(self, *args, **options): + sender = User.objects.get(id=0) + site = Site.objects.all()[0] + subject = 'Erreur dans la transmission de votre copie' + scripts = Script.objects.filter(file='scripts/2014/07/22/home') + print scripts.count() + + for script in scripts: + context = {'script': self, 'site': site} + text = render_to_string('exam/messages/script_fix.txt', context) + print text + mess = Message(sender=sender, recipient=script.author, subject=subject[:119], body=text) + mess.moderation_status = 'a' + #mess.save() + #notify_user(mess, 'acceptance', site) + -- 2.39.5