]> git.parisson.com Git - teleforma.git/commitdiff
Merge branch 'dev' into feature/multi-media-sources
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Sat, 20 Apr 2024 21:32:53 +0000 (23:32 +0200)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Sat, 20 Apr 2024 21:32:53 +0000 (23:32 +0200)
1  2 
teleforma/models/core.py
teleforma/static/teleforma/css/teleforma.css
teleforma/views/core.py

Simple merge
index 3afb45c9681d4c5fa28c9e31aa75f72aa7c07f92,3c697c78d9a5b6e3d2299b44d6b8a0fc63903dfb..53474c8e7aa84bbc4fb82ae45a9b1b4b4d06ab36
@@@ -596,6 -594,28 +594,28 @@@ class CourseView(CourseAccessMixin, Det
  
      @method_decorator(access_required)
      def dispatch(self, *args, **kwargs):
 -        
++
+         # redirect to a retractation page if the student has paid in the 14 last days
+         student = None
+         # import pdb;pdb.set_trace()
+         try:
+             student = self.request.user.student.get()
+         except Student.DoesNotExist:
+             pass
+         if student and student.total_fees and not student.stop_retractation:
+             if student.total_fees:
+                 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()
+                 if old_payments:
+                     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:
+                         return HttpResponseRedirect(reverse('teleforma-desk-period-course-retractation', kwargs={'period_id': kwargs['period_id'], 'pk': kwargs['pk']}))
 -            
++
          return super(CourseView, self).dispatch(*args, **kwargs)
  
      @jsonrpc_method('teleforma.get_course_media_urls')