From: Yoan Le Clanche Date: Tue, 11 Jan 2022 09:22:45 +0000 (+0100) Subject: https://trackers.pilotsystems.net/prebarreau/0336 : change media visibility rules X-Git-Tag: 2.8.1-pro~119^2~2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=009d0a69932aa4a27095d0d6cd0812decec81e02;p=teleforma.git https://trackers.pilotsystems.net/prebarreau/0336 : change media visibility rules --- diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py index b4cf33d0..1a6095a1 100644 --- a/teleforma/context_processors.py +++ b/teleforma/context_processors.py @@ -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: diff --git a/teleforma/models/pro.py b/teleforma/models/pro.py index a10b403e..aa245ffd 100644 --- a/teleforma/models/pro.py +++ b/teleforma/models/pro.py @@ -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 = "" diff --git a/teleforma/templates/teleforma/seminar_detail.html b/teleforma/templates/teleforma/seminar_detail.html index 756590bf..d6d79eae 100644 --- a/teleforma/templates/teleforma/seminar_detail.html +++ b/teleforma/templates/teleforma/seminar_detail.html @@ -170,7 +170,7 @@ {% endwith %} - {% if seminar.conference.webclass and seminar.conference in user.auditor.get.conferences.all %} + {% if show_webclass %} {% with seminar.conference as webclass %}
diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 50f77c34..0fd4cd94 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -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