]> git.parisson.com Git - teleforma.git/commitdiff
fix rooms vs. context (add TELEFORMA_PERIOD_TWEETER)
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 11 Jul 2013 23:18:28 +0000 (01:18 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 11 Jul 2013 23:18:28 +0000 (01:18 +0200)
example/settings.py
teleforma/templates/teleforma/course_detail.html
teleforma/views/core.py

index 8d8194f3880c272249fae773dd399f8c5eb76d15..6ef819925e6b53b235ac6cbc9cef7cf6971d74a8 100644 (file)
@@ -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
index d6c9440980a04396fea2188bb13dedae0927eb65..cbb412055eea964c43b24cc9a871d5ff0e4595f4 100644 (file)
@@ -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
index 8f25d69bd1f87a42bf68924f0c60f726acd5ebc3..ab87082304ae371119c6305e606cb5f5c15b31e1 100644 (file)
@@ -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()