From 1c8a91b7e073383cc29d31823ace75039828b9ab Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 12 Jul 2013 01:18:28 +0200 Subject: [PATCH] fix rooms vs. context (add TELEFORMA_PERIOD_TWEETER) --- example/settings.py | 4 ++++ .../templates/teleforma/course_detail.html | 12 +++++++++--- teleforma/views/core.py | 19 ++++++++++++------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/example/settings.py b/example/settings.py index 8d8194f3..6ef81992 100644 --- a/example/settings.py +++ b/example/settings.py @@ -156,6 +156,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.i18n", "django.core.context_processors.media", 'django.core.context_processors.static', + "teleforma.context_processors.periods", ) TELEMETA_ORGANIZATION = 'Pre-Barreau - CRFPA' @@ -195,4 +196,7 @@ TELECASTER_MASTER_SERVER = 'angus.parisson.com' # CRFPA or AE or PRO TELEFORMA_E_LEARNING_TYPE = 'CRFPA' TELEFORMA_GLOBAL_TWEETER = False +TELEFORMA_PERIOD_TWEETER = True +JQCHAT_DISPLAY_COUNT = 50 +JQCHAT_DISPLAY_TIME = 48 \ No newline at end of file diff --git a/teleforma/templates/teleforma/course_detail.html b/teleforma/templates/teleforma/course_detail.html index d6c94409..cbb41205 100644 --- a/teleforma/templates/teleforma/course_detail.html +++ b/teleforma/templates/teleforma/course_detail.html @@ -50,9 +50,15 @@ $(document).ready(function(){ {% block chat %} {% if course.title_tweeter %} {% if room %} -{% with "Tweeter"|add:" "|add:course.title_tweeter as title %} -{% include "teleforma/inc/chat_room.html" %} -{% endwith %} + {% if 'site' in room.name %} + {% with "General tweeter" as title %} + {% include "teleforma/inc/chat_room.html" %} + {% endwith %} + {% else %} + {% with "Tweeter"|add:" "|add:course.title_tweeter as title %} + {% include "teleforma/inc/chat_room.html" %} + {% endwith %} + {% endif %} {% endif %} {% endif %} {% endblock chat %} \ No newline at end of file diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 8f25d69b..ab870823 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -120,10 +120,15 @@ def stream_from_file(__file): yield __chunk -def get_room(content_type=None, id=None, name=None): - if settings.TELEFORMA_GLOBAL_TWEETER or 'site' in name or 'monitor' in name: - rooms = jqchat.models.Room.objects.filter(name=name) +def get_room(content_type=None, id=None, name=None, period=None): + if settings.TELEFORMA_GLOBAL_TWEETER: + name = 'site' + + if settings.TELEFORMA_PERIOD_TWEETER and period: + name = period + '-' + name + if settings.TELEFORMA_GLOBAL_TWEETER: + rooms = jqchat.models.Room.objects.filter(name=name) else: rooms = jqchat.models.Room.objects.filter(name=name, content_type=content_type, @@ -217,7 +222,7 @@ class CourseListView(CourseAccessMixin, ListView): def get_context_data(self, **kwargs): context = super(CourseListView, self).get_context_data(**kwargs) context['notes'] = Note.objects.filter(author=self.request.user) - context['room'] = get_room(name='site'+'-'+context['period'].name) + context['room'] = get_room(name='site', period=context['period'].name) context['doc_types'] = DocumentType.objects.all() context['list_view'] = True context['courses'] = sorted(context['all_courses'], key=lambda k: k['date'], reverse=True)[:5] @@ -242,7 +247,7 @@ class CourseView(CourseAccessMixin, DetailView): context['courses'] = courses # context['notes'] = course.notes.all().filter(author=self.request.user) content_type = ContentType.objects.get(app_label="teleforma", model="course") - context['room'] = get_room(name=context['period'].name + '-' + course.code, + context['room'] = get_room(name=course.code, period=context['period'].name, content_type=content_type, id=course.id) context['doc_types'] = DocumentType.objects.all() @@ -269,7 +274,7 @@ class MediaView(CourseAccessMixin, DetailView): context['type'] = media.course_type # context['notes'] = media.notes.all().filter(author=self.request.user) content_type = ContentType.objects.get(app_label="teleforma", model="course") - context['room'] = get_room(name=context['period'].name + '-' + media.course.code, + context['room'] = get_room(name=media.course.code,period=context['period'].name, content_type=content_type, id=media.course.id) @@ -378,7 +383,7 @@ class ConferenceView(CourseAccessMixin, DetailView): context['type'] = conference.course_type # context['notes'] = conference.notes.all().filter(author=self.request.user) content_type = ContentType.objects.get(app_label="teleforma", model="course") - context['room'] = get_room(name=context['period'].name + '-' + conference.course.title, + context['room'] = get_room(name=conference.course.code, period=context['period'].name, content_type=content_type, id=conference.course.id) context['livestreams'] = conference.livestream.all() -- 2.39.5