From: Guillaume Pellerin Date: Thu, 16 Mar 2023 15:19:27 +0000 (+0100) Subject: add UseForLaw specific form X-Git-Tag: 2.9.0~71^2~11 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c940b2c01945f6ccf9b1e43da8770633a6a08349;p=teleforma.git add UseForLaw specific form --- diff --git a/teleforma/forms.py b/teleforma/forms.py index 4609f2ea..c459c77b 100644 --- a/teleforma/forms.py +++ b/teleforma/forms.py @@ -177,7 +177,7 @@ class UserForm(ModelForm): user.is_active = False if commit: user.save() - profile = UserProfile(user=user, + self.profile = UserProfile(user=user, address=data['address'], address_detail=data.get('address_detail'), postal_code=data['postal_code'], @@ -219,6 +219,13 @@ class UserForm(ModelForm): return user +class UserUseYourLawForm(UserForm): + + def save(self, commit=True): + super(UserSourceForm, self).__save__(*args, **kwargs) + self.profile.source = "UseYourLaw" + + class CorrectorForm(ModelForm): # profile address = CharField(label=_('Address'), max_length=255) diff --git a/teleforma/migrations/0023_auto_20230316_1619.py b/teleforma/migrations/0023_auto_20230316_1619.py new file mode 100644 index 00000000..88632266 --- /dev/null +++ b/teleforma/migrations/0023_auto_20230316_1619.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.13 on 2023-03-16 16:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('teleforma', '0022_conference_notified_live'), + ] + + operations = [ + migrations.AddField( + model_name='profile', + name='source', + field=models.CharField(blank=True, max_length=32, null=True, verbose_name='Source'), + ), + migrations.AlterField( + model_name='conference', + name='notified_live', + field=models.BooleanField(default=False, verbose_name='Notifié live'), + ), + ] diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index 233cb059..958e3377 100755 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -470,6 +470,8 @@ class Profile(models.Model): max_length=15, blank=True, null=True) siret = models.CharField('Siret', max_length=14, blank=True, null=True) + source = models.CharField('Source', + max_length=32, blank=True, null=True) class Meta(MetaCore): db_table = app_label + '_' + 'profiles' diff --git a/teleforma/urls.py b/teleforma/urls.py index 9fe6dbf5..83a678a1 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -65,7 +65,8 @@ from .views.crfpa import (AnnalsCourseView, AnnalsIEJView, AnnalsView, ReceiptPDFViewDownload, RegistrationPDFView, RegistrationPDFViewDownload, UserAddView, UserCompleteView, UserLoginView, UsersExportView, - UsersView, WriteView, update_training) + UsersView, WriteView, update_training, + UserAddUseYourLawView) from .views.payment import (PaymentStartView, bank_auto, bank_cancel, bank_fail, bank_success) @@ -89,6 +90,8 @@ urlpatterns = [ # (r'^accounts/register0/$', RegistrationView.as_view(), {'form_class':CustomRegistrationForm}), url(r'^accounts/register/$', UserAddView.as_view(), name="teleforma-register"), + url(r'^accounts/register/uyl/$', UserAddUseYourLawView.as_view(), + name="teleforma-register-uyl"), url(r'^accounts/register/(?P.*)/complete/$', UserCompleteView.as_view(), name="teleforma-register-complete"), url(r'^accounts/register/(?P.*)/download/$', diff --git a/teleforma/views/crfpa.py b/teleforma/views/crfpa.py index d3a9248f..d02aa479 100644 --- a/teleforma/views/crfpa.py +++ b/teleforma/views/crfpa.py @@ -61,7 +61,7 @@ from django.conf import settings from ..decorators import access_required from ..forms import (CorrectorForm, NewsItemForm, UserForm, WriteForm, - get_unique_username) + get_unique_username, UserUseYourLawForm) from ..models.core import Course, CourseType, Document, NamePaginator, Period from ..models.crfpa import (IEJ, Discount, NewsItem, Parameters, Payback, Payment, Profile, Student, Training, months_choices, payment_choices) @@ -747,6 +747,15 @@ class UserAddView(CreateView): def get_success_url(self): return reverse_lazy('teleforma-register-complete', kwargs={'username':self.object.username}) + +class UserAddUseYourLawView(UserAddView): + + model = User + template_name = 'registration/registration_form.html' + form_class = UserUseYourLawForm + + + class UserCompleteView(TemplateView): template_name = 'registration/registration_complete.html'