From c53cca44d0ba788c3b7274ce1bfeb82fe06a329d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 8 Feb 2015 22:15:41 +0100 Subject: [PATCH] Add student registration form --- example/settings.py | 1 + setup.py | 1 + teleforma/admin.py | 6 +- teleforma/forms.py | 54 ++++- teleforma/locale/fr/LC_MESSAGES/django.mo | Bin 12077 -> 12217 bytes teleforma/locale/fr/LC_MESSAGES/django.po | 281 +++++++++++++++++++--- teleforma/models/crfpa.py | 27 ++- teleforma/urls.py | 5 + teleforma/views/crfpa.py | 27 +++ 9 files changed, 350 insertions(+), 52 deletions(-) diff --git a/example/settings.py b/example/settings.py index 4bf70dd8..2d178816 100644 --- a/example/settings.py +++ b/example/settings.py @@ -148,6 +148,7 @@ INSTALLED_APPS = ( # 'follow', 'googletools', # 'telecaster', + 'extra_views', ) TEMPLATE_CONTEXT_PROCESSORS = ( diff --git a/setup.py b/setup.py index 86a22f51..b5ee84ae 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ setup( 'django-jqchat', 'django-googletools', 'crocodoc', + 'django-extra-views', ], platforms=['OS Independent'], license='CeCILL v2', diff --git a/teleforma/admin.py b/teleforma/admin.py index 3b026cc1..c007b324 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -16,13 +16,13 @@ class AEStudentProfileInline(admin.StackedInline): filter_horizontal = ['courses'] extra = 1 -class StudentPaymentInline(admin.StackedInline): - model = Payment +# class StudentPaymentInline(admin.StackedInline): +# model = Payment class StudentAdmin(admin.ModelAdmin): model = Student exclude = ['options'] - inlines = [StudentPaymentInline] + # inlines = [StudentPaymentInline] class ProfessorProfileInline(admin.StackedInline): model = Professor diff --git a/teleforma/forms.py b/teleforma/forms.py index 89ec4910..312a27a7 100644 --- a/teleforma/forms.py +++ b/teleforma/forms.py @@ -1,13 +1,65 @@ from django.forms import ModelForm from teleforma.models import * +from registration.forms import RegistrationForm +from django.utils.translation import ugettext_lazy as _ +from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet class ConferenceForm(ModelForm): - class Meta: model = Conference +class UserForm(ModelForm): + # first_name = forms.CharField(_('First name'), required=True) + # last_name = forms.CharField(_('Last name'), required=True) + + class Meta: + model = User + fields = ['last_name', 'first_name', 'email', ] + +RegistrationForm.base_fields.update(UserForm.base_fields) + + +class ProfileForm(ModelForm): + class Meta: + model = Profile + exclude = ['user', 'wifi_login', 'wifi_pass', 'language', 'expiration_date', + 'init_password', ] + +RegistrationForm.base_fields.update(ProfileForm.base_fields) + + +class StudentForm(ModelForm): + class Meta: + model = Student + exclude = ['user', 'trainings', 'options'] + +RegistrationForm.base_fields.update(StudentForm.base_fields) + + +class CustomRegistrationForm(RegistrationForm): + + def save(self, profile_callback=None): + user = super(CustomRegistrationForm, self).save(profile_callback=None) + profile, c = Profile.objects.get_or_create(user=user, \ + address=self.cleaned_data['address'], \ + telephone=self.cleaned_data['telephone']) + + + +class ProfileInline(InlineFormSet): + + model = Profile + can_delete = False + exclude = ['user', 'wifi_login', 'wifi_pass', 'language', 'expiration_date', + 'init_password', ] + + +class StudentInline(InlineFormSet): + model = Student + can_delete = False + exclude = ['user', 'trainings', 'options'] diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index d2ac9bc3898cedc478a0d3c15ecdf80c9178c569..da2cf3f250826cb24ee605fa288eeefb55247f30 100644 GIT binary patch delta 5402 zcmYM%33yFs9>?(`2_Zp7!U!F5B?vN!popbHp9GoIUPWtZ$R*K8G>N5JZj~8>SZ_@i ziD{LowNnYEOf?y)WvX;WZ8Mfu)iz^q(RP++zQ23^>73{J<@28RyyxA{xw*;q@p~rt zE<}c`aX225pOF)xj+0r-aY`ao>o^}YcAPNWgZ1!Z?2X5;HHJ5FuP0*^=e>|FoFP~T zN15ZT-ix)VpN917bBZX`r(&MD6hk{fO{|;51}UZIjY@x)WDbR z{06GOZ&3^R9(8}nPj$b~aUvF&aY~`NH(B$VkfG< z{g{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RA|QQ?ZPJ1 zM9Qtc!mLDXaTRLChfotcjhfgw48u#P9c(}?@P^e#rF-o=nO%JpwB>2o2K%E{Fa*`X zU3NYm)$vpeyv^n!)W^3FwZ)~l5Z^>CC_Te76E(q`Q4`NaEzmcbf(9CEPDjo7Nz}@U zP!0X44oXn(%r=~i6{xT4uwLG~G68kp5p09is7HI&>g!PxX!PoRu2paE6EB zUZ|b9#m(|;S|&gXQKvMfO?cmuq_r@{YF$jTQMAWq87XtppLho zI;_wI+-tszx}h31z$vRghx`rV>g@XePzwm^<2`~H)I<`nHKv;BsD65*Pg~KSLVLUm zHN$+=gvO(`_EFR`oP&Bq%gvRjc17k3sApe}TEKSHKvk%I-a*}e7&W0|eb|59P;Cu9 zLQSC78rIqQm#BfRpgQ~kb)U=h1`0z>FdB6|4K-jUYU>ADeI9B@?nR9=F_Zn*Or}zy zt$z&F(IO1IM5uu`Vg#0UpT-wrLuyDbItRey9; ztnaFwrQ;}al#C#oNXzjz3KPg5$tza*2x{(!$ThN+G?K~W9ird3I!ei}Nx4oq_LCZ- zzxr3{PXHbB$*_s<`vX<{g=FrP zW2P7BL-KdBi|{`scPCj)9wRz#@^ESRCo6-`E#l`s@;)gecM}~0$QOi9g!`26mu=wq z-ps~cL~q?6$Ru(HX*t?cI7alxVJi72xt-|f;o;8dQElgBv{ihDgUC3tnJgsz$ZJH$ zVDeO;$vRR?q5d;H Lv#K)Fp9}jx#nbJV diff --git a/teleforma/locale/fr/LC_MESSAGES/django.po b/teleforma/locale/fr/LC_MESSAGES/django.po index 177112a7..af92cb2d 100644 --- a/teleforma/locale/fr/LC_MESSAGES/django.po +++ b/teleforma/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-01-29 23:28+0100\n" +"POT-Creation-Date: 2015-02-08 22:15+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Guillaume Pellerin \n" "Language-Team: LANGUAGE \n" @@ -99,7 +99,7 @@ msgstr "correcteur" msgid "period" msgstr "période" -#: exam/models.py:123 models/crfpa.py:174 +#: exam/models.py:123 msgid "value" msgstr "valeur" @@ -124,8 +124,7 @@ msgstr "" msgid "date added" msgstr "date d'ajout" -#: exam/models.py:171 models/core.py:160 models/core.py:463 -#: models/crfpa.py:177 models/pro.py:68 +#: exam/models.py:171 models/core.py:160 models/core.py:463 models/pro.py:68 msgid "date modified" msgstr "date de modification" @@ -254,19 +253,19 @@ msgstr "Copie" msgid "Scripts" msgstr "Copies" -#: exam/views.py:84 +#: exam/views.py:85 msgid "Pending scripts" msgstr "Copies en attente" -#: exam/views.py:101 +#: exam/views.py:102 msgid "Treated scripts" msgstr "Copie traitées" -#: exam/views.py:116 +#: exam/views.py:117 msgid "Rejected scripts" msgstr "Copies rejetées" -#: exam/views.py:129 +#: exam/views.py:130 msgid "" "You have successfully submitted your script. It will be processed in the " "next hours." @@ -274,7 +273,7 @@ msgstr "" "Vous avez correctement soumis votre copie. Elle sera traitée dans les " "prochaines heures puis corrigée." -#: exam/views.py:133 +#: exam/views.py:134 msgid "" "There was a problem with your submission. Please try again, later if " "possible." @@ -713,20 +712,6 @@ msgstr "" msgid "profile" msgstr "profil" -#: models/crfpa.py:173 -#, fuzzy -msgid "student" -msgstr "Etudiant AE" - -#: models/crfpa.py:175 -msgid "month" -msgstr "" - -#: models/crfpa.py:176 -#, fuzzy -msgid "date created" -msgstr "date de rejet" - #: models/pro.py:47 msgid "price" msgstr "prix" @@ -1058,6 +1043,226 @@ msgstr "" msgid "Write" msgstr "" +#: templates/registration/activate.html:3 +#: templates/registration/activation_complete.html:3 +#, fuzzy +msgid "Activation complete" +msgstr "incomplet" + +#: templates/registration/activate.html:3 +msgid "Activation problem" +msgstr "" + +#: templates/registration/activate.html:7 +#, python-format +msgid "" +"\n" +"Thanks %(account)s, activation complete!\n" +"You may now login using the username and " +"password you set at registration.\n" +msgstr "" + +#: templates/registration/activate.html:12 +msgid "" +"Oops – it seems that your activation key is invalid. Please check the " +"url again." +msgstr "" + +#: templates/registration/activation_complete.html:6 +#, python-format +msgid "" +"\n" +"Thanks, activation complete! You may now login using the username and password you set " +"at registration.\n" +msgstr "" + +#: templates/registration/activation_email.html:8 +#, python-format +msgid "" +"\n" +"

Account registration for %(sitename)s

\n" +"

\n" +"You (or someone pretending to be you) have asked to register an account at\n" +"%(sitename)s.
\n" +"If this wasn't you, please ignore this email and your address will be " +"removed\n" +"from our records.\n" +"

\n" +"

\n" +"To activate this account, please click the following link within the next \n" +"%(expiration_days)s days:
\n" +"http://%(sitedomain)s" +"%(activation_key_url)s\n" +"

\n" +"

\n" +"Sincerely,
\n" +"%(sitename)s Management\n" +"

\n" +"\n" +msgstr "" + +#: templates/registration/activation_email.txt:3 +#, python-format +msgid "" +"\n" +"You (or someone pretending to be you) have asked to register an account at\n" +"%(sitename)s. If this wasn't you, please ignore this email\n" +"and your address will be removed from our records.\n" +"\n" +"To activate this account, please click the following link within the next \n" +"%(expiration_days)s days:\n" +"\n" +"http://%(siteurl)s%(activation_key_url)s\n" +"\n" +"Sincerely,\n" +"%(sitename)s Management\n" +msgstr "" + +#: templates/registration/activation_email_subject.txt:1 +#, python-format +msgid "Account registration for %(sitename)s" +msgstr "" + +#: templates/registration/login.html:3 +#, fuzzy +msgid "Login" +msgstr "Se connecter en tant que" + +#: templates/registration/login.html:9 templates/telemeta/login.html:19 +msgid "Your username and password didn't match. Please try again." +msgstr "" + +#: templates/registration/login.html:23 +#, python-format +msgid "" +"Forgot your password?\n" +" Need an account?" +msgstr "" + +#: templates/registration/login.html:26 +#, fuzzy +msgid "login" +msgstr "Se connecter en tant que" + +#: templates/registration/logout.html:3 +msgid "Logged out" +msgstr "" + +#: templates/registration/logout.html:5 +msgid "Successfully logged out!" +msgstr "" + +#: templates/registration/password_change_done.html:3 +#, fuzzy +msgid "Password changed" +msgstr "Mot de passe initialisé" + +#: templates/registration/password_change_done.html:5 +msgid "Password successfully changed!" +msgstr "" + +#: templates/registration/password_change_form.html:3 +#: templates/registration/password_change_form.html:8 +#: templates/telemeta/profile_detail.html:49 +msgid "Change password" +msgstr "" + +#: templates/registration/password_reset_complete.html:3 +#, fuzzy +msgid "Password reset complete" +msgstr "Réinitialisation du mot de passe" + +#: templates/registration/password_reset_complete.html:4 +#, python-format +msgid "" +"\n" +"Your password has been reset! You may now log in.\n" +msgstr "" + +#: templates/registration/password_reset_confirm.html:3 +#, fuzzy +msgid "Confirm password reset" +msgstr "Réinitialisation du mot de passe" + +#: templates/registration/password_reset_confirm.html:5 +msgid "Enter your new password below to reset your password:" +msgstr "" + +#: templates/registration/password_reset_confirm.html:9 +msgid "Set password" +msgstr "" + +#: templates/registration/password_reset_done.html:3 +#: templates/telemeta/profile_detail.html:106 +msgid "Password reset" +msgstr "Réinitialisation du mot de passe" + +#: templates/registration/password_reset_done.html:6 +msgid "" +"We have sent you an email with a link to reset your password.\n" +"Please check your email and click the link to continue." +msgstr "" + +#: templates/registration/password_reset_email.html:1 +msgid "Greetings" +msgstr "" + +#: templates/registration/password_reset_email.html:3 +#, python-format +msgid "" +"You are receiving this email because you (or someone pretending to be you)\n" +"requested that your password be reset on the %(domain)s site. If you do " +"not \n" +"wish to reset your password, please ignore this message.\n" +"\n" +"To reset your password, please click the following link, or copy and paste " +"it\n" +"into your web browser:" +msgstr "" + +#: templates/registration/password_reset_email.html:12 +#, python-format +msgid "" +"\n" +"Your username, in case you've forgotten: %(username)s\n" +"\n" +"Best regards,\n" +"%(site_name)s Management\n" +msgstr "" + +#: templates/registration/password_reset_form.html:3 +#: templates/registration/password_reset_form.html:10 +msgid "Reset password" +msgstr "" + +#: templates/registration/password_reset_form.html:4 +msgid "" +"\n" +"Forgot your password? Enter your email in the form below and we'll send " +"you\n" +"instructions for creating a new one." +msgstr "" + +#: templates/registration/registration_complete.html:3 +msgid "Activation email sent" +msgstr "" + +#: templates/registration/registration_complete.html:5 +msgid "" +"An activation email has been sent.\n" +"Please check your email and click on the link to activate your account." +msgstr "" + +#: templates/registration/registration_form.html:4 +msgid "Registration" +msgstr "Inscription" + +#: templates/registration/registration_form.html:20 +msgid "Save and download the registration form" +msgstr "Enregistrer et télécharger le formulaire" + #: templates/teleforma/annals.html:6 templates/teleforma/annals.html.py:54 #: templates/telemeta/base.html:112 msgid "Annals" @@ -1354,10 +1559,6 @@ msgstr "Sonore" msgid "deleted" msgstr "" -#: templates/telemeta/login.html:19 -msgid "Your username and password didn't match. Please try again." -msgstr "" - #: templates/telemeta/login.html:29 msgid "Password forgotten" msgstr "" @@ -1382,10 +1583,6 @@ msgstr "Envoyer un message" msgid "User profile" msgstr "Profil utilisateur" -#: templates/telemeta/profile_detail.html:49 -msgid "Change password" -msgstr "" - #: templates/telemeta/profile_detail.html:51 msgid "Login as" msgstr "Se connecter en tant que" @@ -1452,10 +1649,6 @@ msgstr "" msgid "Apply" msgstr "" -#: templates/telemeta/profile_detail.html:106 -msgid "Password reset" -msgstr "Réinitialisation du mot de passe" - #: templates/telemeta/search_criteria.html:5 #: templates/telemeta/search_criteria.html:76 msgid "Advanced Search" @@ -1546,6 +1739,24 @@ msgstr "" msgid "A new live conference has started : " msgstr "Une nouvelle conférence en direct a commencé : " +#: views/crfpa.py:374 +msgid "You have successfully register your account." +msgstr "" + +#~ msgid "First name" +#~ msgstr "Prénom" + +#~ msgid "Last name" +#~ msgstr "Nom" + +#, fuzzy +#~ msgid "student" +#~ msgstr "Etudiant AE" + +#, fuzzy +#~ msgid "date created" +#~ msgstr "date de rejet" + #~ msgid "CRFPA Profile" #~ msgstr "Profil CRFPA" diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index ab92e382..e9c06f0f 100644 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -168,17 +168,18 @@ months_choices = [] for i in range(1,13): months_choices.append((i, _(datetime.date(2015, i, 1).strftime('%B')))) -class Payment(models.Model): - "a payment from a student" - - student = models.ForeignKey(Student, related_name='payments', verbose_name=_('student')) - value = models.FloatField(_('value')) - month = models.IntegerField(_('month'), choices=months_choices, default=1) - date_created = models.DateTimeField(_('date created'), auto_now_add=True) - date_modified = models.DateTimeField(_('date modified'), auto_now=True) - - class Meta: - db_table = app_label + '_' + 'payments' - verbose_name = "Payment" - verbose_name_plural = "Payments" + +# class Payment(models.Model): +# "a payment from a student" + +# student = models.ForeignKey(Student, related_name='payments', verbose_name=_('student')) +# value = models.FloatField(_('value')) +# month = models.IntegerField(_('month'), choices=months_choices, default=1) +# date_created = models.DateTimeField(_('date created'), auto_now_add=True) +# date_modified = models.DateTimeField(_('date modified'), auto_now=True) + +# class Meta: +# db_table = app_label + '_' + 'payments' +# verbose_name = "Payment" +# verbose_name_plural = "Payments" diff --git a/teleforma/urls.py b/teleforma/urls.py index b495b6ad..389e644f 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -39,6 +39,8 @@ from django.views.generic.base import * from teleforma.models import * from teleforma.views import * from telemeta.views import * +from teleforma.forms import * +from registration.views import * from jsonrpc import jsonrpc_site htdocs_forma = os.path.dirname(__file__) + '/static/teleforma/' @@ -118,4 +120,7 @@ urlpatterns = patterns('', # EXAM url(r'^', include('teleforma.exam.urls')), + + (r'^accounts/register0/$', RegistrationView.as_view(), {'form_class':CustomRegistrationForm}), + (r'^accounts/register/$', UserAddView.as_view()), ) diff --git a/teleforma/views/crfpa.py b/teleforma/views/crfpa.py index c17f3ecb..fb202442 100644 --- a/teleforma/views/crfpa.py +++ b/teleforma/views/crfpa.py @@ -34,6 +34,9 @@ from teleforma.views.core import * +from registration.views import * +from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet +from django.utils.translation import ugettext_lazy as _ def get_course_code(obj): @@ -349,3 +352,27 @@ class AnnalsCourseView(AnnalsView): return self.get_docs(course=self.course) +def get_unique_username(first_name, last_name): + username = slugify(first_name)[0] + '.' + slugify(last_name) + username = username[:30] + i = 1 + while User.objects.filter(username=username[:30]): + username = slugify(first_name)[:i] + '.' + slugify(last_name) + i += 1 + return username[:30] + + +class UserAddView(CreateWithInlinesView): + + model = User + template_name = 'registration/registration_form.html' + form_class = UserForm + inlines = [ProfileInline, StudentInline] + success_url = '/' + + def forms_valid(self, form, inlines): + messages.info(self.request, _("You have successfully register your account.")) + user = form.save() + user.username = get_unique_username(user.first_name, user.last_name) + user.save() + return super(UserAddView, self).forms_valid(form, inlines) -- 2.39.5