From: Guillaume Pellerin Date: Mon, 16 Dec 2013 21:41:30 +0000 (+0100) Subject: add seminar copy script, try vertical admin filter X-Git-Tag: 2.8.1-pro~459 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=0bf6c52f1e9a0f8f146824b49ab13cbc6f65d6f3;p=teleforma.git add seminar copy script, try vertical admin filter --- diff --git a/teleforma/admin.py b/teleforma/admin.py index 045edb7c..5a356cb4 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -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 index 00000000..9980780b --- /dev/null +++ b/teleforma/management/commands/teleforma-copy-seminars.py @@ -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)