From 9da8bc855fe5b1aaa69835a56d9d51b67f7e61bd Mon Sep 17 00:00:00 2001 From: yomguy Date: Mon, 9 Jul 2012 12:03:10 +0200 Subject: [PATCH] fix doc double display, trans, init account script --- example/settings.py | 4 ++- teleforma/locale/fr/LC_MESSAGES/django.mo | Bin 5388 -> 5555 bytes teleforma/locale/fr/LC_MESSAGES/django.po | 28 +++++++++--------- ...teleforma-reset-all-passwords-with-mail.py | 25 +++++++++------- .../templates/postman/email_user_init.txt | 16 ++++++++-- .../postman/email_user_subject_init.txt | 2 +- teleforma/templates/teleforma/courses.html | 4 ++- .../teleforma/inc/document_list.html | 16 ++++++---- .../templates/telemeta/profile_detail.html | 2 +- 9 files changed, 61 insertions(+), 36 deletions(-) diff --git a/example/settings.py b/example/settings.py index a58db1fa..c2a1d270 100644 --- a/example/settings.py +++ b/example/settings.py @@ -176,7 +176,7 @@ LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = reverse_lazy('teleforma-desk') SESSION_EXPIRE_AT_BROWSER_CLOSE = False -EMAIL_HOST = 'smtp.numericable.fr' +EMAIL_HOST = 'smtp.free.fr' DEFAULT_FROM_EMAIL = 'webmaster@parisson.com' SERVER_EMAIL = 'webmaster@parisson.com' EMAIL_SUBJECT_PREFIX = '[' + TELEMETA_ORGANIZATION.decode('utf8') + '] ' @@ -184,3 +184,5 @@ EMAIL_SUBJECT_PREFIX = '[' + TELEMETA_ORGANIZATION.decode('utf8') + '] ' POSTMAN_AUTO_MODERATE_AS = True #FILE_PROTECTION_METHOD = 'xsendfile' + +GOOGLE_ANALYTICS_MODEL = True diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index 821c24d4bff62767e0a9fc4dd9fec29b1634a2f2..84e72829e7dbd5e146bbe5e55c1e801794e9b55c 100644 GIT binary patch delta 2607 zcmZvdTTI+V6o;okK`t!|rM4i_l`368s@N;E(n7Te7R8E+6_M3lag|HMu3C9;qmss| zDM`0BS|8976N@$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pOD!X{~xXX$9(_* diff --git a/teleforma/locale/fr/LC_MESSAGES/django.po b/teleforma/locale/fr/LC_MESSAGES/django.po index ff6e7697..8cac4497 100644 --- a/teleforma/locale/fr/LC_MESSAGES/django.po +++ b/teleforma/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-07-08 15:43+0200\n" +"POT-Creation-Date: 2012-07-09 11:47+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -266,7 +266,7 @@ msgstr "Date d'expiration" #: models.py:526 msgid "Password initialized" -msgstr "" +msgstr "Mot de passe initialisé" #: models.py:530 msgid "profile" @@ -445,7 +445,7 @@ msgid "Thank you again for your interest in our services." msgstr "" #: templates/postman/email_user.txt:20 -#: templates/postman/email_user_init.txt:16 +#: templates/postman/email_user_init.txt:25 #: templates/postman/email_visitor.txt:16 msgid "The site administrator" msgstr "" @@ -455,18 +455,18 @@ msgid "of" msgstr "de" #: templates/postman/email_user.txt:22 -#: templates/postman/email_user_init.txt:18 +#: templates/postman/email_user_init.txt:28 #: templates/postman/email_visitor.txt:18 msgid "" "Note: This message is issued by an automated system.\n" "Do not reply, this would not be taken into account." msgstr "" -#: templates/postman/email_user_init.txt:15 +#: templates/postman/email_user_init.txt:24 msgid "Best regards" -msgstr "" +msgstr "Cordialement" -#: templates/postman/email_user_init.txt:16 +#: templates/postman/email_user_init.txt:25 msgid "of the" msgstr "du" @@ -478,8 +478,8 @@ msgstr "" #: templates/postman/email_user_subject_init.txt:1 #, python-format -msgid "Initialization of your e-learning account at %(organization)s" -msgstr "Initialisation de votre compte e-learning du %(organization)s" +msgid "%(organization)s : initialization of your e-learning account" +msgstr "%(organization)s : initialisation de votre compte e-learning" #: templates/postman/email_visitor.txt:1 msgid "Dear visitor," @@ -640,17 +640,17 @@ msgid "Live conferences" msgstr "Conférences en direct" #: templates/teleforma/inc/conference_list.html:15 -#: templates/teleforma/inc/document_list.html:17 +#: templates/teleforma/inc/document_list.html:20 #: templates/teleforma/inc/media_list.html:14 msgid "View" msgstr "" -#: templates/teleforma/inc/document_list.html:19 +#: templates/teleforma/inc/document_list.html:22 #: templates/teleforma/inc/media_list.html:17 msgid "Download" msgstr "Télécharger" -#: templates/teleforma/inc/document_list.html:30 +#: templates/teleforma/inc/document_list.html:36 msgid "No document" msgstr "Aucun document" @@ -867,8 +867,8 @@ msgid "Login as" msgstr "Se connecter en tant que" #: templates/telemeta/profile_detail.html:107 -msgid "Password reinitialization" -msgstr "" +msgid "Password reset" +msgstr "Réinitialisation du mot de passe" #: templates/telemeta/search_criteria.html:5 #: templates/telemeta/search_criteria.html:76 diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py index 431d8273..17f5cbbb 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py @@ -6,6 +6,8 @@ from django.contrib.auth.forms import PasswordResetForm from django.contrib.auth.tokens import default_token_generator from django.template.defaultfilters import slugify from django.template.loader import render_to_string +from django.core.mail import send_mail, mail_admins +from django.utils import translation from telemeta.models import * from telemeta.util.unaccent import unaccent from teleforma.models import * @@ -15,26 +17,29 @@ from postman import * class Command(BaseCommand): help = "Reset the password for all (active) users " - message_template = 'postman/email_user_init.html' - subject_template = 'postman/email_user_subject_init.html' + message_template = 'postman/email_user_init.txt' + subject_template = 'postman/email_user_subject_init.txt' + language_code = 'fr_FR' - def init_password_email(self, user): + def init_password_email(self, user, profile): site = Site.objects.get_current() ctx_dict = {'site': site, 'organization': settings.TELEMETA_ORGANIZATION, 'usr': user} - subject = render_to_string(subject_template, ctx_dict) + subject = render_to_string(self.subject_template, ctx_dict) subject = ''.join(subject.splitlines()) - message = render_to_string(message_template, ctx_dict) + message = render_to_string(self.message_template, ctx_dict) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email], fail_silently=False) - profile = user.get_profile() profile.init_password = True profile.save() - mail_admins(subject, message) def handle(self, *args, **options): # users = User.objects.all() + translation.activate(self.language_code) users = User.objects.filter(is_staff=True) for user in users: - profile = user.get_profile() - if not profile.init_password and user.is_active: - self.init_password_email(user) + profile = Profile.objects.get(user=user) + if profile: + profile.init_password = False + if not profile.init_password and user.is_active: + self.init_password_email(user, profile) + print user.username diff --git a/teleforma/templates/postman/email_user_init.txt b/teleforma/templates/postman/email_user_init.txt index 6889e7a8..e73d5cd3 100644 --- a/teleforma/templates/postman/email_user_init.txt +++ b/teleforma/templates/postman/email_user_init.txt @@ -1,10 +1,18 @@ {% load i18n %}{% load telemeta_utils %}{% load teleforma_tags %}{% autoescape off %}{% trans "Hello" %} {{ usr.first_name }} {{ usr.last_name }}, -Suite à votre inscription à la formation estivale 2012 du Pré-Barreau, vous trouverez ci-dessous un lien vous invitant à choisir votre mot de passe à la plateforme e-learning. +Suite à votre inscription à la formation estivale 2012 du Pré-Barreau, nous vous invitons à initialiser votre compte sur notre plateforme e-learning interactive et multi-média. Pour cela, merci de cliquer sur le lien suivant puis d'indiquez votre adresse e-mail : -http://{{ site.name }}/account/reset_password +http://{{ site.name }}/accounts/password_reset/ + +Vous recevrez alors un second e-mail vous invitant à initialiser votre mot de passe personnel. +Une fois la procédure accomplie, vous pourrez vous connecter à l'adresse suivante : + +http://{{ site.name }} + +à l'aide de votre nom d'utilisateur : {{ usr.username }} + +Cette plateforme vous permet d’accéder tout au long de votre formation aux différents documents - fascicules de cours (selon la formule choisie), fascicules d’actualisation, sujets et corrigés - ainsi qu’à l’ensemble de vos enseignements à la demande ou en direct. La messagerie intégrée vous donne aussi la possibilité de communiquer avec les administrateurs et les professeurs. Une page d'aide sera bientôt disponible pour vous assister lors de la découverte de ces nouveaux services. -Cette plateforme vous permettra d’accéder tout au long de votre formation aux différents documents - fascicules de cours (selon la formule choisie), fascicules d’actualisation, sujets et corrigés - ainsi qu’à l’ensemble de vos enseignements. La messagerie intégrée vous permet de communiquer avec les administrateurs, les utilisateurs et le corps enseignant. Une page d'aide est également disponible pour vous assister lors de la découverte de ces nouveaux services. Nous vous rappelons que votre formation commencera le vendredi 20 juillet 2012 par une séance de méthodologie à la note de synthèse (2h) et aux épreuves juridiques (2h). @@ -12,8 +20,10 @@ Ainsi, vous composerez sur la première note de synthèse dès le samedi 21 juil Votre emploi du temps vous sera communiqué vers le 16 juillet. + {% 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/templates/postman/email_user_subject_init.txt b/teleforma/templates/postman/email_user_subject_init.txt index 928d5ede..967e8aa7 100644 --- a/teleforma/templates/postman/email_user_subject_init.txt +++ b/teleforma/templates/postman/email_user_subject_init.txt @@ -1 +1 @@ -{% load i18n %}{% autoescape off %}{% blocktrans %}Initialization of your e-learning account at {{ organization }}{% endblocktrans %}{% endautoescape %} \ No newline at end of file +{% load i18n %}{% autoescape off %}{% blocktrans %}{{ organization }} : initialization of your e-learning account{% endblocktrans %}{% endautoescape %} \ No newline at end of file diff --git a/teleforma/templates/teleforma/courses.html b/teleforma/templates/teleforma/courses.html index b0bc35f6..79864415 100644 --- a/teleforma/templates/teleforma/courses.html +++ b/teleforma/templates/teleforma/courses.html @@ -71,7 +71,9 @@ $(document).ready(function(){ {% endblock %} {% block document %} - {% include "teleforma/inc/document_list.html" %} + {% with forloop.counter as type_counter %} + {% include "teleforma/inc/document_list.html" %} + {% endwith %} {% endblock %} diff --git a/teleforma/templates/teleforma/inc/document_list.html b/teleforma/templates/teleforma/inc/document_list.html index 52b92011..65affcc4 100644 --- a/teleforma/templates/teleforma/inc/document_list.html +++ b/teleforma/templates/teleforma/inc/document_list.html @@ -7,22 +7,28 @@

