From: Guillaume Pellerin Date: Tue, 15 Jul 2014 20:44:56 +0000 (+0200) Subject: fix script messages X-Git-Tag: 1.1~431 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ce7fa4ab292e92ea996501ed81322b694fcba37e;p=teleforma.git fix script messages --- diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index cf3e9683..7303ddd4 100644 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -41,7 +41,7 @@ from django.contrib.auth.models import User from django.db.models import Q, Max, Min from django.db.models.signals import post_save from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext, ugettext_lazy as _ from teleforma.models import * from django.template.loader import render_to_string @@ -282,7 +282,8 @@ class Script(BaseResource): def submit(self): self.date_submitted = datetime.datetime.now() - self.url = settings.MEDIA_URL + unicode(self.file) + self.url = 'http://teleforma.parisson.com/media/scripts/2014/06/24/Gstreamer_monitoring_Pipleline.pdf' + # self.url = settings.MEDIA_URL + unicode(self.file) self.box_uuid = crocodoc.document.upload(url=self.url) while True: statuses = crocodoc.document.status([self.box_uuid,]) @@ -301,33 +302,37 @@ class Script(BaseResource): if not self.corrector: self.auto_set_corrector() + self.status = 3 self.save() def mark(self): self.date_marked = datetime.datetime.now() - context = {} + context = {'script': self} text = render_to_string('exam/messages/script_marked.txt', context) - a = _('script') - v = _('marked') - subject = '%s : %s - %s %s' % (unicode(self), a, self.session, v) + a = ugettext('script') + v = ugettext('marked') + subject = '%s %s' % (a, v) mess = Message(sender=self.corrector, recipient=self.author, subject=subject[:119], body=text) mess.moderation_status = 'a' mess.save() - #notify_user(mess, 'acceptance') + site = Site.objects.all()[0] + notify_user(mess, 'acceptance', site) def reject(self): self.date_marked = datetime.datetime.now() self.date_rejected = datetime.datetime.now() - context = {} + context = {'script': self} text = render_to_string('exam/messages/script_rejected.txt', context) - a = _('script') - v = _('rejected') - subject = '%s : %s - %s %s' % (unicode(self), a, self.session, v) + a = ugettext('script') + v = ugettext('rejected') + subject = '%s %s' % (a, v) mess = Message(sender=self.corrector, recipient=self.author, subject=subject[:119], body=text) mess.moderation_status = 'a' mess.save() - #notify_user(mess, 'acceptance') + site = Site.objects.all()[0] + notify_user(mess, 'acceptance', site) + def set_file_properties(sender, instance, **kwargs): if instance.file: diff --git a/teleforma/exam/templates/exam/messages/script_marked.txt b/teleforma/exam/templates/exam/messages/script_marked.txt index 837fad49..422fe15f 100644 --- a/teleforma/exam/templates/exam/messages/script_marked.txt +++ b/teleforma/exam/templates/exam/messages/script_marked.txt @@ -1 +1,14 @@ -marked \ No newline at end of file +{% 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é corrigée. + +La note, les commentaires et les annotations sont disponibles à cette adresse : + +{{ site.domain }}{% url teleforma-exam-script-detail script.period.id script.id %} + +{% 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/exam/templates/exam/messages/script_rejected.txt b/teleforma/exam/templates/exam/messages/script_rejected.txt index 25ce34cf..d34e8d53 100644 --- a/teleforma/exam/templates/exam/messages/script_rejected.txt +++ b/teleforma/exam/templates/exam/messages/script_rejected.txt @@ -1 +1,12 @@ -rejected \ No newline at end of file +{% 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 pour le motif suivant : {{ script.reject_reason }}. + +Veuiller corriger cette erreur puis resoumettre votre copie. + +{% 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/exam/templates/exam/scripts.html b/teleforma/exam/templates/exam/scripts.html index f62357ad..9d4d3fa1 100644 --- a/teleforma/exam/templates/exam/scripts.html +++ b/teleforma/exam/templates/exam/scripts.html @@ -47,9 +47,19 @@ {% endif %} + {% if messages %} +
+ {% for message in messages %} + {{ message }}
+ {% endfor %} + + {% endif %} + {% block answers %}
{{ title }}

+ + {% if object_list %} {% include "exam/inc/script_list.html" %} {% else %} diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 486743ec..7dd8bfb5 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -6,6 +6,7 @@ from teleforma.views.core import * from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.core.urlresolvers import reverse_lazy, reverse +from django.utils.translation import ugettext_lazy as _ class ScriptView(CourseAccessMixin, UpdateView): @@ -123,9 +124,11 @@ class ScriptCreateView(CreateView): def form_valid(self, form): form.instance.author = self.request.user + messages.info(self.request, _("You have successfully submitted your script. It will be processed in the next hours.")) return super(ScriptCreateView, self).form_valid(form) def form_invalid(self, form): + messages.info(self.request, _("There was a problem with your submission. Please try again, later if possible.")) return super(ScriptCreateView, self).form_invalid(form) def get_context_data(self, **kwargs): diff --git a/teleforma/static/teleforma/css/teleforma.css b/teleforma/static/teleforma/css/teleforma.css index 5608a382..8ad5695c 100644 --- a/teleforma/static/teleforma/css/teleforma.css +++ b/teleforma/static/teleforma/css/teleforma.css @@ -1665,3 +1665,51 @@ input,textarea{ .conference_form textarea { font-size: 1.2em; } + + +.info { + margin-top: 0.3em; + color: white; + padding: 0.3em 0.3em 0.5em 0.8em; + background-color: #008000; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; +} + +.success { + margin-top: 1em; + color: white; + padding: 0.3em 0.3em 0.5em 0.8em; + background-color: #008000; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; +} + +.warning { + margin-top: 0.3em; + color: white; + padding: 0.3em 0.3em 0.5em 0.8em; + background-color: #e65911; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; +} + +.error { + color: white; + padding: 0.3em; + background-color: #db4b39; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; +} + +.errorlist { + color: red; +} + +.errorlist li { + font-size: 1.2em; +}