]> git.parisson.com Git - teleforma.git/commitdiff
https://trackers.pilotsystems.net/prebarreau/0336 : change media visibility rules
authorYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 11 Jan 2022 09:22:45 +0000 (10:22 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 11 Jan 2022 09:22:45 +0000 (10:22 +0100)
teleforma/context_processors.py
teleforma/models/pro.py
teleforma/templates/teleforma/seminar_detail.html
teleforma/views/pro.py

index b4cf33d05518303ba7be4aaad20ede9f70b798ff..1a6095a1643e857df1953295841ebdcaa3ccbfaa 100644 (file)
@@ -63,7 +63,8 @@ def seminar_progress(user, seminar, more=False):
             'step': '5'
         }
     ]
-    if seminar.conference and seminar.conference.webclass and seminar.conference in user.auditor.get().conferences.all():
+
+    if seminar.use_webclass(user):
         objects[1]['obj'] = seminar.conference
     for item in objects:
         
index a10b403e6b5233bdab06dc422cf8e1da8f552ea1..aa245ffdde67b82d064c7c360fc267d928f6fddc 100644 (file)
@@ -176,6 +176,14 @@ class Seminar(ClonableMixin, Displayable, ProductCodeMixin, SuggestionsMixin):
     def suggestions(self):
         return (list(self.suggested_seminars.all())+list(self.suggested_conferences.all()))[:3]
 
+    def use_webclass(self, user):
+        """
+        Should we show the webclass or the media ?
+        If the user subscribe to the conference, then show the webclass
+        If the user subscribe to the seminar and there are no medias, then show the webclass, else show the media.
+        """
+        return self.conference and self.conference.webclass and (self.conference in user.auditor.get().conferences.all() or not self.medias.count())
+
     def clone_to_next_year(self):
         """ copy the seminar for next year """
         log = ""
index 756590bfe96da14e23cf52042fb1af462ad79f9a..d6d79eae2af7c23f10b64d63035347a6de6999fc 100644 (file)
   </div>
   {% endwith %}
 
-  {% if seminar.conference.webclass and seminar.conference in user.auditor.get.conferences.all %}
+  {% if show_webclass %}
     {% with seminar.conference as webclass %}
     <div class="course_content">
       <div class="course_subtitle">
index 50f77c34dc506e20a7e1e009f8fe23afe9980e5c..0fd4cd944f5c3dee9160eff5a9b04b1e6c102392 100644 (file)
@@ -219,7 +219,7 @@ class SeminarView(SeminarAccessMixin, DetailView):
         context = super(SeminarView, self).get_context_data(**kwargs)
         seminar = context['seminar']
         user = self.request.user
-
+        context['show_webclass'] = seminar.use_webclass(user)
         validated = seminar_validated(user, seminar)
         if validated:
             # check if testimonial exists and create it