{% trans "Documents"%}

+{% with course.document.all as docs %} {% for doc_type in doc_types %} -{% if course.document.all|from_course_type:type|from_doc_type:doc_type %} +{% if docs|from_course_type:type|from_doc_type:doc_type and not type_counter > 1 %} {{ doc_type }} - {% for document in course.document.all|from_course_type:type|from_doc_type:doc_type %} + {% for doc in docs|from_course_type:type|from_doc_type:doc_type %} + {% if doc.course_type.all|length > 1 and type_counter > 1 %} + {% else %} - - - + + + + {% endif %} {% endfor %}
{% if document.file %}{% endif %} {{ document.title }}{% if document.file %}{% endif %}{{ document.date_modified }}{% if document.file %}{% endif %}{% if doc.file %}{% endif %} {{ doc.title }}{% if doc.file %}{% endif %}{{ doc.date_modified }}{% if doc.file %}{% endif %}
{% endif %} {% endfor %} +{% endwith %} + {% else %} diff --git a/teleforma/templates/telemeta/profile_detail.html b/teleforma/templates/telemeta/profile_detail.html index fb0d4484..905d6986 100644 --- a/teleforma/templates/telemeta/profile_detail.html +++ b/teleforma/templates/telemeta/profile_detail.html @@ -104,7 +104,7 @@
{% if user.username != usr.username and user.is_staff %} - + {% endif %}
-- 2.39.5