]> git.parisson.com Git - teleforma.git/commitdiff
add UseForLaw specific form
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 16 Mar 2023 15:19:27 +0000 (16:19 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 16 Mar 2023 15:19:27 +0000 (16:19 +0100)
teleforma/forms.py
teleforma/migrations/0023_auto_20230316_1619.py [new file with mode: 0644]
teleforma/models/crfpa.py
teleforma/urls.py
teleforma/views/crfpa.py

index 4609f2ea3ba926f0de88b868e33476ef78f73168..c459c77be423b15c3c1330293e506556eb0ab21f 100644 (file)
@@ -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 (file)
index 0000000..8863226
--- /dev/null
@@ -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'),
+        ),
+    ]
index 233cb059f8f9c3aba0435001a1d263e0bdcdc972..958e3377569fed5829d8db781e184f689414650f 100755 (executable)
@@ -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'
index 9fe6dbf517cf5fcb9efb86c8cd0fdf537338e89c..83a678a1bf1c03963bbc563a9c5a4dc351c2cadf 100644 (file)
@@ -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<username>.*)/complete/$',
         UserCompleteView.as_view(), name="teleforma-register-complete"),
     url(r'^accounts/register/(?P<username>.*)/download/$',
index d3a9248fa6d49801bbb8a3665ab9c89a510775e4..d02aa4790254e2fead48bc89fad4c8e3408e92d1 100644 (file)
@@ -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'