]> git.parisson.com Git - teleforma.git/commitdiff
add seminar copy script, try vertical admin filter
authorGuillaume Pellerin <yomguy@parisson.com>
Mon, 16 Dec 2013 21:41:30 +0000 (22:41 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Mon, 16 Dec 2013 21:41:30 +0000 (22:41 +0100)
teleforma/admin.py
teleforma/management/commands/teleforma-copy-seminars.py [new file with mode: 0644]

index 045edb7c35a5212575fff4f72ac1077302a12b79..5a356cb4800833c15fe7db92b022599d597250f6 100644 (file)
@@ -19,7 +19,7 @@ class AEStudentProfileInline(admin.StackedInline):
 
 class AuditorProfileInline(admin.StackedInline):
     model = Auditor
-    filter_horizontal = ['seminars', 'conferences']
+    filter_vertical = ['seminars', 'conferences']
 
 class StudentAdmin(admin.ModelAdmin):
     model = Student
diff --git a/teleforma/management/commands/teleforma-copy-seminars.py b/teleforma/management/commands/teleforma-copy-seminars.py
new file mode 100644 (file)
index 0000000..9980780
--- /dev/null
@@ -0,0 +1,41 @@
+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 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 *
+import logging
+import datetime
+
+
+class Command(BaseCommand):
+    help = """Copy some seminars and their content thanks to their expiry date year"""
+    args = ['from_year to_year']
+    language_code = 'fr_FR'
+
+    def handle(self, *args, **kwargs):
+        to_year = int(args[-1])
+        from_year = int(args[-2])
+
+        for seminar in Seminar.objects.all():
+            if seminar.expiry_date.year == from_year:
+                seminar.pk = None
+                seminar.save()
+                seminar.publish_date.replace(year=from_year)
+                seminar.expiry_date.replace(year=to_year)
+                seminar.save()
+                print ("updated:", seminar)
+
+                for question in seminar.question.all():
+                    question.pk = None
+                    question.save()
+                    question.seminar = seminar
+                    question.save()
+                    print ("updated:", question)