]> git.parisson.com Git - teleforma.git/commitdiff
add account init email script
authoryomguy <yomguy@parisson.com>
Sun, 8 Jul 2012 13:37:39 +0000 (15:37 +0200)
committeryomguy <yomguy@parisson.com>
Sun, 8 Jul 2012 13:37:39 +0000 (15:37 +0200)
teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py [new file with mode: 0644]
teleforma/models.py
teleforma/templates/postman/archives.html
teleforma/templates/postman/email_user_init.txt [new file with mode: 0644]
teleforma/templates/postman/email_user_subject_init.txt [new file with mode: 0644]
teleforma/templates/teleforma/inc/document_list.html

diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py
new file mode 100644 (file)
index 0000000..431d827
--- /dev/null
@@ -0,0 +1,40 @@
+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.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 telemeta.models import *
+from telemeta.util.unaccent import unaccent
+from teleforma.models import *
+import logging
+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'
+
+    def init_password_email(self, user):
+        site = Site.objects.get_current()
+        ctx_dict = {'site': site, 'organization': settings.TELEMETA_ORGANIZATION, 'usr': user}
+        subject = render_to_string(subject_template, ctx_dict)
+        subject = ''.join(subject.splitlines())
+        message = render_to_string(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()
+        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)
+
index 569bb22f8c0369ffaedca819b2bd56bbe40ba5b9..e7311a679306e8c271c53e7945a7ead8caa09493 100755 (executable)
@@ -523,7 +523,7 @@ class Profile(models.Model):
     language        = CharField(_('Language'), max_length=255, blank=True)
     telephone       = CharField(_('Telephone'), max_length=255, blank=True)
     expiration_date = DateField(_('Expiration_date'), blank=True, null=True)
-    init_password   = BooleanField(_('Password initialization'))
+    init_password   = BooleanField(_('Password initialized'))
 
     class Meta:
         db_table = app_label + '_' + 'profiles'
index ab3d94a2bc6dd3706dacff30acf07c4b4b5612ff..219600a15b93fc87e458e90f3d40a6a7897f3c2a 100644 (file)
@@ -5,4 +5,4 @@
 {% block pm_undelete_button %}{% endblock %}
 {% block pm_footer_info %}
 <p>{% trans "Messages in this folder will never be removed. You can use this folder for long term storage." %}</p>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/teleforma/templates/postman/email_user_init.txt b/teleforma/templates/postman/email_user_init.txt
new file mode 100644 (file)
index 0000000..cbfd4f5
--- /dev/null
@@ -0,0 +1,19 @@
+{% 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.
+
+http://{{ site.name }}/account/reset_password
+
+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).
+
+Ainsi, vous composerez sur la première note de synthèse dès le samedi 21 juillet et sur les épreuves juridiques les lundi 23 et mardi 24 juillet.
+
+Votre emploi du temps vous sera communiqué vers le 16 juillet.
+
+{% trans "Best regards" %},
+{% trans "The site administrator" %} {% trans "of" %} {% 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
new file mode 100644 (file)
index 0000000..152eb26
--- /dev/null
@@ -0,0 +1 @@
+{% load i18n %}{% autoescape off %}{% blocktrans with site.name as sitename %}Initialization of your account for {{ organization }} on the site {{ sitename }}{% endblocktrans %}{% endautoescape %}
\ No newline at end of file
index 2a6224b2f34d8d569eed3cc091d8b2140976ee15..52b920114b7b9436025fee3d12e5443941351e2b 100644 (file)
         {% for document in course.document.all|from_course_type:type|from_doc_type:doc_type %}
         <tr>
         <td {% if forloop.counter0 == 0 %}class="border-top"{% endif %} width="60%">{% if document.file %}<a href="{% url teleforma-document-view document.id %}" target="_blank" title="{% trans "View" %}"><img src="{{ STATIC_URL }}/teleforma/images/application-msword.png" style="vertical-align:middle" alt="" />{% endif %} {{ document.title }}{% if document.file %}</a>{% endif %}</td>
-        <!--<td align="center">
-        {% if document.is_annal %}
-          <img src="images/ok.png" alt="yes" style="vertical-align:middle" />&nbsp;
-        {% endif %}
-        </td>-->
-        <td {% if forloop.counter0 == 0 %}class="border-top"{% endif %} width="35%">{{ document.date_added }}</td>
+        <td {% if forloop.counter0 == 0 %}class="border-top"{% endif %} width="35%">{{ document.date_modified }}</td>
         <td {% if forloop.counter0 == 0 %}class="border-top"{% endif %} width="5%" align="center">{% if document.file %}<a href="{% url teleforma-document-download document.id %}"><img src="{{ STATIC_URL }}teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
         </tr>
     {% endfor %}
@@ -35,5 +30,4 @@
   <p>{% trans "No document" %}</p>
 </div>
 
-
-{% endif %}
\ No newline at end of file
+{% endif %}