]> git.parisson.com Git - teleforma.git/commitdiff
add seminar doc templates
authoryomguy <yomguy@parisson.com>
Mon, 26 Nov 2012 22:20:06 +0000 (23:20 +0100)
committeryomguy <yomguy@parisson.com>
Mon, 26 Nov 2012 22:20:06 +0000 (23:20 +0100)
teleforma/models/core.py
teleforma/models/pro.py
teleforma/templates/teleforma/inc/document_simple_list.html [new file with mode: 0644]
teleforma/templates/teleforma/inc/media_package_list.html [new file with mode: 0644]
teleforma/templates/teleforma/inc/question_list.html [new file with mode: 0644]
teleforma/templates/teleforma/seminar_detail.html
teleforma/templates/teleforma/seminars.html
teleforma/urls.py
teleforma/views/pro.py

index 3eb718bb812fa369734f4259654d851b117e76dd..eed12aaa9ff3faf3f12bf5c396f98c2ce9440f35 100644 (file)
@@ -454,7 +454,7 @@ class DocumentSimple(MediaBase):
     readers         = ManyToManyField(User, related_name="document_simple", verbose_name=_('readers'),
                                         blank=True, null=True)
     rank            = models.IntegerField(_('rank'), blank=True, null=True)
-    
+
     def is_image(self):
         is_url_image = False
         if self.url:
@@ -477,7 +477,7 @@ class DocumentSimple(MediaBase):
 
     class Meta(MetaCore):
         db_table = app_label + '_' + 'document_simple'
-        ordering = ['-date_added']
+        ordering = ['rank']
 
 
 
index 68a385c81f93bb0aab2b5428017b10d628f36d7d..bea2fbcea509a65b6c40bd02304ffb3d406ed9ca 100644 (file)
@@ -126,15 +126,27 @@ class Seminar(models.Model):
     def __unicode__(self):
         return ' - '.join([self.course.title, str(self.rank), self.title])
 
+    @property
+    def scenario(self):
+        self.steps = []
+        self.steps.append(self.doc_1)
+        self.steps.append(self.media)
+        self.steps.append(self.doc_2)
+        self.steps.append(self.question)
+        self.steps.append(self.doc_correct)
+        self.steps.append(self.testimonial)
+        return self.steps
+        
     class Meta(MetaCore):
         db_table = app_label + '_' + 'seminar'
         verbose_name = _('Seminar')
+        ordering = ['rank']
 
 
 class Question(models.Model):
 
     element_type = 'question'
-    
+
     seminar     = models.ForeignKey(Seminar, related_name="question", verbose_name=_('seminar'))
     title       = models.CharField(_('title'), max_length=255, blank=True)
     description = models.CharField(_('description'), max_length=1024, blank=True)
@@ -218,24 +230,6 @@ class Evaluation(models.Model):
         verbose_name = _('Evaluation')
 
 
-class SeminarScenario1():
-
-    def __init__(self, seminar):
-        self.seminar = seminar
-        self.steps = []
-
-        self.append(self.seminar.doc_1)
-        self.append(self.seminar.media)
-        self.append(self.seminar.doc_2)
-        self.append(self.seminar.question)
-        self.append(self.seminar.doc_correct)
-        self.steps.append(self.seminar.evaluation.all()[0])
-        self.append(self.seminar.testimonial)
-        
-    def append(self, models):
-        for mod in models.all().order_by('rank'):
-            self.steps.append(mod)
-
 
 class Auditor(models.Model):
 
