]> git.parisson.com Git - teleforma.git/commitdiff
Not displaying link to register to a closed webclass
authorGael Le Mignot <gael@pilotsystems.net>
Tue, 10 Aug 2021 08:38:42 +0000 (10:38 +0200)
committerGael Le Mignot <gael@pilotsystems.net>
Tue, 10 Aug 2021 08:38:42 +0000 (10:38 +0200)
teleforma/templates/teleforma/course_detail.html
teleforma/views/core.py
teleforma/webclass/models.py

index 77ce22841cda936aece893d763935e27b20004cb..5a53a301731b6d6c77b26f93fb67c21a735d8a86 100644 (file)
@@ -14,7 +14,7 @@
 
 <div class="desk_center">
 
-  {% if webclass and not webclass_slot %}
+  {% if webclass and not webclass_slot and webclass_not_over %}
   <div class="block important">
     <p>
       <strong>Vous n'êtes pas inscrit à la webclass de cette matière. </strong><a
index 3a3624f0442e5cbed016d721c7b4757ed79e89dc..9cfd3a77c7d240bc98df1654cd92d79c07d99c5c 100644 (file)
@@ -386,6 +386,8 @@ class CourseListView(CourseAccessMixin, ListView):
                     continue
                 if not student.platform_only and not webclass.allow_presentiel:
                     continue
+                if not webclass.is_not_over():
+                    continue
                 slot = webclass.get_slot(user)
                 if slot and slot.status in ('almost', 'ingoing'):
                     slots.append(slot)
@@ -491,6 +493,7 @@ class CourseView(CourseAccessMixin, DetailView):
                     webclass_slot = webclass.get_slot(self.request.user)
         context['webclass'] = webclass
         context['webclass_slot'] = webclass_slot
+        context['webclass_not_over'] = webclass.is_not_over()
 
         try:
             context['webclass_records'] = WebclassRecord.get_records(
index a4f3ba4089582f3232d480534e5318908a24ec2a..3a9281b64d7c297cb196ba546c038fc5e0d26b92 100644 (file)
@@ -168,6 +168,14 @@ class Webclass(models.Model):
         except WebclassSlot.DoesNotExist:
             return None
 
+    def is_not_over(self):
+        """
+        Check if the webclass is not over yet
+        """
+        if self.end_date and self.end_date < datetime.date.today():
+            return False
+        return True
+        
 
 class SlotPublishedManager(models.Manager):
     def get_query_set(self):