]> git.parisson.com Git - teleforma.git/commitdiff
Add retractation date
authorYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 18 Mar 2024 10:55:00 +0000 (11:55 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 18 Mar 2024 10:55:00 +0000 (11:55 +0100)
teleforma/forms.py
teleforma/migrations/0028_auto_20240318_1139.py [new file with mode: 0644]
teleforma/models/crfpa.py
teleforma/views/core.py
teleforma/views/crfpa.py

index 9301fb4549e200f70b04e4ec0afd99b04d40ae0d..40c84ec6e517e08d37f82983c1f49a0e7135e91e 100644 (file)
@@ -346,4 +346,11 @@ class RetractationForm(ModelForm):
     class Meta:
         model = Student
         fields = ['stop_retractation']
+
+    def save(self, commit=True):
+        student = super(RetractationForm, self).save(commit=False)
+        student.stop_retractation_date = datetime.now()
+        if commit:
+            student.save()
+        return student
         
\ No newline at end of file
diff --git a/teleforma/migrations/0028_auto_20240318_1139.py b/teleforma/migrations/0028_auto_20240318_1139.py
new file mode 100644 (file)
index 0000000..d9880a4
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.13 on 2024-03-18 11:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('teleforma', '0027_student_stop_retractation'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='student',
+            name='stop_retractation_date',
+            field=models.DateTimeField(blank=True, null=True, verbose_name='Date de renonciation'),
+        ),
+        migrations.AlterField(
+            model_name='student',
+            name='stop_retractation',
+            field=models.BooleanField(default=False, verbose_name='En accédant au contenu de la plateforme, je renonce de ce fait à mon droit de rétractation.'),
+        ),
+    ]
index 58cef3107ddeeec2b87c5692a093d78b3a089008..5b8c3f57881af2d6051414725bffde159aff7049 100644 (file)
@@ -213,6 +213,7 @@ class Student(models.Model):
 
     payment_generated = models.BooleanField(_('échances générées'), default=False)
     stop_retractation = models.BooleanField('En accédant au contenu de la plateforme, je renonce de ce fait à mon droit de rétractation.', default=False)
+    stop_retractation_date = models.DateTimeField('Date de renonciation', blank=True, null=True)
 
     def __str__(self):
         try:
index 7a838f6e242b0556d60732e04f7dc3b633911a6b..dc87aaa6ff5d2ea550742408dc96f5fad87fa70d 100644 (file)
@@ -598,8 +598,6 @@ class CourseView(CourseAccessMixin, DetailView):
     def dispatch(self, *args, **kwargs):
         
         # redirect to a retractation page if the student has paid in the 14 last days
-        print(args)
-        print(kwargs)
         student = None
         # import pdb;pdb.set_trace()
         try:
@@ -611,11 +609,10 @@ class CourseView(CourseAccessMixin, DetailView):
                 two_week_ago = None
                 two_week_ago = datetime.datetime.now() - datetime.timedelta(days=14)
                 old_payments = student.payments.filter(date_paid__lt=two_week_ago).count()
-                print(old_payments)
                 if old_payments:
-                    pass
-                    # student.stop_retractation = True
-                    student.save()
+                    student.stop_retractation = True
+                    student.stop_retractation_date = datetime.datetime.now()
+                    student.save()
                 else:
                     payment_in_retractation_period = student.payments.filter(date_paid__gte=two_week_ago).count()
                     if payment_in_retractation_period:
index 0429e61edfed6415ad8cdfc051e93e3a24ee4802..bb507b67a6c21796c3fc624cc1e8d5bab7e165b5 100644 (file)
@@ -775,19 +775,12 @@ class RetractationView(CourseAccessMixin, DetailView, UpdateView):
     model = Course
     form_class = RetractationForm
     template_name = 'teleforma/retractation.html'
-
-    def get_context_data(self, **kwargs):
-        context = super(RetractationView, self).get_context_data(**kwargs)
-        return context
     
     def get_form_kwargs(self):
         kwargs = super(RetractationView, self).get_form_kwargs()
         kwargs['instance'] = self.request.user.student.get()
         return kwargs
-    
-    def post(self, request, *args, **kwargs):
-        return FormView.post(self, request, *args, **kwargs)
-    
+        
     def get_success_url(self):
         return reverse_lazy('teleforma-desk-period-course', kwargs = {'pk': self.kwargs['pk'], 'period_id': self.kwargs['period_id']})