diff --git a/teleforma/templates/teleforma/inc/document_simple_list.html b/teleforma/templates/teleforma/inc/document_simple_list.html
new file mode 100644 (file)
index 0000000..c289271
--- /dev/null
@@ -0,0 +1,25 @@
+{% load teleforma_tags %}
+{% load i18n %}
+
+<div class="course_content">
+
+<div class="course_subtitle">
+<h3><img src="{{ STATIC_URL }}/telemeta/images/item_title.png" width="10px" alt="" /> {% trans "Documents"%}</h3>
+</div>
+
+
+<span class="doc_type_title">{{ doc_type }}</span>
+<table class="listing" width="100%">
+    <tbody>
+        {% for doc in docs %}
+            <tr>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="60%">{% if doc.file %}<a href="{% url teleforma-document-view doc.id %}" target="_blank" title="{% trans "View" %}"><img src="{{ STATIC_URL }}/teleforma/images/application-msword.png" style="vertical-align:middle" alt="" />{% endif %} {{ doc.title }}{% if doc.file %}</a>{% endif %}</td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="35%">{{ doc.date_modified }}</td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="5%" align="center">{% if doc.file %}<a href="{% url teleforma-document-download doc.id %}"><img src="{{ STATIC_URL }}teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
+            </tr>
+        {% endfor %}
+    </tbody>
+</table>
+
+</div>
+
diff --git a/teleforma/templates/teleforma/inc/media_package_list.html b/teleforma/templates/teleforma/inc/media_package_list.html
new file mode 100644 (file)
index 0000000..57840dc
--- /dev/null
@@ -0,0 +1,51 @@
+{% load teleforma_tags %}
+{% load i18n %}
+
+{% with course.conference.all|from_course_type:type as conferences %}
+{% if conferences %}
+<div class="course_content">
+<div class="course_subtitle">
+    <h3><img src="{{ STATIC_URL }}telemeta/images/item_title.png" width="10px" alt="" /> {% trans "Live conferences"%}</h3>
+</div>
+    <table class="listing" width="100%">
+    <tbody>
+       {% for conference in conferences|from_periods:periods %}
+        {% for stream in conference.livestream.all %}
+         {% if stream.stream_type == 'webm' %}
+            <tr>
+            {% if stream.streaming %}
+            <td {% if forloop.first %}class="border-top"{% endif %} width="230px">
+               <a href="{% url teleforma-conference-detail stream.conference.id %}" title="{% trans "View" %}">
+               <img id="snapshot-{{ stream.course.code }}-{{ stream.course_type }}" src="{{ stream.snapshot_url }}" width="100%" alt="{% trans 'Click here' %}" />
+               </a>
+            </td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="60%" style="padding-left: 1em;">
+                <div>
+                    <dl class="listing" style="font-size: 1.2em;">
+                    <dt>{% trans "Title" %}</dt><dd>{{ stream.conference.course.title }}</dd>
+                    <dt>{% trans "Session" %}</dt><dd>{{ stream.conference.session }}</dd>
+                    <dt>{% trans "Professor" %}</dt><dd><a href="{% url telemeta-profile-detail stream.conference.professor.user.username %}" target="_blank">{{ stream.conference.professor }}</a></dd>
+                    <dt>{% trans "Begin" %}</dt><dd>{{ stream.conference.date_begin }}</dd>
+                    </dl>
+                 </div>
+            </td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="10%" align="center">
+                {% if stream.streaming %}
+                <img src="{{ STATIC_URL }}teleforma/images/network-wireless.png" style="vertical-align:middle" title="streaming" />
+                <img src="{{ STATIC_URL }}telemeta/images/media-record.png" style="vertical-align:middle" title="recording" />
+              {% endif %}
+            </td>
+            {% else %}
+            <div style="padding-left: 1em;">
+
+            </div>
+             {% endif %}
+            </tr>
+            {% endif %}
+        {% endfor %}
+        {% endfor %}
+    </tbody>
+    </table>
+</div>
+{% endif %}
+{% endwith %}
\ No newline at end of file
diff --git a/teleforma/templates/teleforma/inc/question_list.html b/teleforma/templates/teleforma/inc/question_list.html
new file mode 100644 (file)
index 0000000..57840dc
--- /dev/null
@@ -0,0 +1,51 @@
+{% load teleforma_tags %}
+{% load i18n %}
+
+{% with course.conference.all|from_course_type:type as conferences %}
+{% if conferences %}
+<div class="course_content">
+<div class="course_subtitle">
+    <h3><img src="{{ STATIC_URL }}telemeta/images/item_title.png" width="10px" alt="" /> {% trans "Live conferences"%}</h3>
+</div>
+    <table class="listing" width="100%">
+    <tbody>
+       {% for conference in conferences|from_periods:periods %}
+        {% for stream in conference.livestream.all %}
+         {% if stream.stream_type == 'webm' %}
+            <tr>
+            {% if stream.streaming %}
+            <td {% if forloop.first %}class="border-top"{% endif %} width="230px">
+               <a href="{% url teleforma-conference-detail stream.conference.id %}" title="{% trans "View" %}">
+               <img id="snapshot-{{ stream.course.code }}-{{ stream.course_type }}" src="{{ stream.snapshot_url }}" width="100%" alt="{% trans 'Click here' %}" />
+               </a>
+            </td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="60%" style="padding-left: 1em;">
+                <div>
+                    <dl class="listing" style="font-size: 1.2em;">
+                    <dt>{% trans "Title" %}</dt><dd>{{ stream.conference.course.title }}</dd>
+                    <dt>{% trans "Session" %}</dt><dd>{{ stream.conference.session }}</dd>
+                    <dt>{% trans "Professor" %}</dt><dd><a href="{% url telemeta-profile-detail stream.conference.professor.user.username %}" target="_blank">{{ stream.conference.professor }}</a></dd>
+                    <dt>{% trans "Begin" %}</dt><dd>{{ stream.conference.date_begin }}</dd>
+                    </dl>
+                 </div>
+            </td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="10%" align="center">
+                {% if stream.streaming %}
+                <img src="{{ STATIC_URL }}teleforma/images/network-wireless.png" style="vertical-align:middle" title="streaming" />
+                <img src="{{ STATIC_URL }}telemeta/images/media-record.png" style="vertical-align:middle" title="recording" />
+              {% endif %}
+            </td>
+            {% else %}
+            <div style="padding-left: 1em;">
+
+            </div>
+             {% endif %}
+            </tr>
+            {% endif %}
+        {% endfor %}
+        {% endfor %}
+    </tbody>
+    </table>
+</div>
+{% endif %}
+{% endwith %}
\ No newline at end of file
index 61fcde741d6d6a0d151c3615033b37225ee76039..b0a9f4365d643986d28791d1c3d937fe9b63cf81 100644 (file)
@@ -1,56 +1,30 @@
-{% extends "teleforma/courses.html" %}
+{% extends "teleforma/seminars.html" %}
 {% load i18n %}
 
-{% block extra_javascript %}
-<script type="text/javascript">
-$(document).ready(function(){
-    InitChatWindow("{% url jqchat_ajax room.id %}", null);
-    });
-</script>
-{% endblock extra_javascript %}
 
-{% block courses %}
-{% for c in all_courses %}
-  {% with c.course as course %}
-   <li><a href="{% url teleforma-course-detail course.id %}">{{ course.title }}</a></li>
-  {% endwith %}
- {% endfor %}
-{% endblock courses %}
 
 {% block course %}
 <div class="desk_center">
-    {% for c in courses %}
-     {% with c.course as course %}
-      {% for type in c.types %}
       <div class="course">
-        <div class="course_title">{{ course.title }}{% if type.name != "None" %} - {{ type }}{% endif %}{% if course.description %} - {{ course.description }}{% endif %}
+        <div class="course_title">
+         <a href="{% url teleforma-seminar-detail seminar.id %}" style="color: #000;">{{ seminar.title }}{% if seminar.description %} - {{ seminar.description }}{% endif %}</a>
         </div>
 
-        {% block conference %}
-         {% include "teleforma/inc/conference_list.html" %}
-        {% endblock %}
-
-        {% block media %}
-         {% include "teleforma/inc/media_list.html" %}
-        {% endblock %}
-
-        {% block document %}
-         {% with forloop.counter as type_counter %}
-          {% include "teleforma/inc/document_list.html" %}
-         {% endwith %}
-        {% endblock %}
-
-        </div>
-      {% endfor %}
-     {% endwith %}
-    {% endfor %}
+        {% for step in seminar.steps %}
+
+          {% if step.element_type == 'document_simple' %}
+           {% include "teleforma/inc/document_simple_list.html" %}
+          
+          {% elif step.element_type == 'media_package' %}
+           {% include "teleforma/inc/media_package_list.html" %
+
+          {% elif step.element_type == 'question' %}
+            {% include "teleforma/inc/question_list.html" %}
+         
+          {% endif %}
+        {% endfor %}
+      
+      </div>
 </div>
 {% endblock course %}
 
-{% block chat %}
-{% if room %}
-{% with "General tweeter" as title %}
-{% include "teleforma/inc/chat_room.html" %}
-{% endwith %}
-{% endif %}
-{% endblock chat %}
\ No newline at end of file
index acbd28b50dddf66ac9a00a91f649d60b3916b7f4..e133937a6fb53161e2e8d52eb833856cadae7b79 100644 (file)
@@ -15,7 +15,7 @@
 <div style="background: white;">
 <ul>
 {% block courses %}
-{% for s in all_seminars %}
+{% for seminar in all_seminars %}
    <li><a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a></li>
  {% endfor %}
 {% endblock courses %}
     {% for seminar in object_list %}
       <div class="course">
         <div class="course_title">
-         <a href="{% url teleforma-seminar-detail seminar.id %}" style="color: #000;">{{ seminar.title }} - {{ type }}{% if seminar.description %} - {{ seminar.description }}{% endif %}</a>
+         <a href="{% url teleforma-seminar-detail seminar.id %}" style="color: #000;">{{ seminar.title }}</a>
         </div>
+        {% if seminar.description %}{{ seminar.description }}{% endif %}
 
-        {% for step in seminar.steps %}
+        {% for step in seminar.scenario %}
+        
+          {% if step.all.0.element_type == 'document_simple' %}
+           {% with step.all as docs %}
+            {% include "teleforma/inc/document_simple_list.html" %}
+           {% endwith %}
 
-          {% if step.element_type == 'document_simple' %}
-           {% include "teleforma/inc/document_simple_list.html" %}
-          
           {% elif step.element_type == 'media_package' %}
            {% include "teleforma/inc/media_package_list.html" %
 
index 98a2936edd33c70d989739141f8e0a1e1b060186..c2dcb26312f1db014df928c53d022d080c97454b 100644 (file)
@@ -59,8 +59,9 @@ urlpatterns = patterns('',
     url(r'^help/$', HelpView.as_view(), name="teleforma-help"),
 
     # Desk
-    url(r'^desk/$', CoursesView.as_view(), name="teleforma-desk"),
+    url(r'^desk/$', SeminarsView.as_view(), name="teleforma-desk"),
     url(r'^desk/courses/(?P<pk>.*)/$', CourseView.as_view(), name="teleforma-course-detail"),
+    url(r'^desk/seminars/(?P<pk>.*)/$', SeminarView.as_view(), name="teleforma-seminar-detail"),
 
     url(r'^desk/medias/(?P<pk>.*)/detail/$', MediaView.as_view(), name="teleforma-media-detail"),
     url(r'^desk/medias/(?P<pk>.*)/download/$', media.download, name="teleforma-media-download"),
index 9b4a9d774d3f4fa09beec577255035706bd7aa2a..8d152bdbf598df67609e3414dc95172c0df57762 100644 (file)
@@ -37,9 +37,6 @@
 from teleforma.views.core import *
 
 
-scenario = SeminarScenario1
-
-
 def get_seminars(user):
     seminars = []
 
@@ -96,10 +93,13 @@ def total_progress(user):
     n = 0
 
     for revision in revisions:
-        total += revision.progress
+        progress += revision.progress
         n += 1
 
-    return int(total/n)
+    if n:
+        return int(progress/n)
+    else:
+        return 0
 
 
 class SeminarView(DetailView):
@@ -118,7 +118,6 @@ class SeminarView(DetailView):
         context['all_seminars'] = get_seminars(user)
         context['progress'] = seminar_progress(user, seminar)
         context['total_progress'] = total_progress(user)
-        context['scenario'] = scenario(seminar)
         return context
 
 
@@ -128,18 +127,18 @@ class SeminarsView(ListView):
     template_name='teleforma/seminars.html'
 
     def get_queryset(self):
-        self.all_courses = get_courses(self.request.user, date_order=True)
-        return self.all_courses[:10]
+        return get_seminars(self.request.user)
 
     def get_context_data(self, **kwargs):
-        context = super(SeminarView, self).get_context_data(**kwargs)
+        context = super(SeminarsView, self).get_context_data(**kwargs)
+        user = self.request.user
         context['all_seminars'] = get_seminars(user)
         context['total_progress'] = total_progress(user)
         return context
 
     @method_decorator(login_required)
     def dispatch(self, *args, **kwargs):
-        return super(SeminarView, self).dispatch(*args, **kwargs)
+        return super(SeminarsView, self).dispatch(*args, **kwargs)