]> git.parisson.com Git - teleforma.git/commitdiff
cleanup context_processor, add Score tab, add professor to script views
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 14 Jul 2015 08:45:15 +0000 (10:45 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 14 Jul 2015 08:45:15 +0000 (10:45 +0200)
teleforma/exam/context_processors.py [deleted file]
teleforma/exam/templates/exam/scores.html
teleforma/exam/urls.py
teleforma/exam/views.py
teleforma/templates/telemeta/base.html

diff --git a/teleforma/exam/context_processors.py b/teleforma/exam/context_processors.py
deleted file mode 100644 (file)
index c547afe..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2013 Parisson SARL
-
-# This software is a computer program whose purpose is to backup, analyse,
-# transcode and stream any audio content with its metadata over a web frontend.
-
-# This software is governed by the CeCILL  license under French law and
-# abiding by the rules of distribution of free software.  You can  use,
-# modify and/ or redistribute the software under the terms of the CeCILL
-# license as circulated by CEA, CNRS and INRIA at the following URL
-# "http://www.cecill.info".
-
-# As a counterpart to the access to the source code and  rights to copy,
-# modify and redistribute granted by the license, users are provided only
-# with a limited warranty  and the software's author,  the holder of the
-# economic rights,  and the successive licensors  have only  limited
-# liability.
-
-# In this respect, the user's attention is drawn to the risks associated
-# with loading,  using,  modifying and/or developing or reproducing the
-# software by the user in light of its specific status of free software,
-# that may mean  that it is complicated to manipulate,  and  that  also
-# therefore means  that it is reserved for developers  and  experienced
-# professionals having in-depth computer knowledge. Users are therefore
-# encouraged to load and test the software's suitability as regards their
-# requirements in conditions enabling the security of their systems and/or
-# data to be ensured and,  more generally, to use and operate it in the
-# same conditions as regards security.
-
-# The fact that you are presently reading this means that you have had
-# knowledge of the CeCILL license and that you accept its terms.
-#
-# Authors: Guillaume Pellerin <yomguy@parisson.com>
-
-
-from teleforma.views.core import *
-
-
-def exam_access(request):
-    user = request.user
-
-    if user.is_authenticated():
-        students = user.student.all()
-        quotas = user.quotas.all()
-        professor = user.professor.all()
-
-        # Option for restricting access to platform user only
-        if students:
-            platform_only = students[0].platform_only
-        else:
-            platform_only = False
-
-        if students or quotas or user.is_staff or user.is_superuser:
-            return {'exam_access': True}
-        else:
-            return {'exam_access': False}
-    else:
-        return {'exam_access': False}
-
index 5d3b71f210ec1e439ce3fddfea498db1d7c00194..d90fb0e189cb61c2210f3fdcd460b7e415ea1e01 100644 (file)
@@ -12,8 +12,8 @@
 {% load_chart data.charttype data.chartdata data.chartcontainer data.extra %}
 {% endblock extra_javascript %}
 
-{% block module-action %}
 
+{% block modules %}
     <div class="module">
     <h3><a href="{% url teleforma-home %}"><img src="{{ STATIC_URL }}telemeta/images/module_playlist.png" alt="playlists" style="vertical-align:middle" />{% trans "My courses" %}</a></h3>
     <div style="background: white;">
     </div>
     </div>
 
+{% block module-action %}
 {% endblock module-action %}
 
+{% endblock modules %}
+
+
 {% block answers %}
 
 <div class="course_title">
index 9f6dc360c88174b71c8e47583ddf1199cd3d9918..f5525763461fe8855d4d311428aa8dbea573c7dd 100644 (file)
@@ -42,21 +42,19 @@ from jsonrpc import jsonrpc_site
 
 urlpatterns = patterns('',
 
-    url(r'^exam/periods/(?P<period_id>.*)/script/(?P<pk>.*)/detail/$', ScriptView.as_view(),
+    url(r'^scripts/periods/(?P<period_id>.*)/(?P<pk>.*)/detail/$', ScriptView.as_view(),
         name="teleforma-exam-script-detail"),
-
-    url(r'^exam/periods/(?P<period_id>.*)/scripts/list/$', ScriptsView.as_view(),
+    url(r'^scripts/periods/(?P<period_id>.*)/list/$', ScriptsView.as_view(),
         name="teleforma-exam-script-list"),
-
-    url(r'^exam/periods/(?P<period_id>.*)/scripts/create/$', ScriptCreateView.as_view(),
+    url(r'^scripts/periods/(?P<period_id>.*)/create/$', ScriptCreateView.as_view(),
         name="teleforma-exam-script-create"),
+    url(r'^scripts/periods/(?P<period_id>.*)/pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"),
+    url(r'^scripts/periods/(?P<period_id>.*)/treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"),
+    url(r'^scripts/periods/(?P<period_id>.*)/rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"),
 
-    url(r'^exam/periods/(?P<period_id>.*)/scripts_pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"),
-    url(r'^exam/periods/(?P<period_id>.*)/scripts_treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"),
-    url(r'^exam/periods/(?P<period_id>.*)/scripts_rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"),
-    url(r'^exam/periods/(?P<period_id>.*)/scripts_scores_all/$', ScriptsScoreAllView.as_view(), name="teleforma-exam-scripts-scores-all"),
-    url(r'^exam/periods/(?P<period_id>.*)/scripts_scores/(?P<course_id>.*)/$', ScriptsScoreCourseView.as_view(), name="teleforma-exam-scripts-scores-course"),
+    url(r'^scores/periods/(?P<period_id>.*)/all/$', ScriptsScoreAllView.as_view(), name="teleforma-exam-scripts-scores-all"),
+    url(r'^scores/periods/(?P<period_id>.*)/courses/(?P<course_id>.*)/$', ScriptsScoreCourseView.as_view(), name="teleforma-exam-scripts-scores-course"),
 
-    url(r'^exam/periods/(?P<period_id>.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"),
+    url(r'^exam/periods/(?P<period_id>.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"),
 
 )
index 46a0ca1b9544eed7a9a1a523ddacb7c7e06d7aa2..8f28fc525779bba26f5e048a71f0111e21ab09df 100644 (file)
@@ -78,10 +78,15 @@ class ScriptsPendingView(ScriptsView):
     def get_queryset(self):
         user = self.request.user
         period = Period.objects.get(id=self.kwargs['period_id'])
-        Q1 = Q(status=3, author=user, period=period)
-        Q2 = Q(status=2, author=user, period=period)
-        Q3 = Q(status=3, corrector=user, period=period)
-        scripts = Script.objects.filter(Q1 | Q2 | Q3)
+        if user.professor.all():
+            Q1 = Q(status=3, period=period)
+            Q2 = Q(status=2, period=period)
+            scripts = Script.objects.filter(Q1 | Q2)
+        else:
+            Q1 = Q(status=3, author=user, period=period)
+            Q2 = Q(status=2, author=user, period=period)
+            Q3 = Q(status=3, corrector=user, period=period)
+            scripts = Script.objects.filter(Q1 | Q2 | Q3)
         return scripts
 
     def get_context_data(self, **kwargs):
@@ -94,11 +99,17 @@ class ScriptsTreatedView(ScriptsView):
 
     def get_queryset(self):
         user = self.request.user
-        Q1 = Q(status=4, author=user)
-        Q2 = Q(status=5, author=user)
-        Q3 = Q(status=4, corrector=user)
-        Q4 = Q(status=5, corrector=user)
-        scripts = Script.objects.filter(Q1 | Q2 | Q3 | Q4)
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        if user.professor.all():
+            Q1 = Q(status=4, period=period)
+            Q2 = Q(status=5, period=period)
+            scripts = Script.objects.filter(Q1 | Q2)
+        else:
+            Q1 = Q(status=4, author=user, period=period)
+            Q2 = Q(status=5, author=user, period=period)
+            Q3 = Q(status=4, corrector=user, period=period)
+            Q4 = Q(status=5, corrector=user, period=period)
+            scripts = Script.objects.filter(Q1 | Q2 | Q3 | Q4)
         return scripts
 
     def get_context_data(self, **kwargs):
@@ -111,9 +122,14 @@ class ScriptsRejectedView(ScriptsView):
 
     def get_queryset(self):
         user = self.request.user
-        Q1 = Q(status=0, author=user)
-        Q2 = Q(status=0, corrector=user)
-        scripts = Script.objects.filter(Q1 | Q2)
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        if user.professor.all():
+            Q1 = Q(status=0)
+            scripts = Script.objects.filter(Q1)
+        else:
+            Q1 = Q(status=0, author=user)
+            Q2 = Q(status=0, corrector=user)
+            scripts = Script.objects.filter(Q1 | Q2)
         return scripts
 
     def get_context_data(self, **kwargs):
@@ -205,7 +221,12 @@ class ScriptsScoreAllView(ScriptsTreatedView):
 
     def get_context_data(self, **kwargs):
         context = super(ScriptsScoreAllView, self).get_context_data(**kwargs)
-        scripts = self.get_queryset()
+
+        if self.request.user.is_staff or self.request.user.professor.all():
+            scripts = Script.objects.all().exclude(score=None)
+        else:
+            scripts = self.get_queryset()
+
         sessions = []
         scores = []
 
@@ -243,8 +264,12 @@ class ScriptsScoreCourseView(ScriptsScoreAllView):
     def get_context_data(self, **kwargs):
         context = super(ScriptsScoreCourseView, self).get_context_data(**kwargs)
         course = Course.objects.get(id=self.kwargs['course_id'])
-        scripts = self.get_queryset()
-        scripts = scripts.filter(course=course)
+
+        if self.request.user.is_staff or self.request.user.professor.all():
+            scripts = Script.objects.all().filter(course=course).exclude(score=None)
+        else:
+            scripts = self.get_queryset().filter(course=course)
+
         sessions = []
         scores = []
 
index 97d4c434eed34b7c2d65216ee7ba4484647478db..9cf52162248112a81554eb04cc83e679df88719a 100644 (file)
@@ -112,14 +112,13 @@ alt="logo" />
 
   <li><a href="{% url teleforma-annals %}" class="yellow">{% trans "Annals" %}</a></li>
 
-  {% if exam_access %}
   {% if periods|length == 1 %}
       <li><a href="{% url teleforma-exam-scripts-pending periods.0.id %}" class="green">&nbsp;{% trans "Scripts" %}
       {% if user.is_staff or user.quotas.all %}{% untreated_scripts_count user periods.0.id %}
      {% else %}{% treated_scripts_count user periods.0.id %}{% endif %}</a>
      </li>
   {% else %}
-    <li><a href="#exam#" class="green">&nbsp;{% trans "Scripts" %}
+    <li><a href="#scripts#" class="green">&nbsp;{% trans "Scripts" %}
      {% if user.is_staff or user.quotas.all %}{% untreated_scripts_count user periods.0.id %}
      {% else %}{% treated_scripts_count user periods.0.id %}{% endif %}</a>
       <ul>
@@ -129,6 +128,17 @@ alt="logo" />
       </ul>
     </li>
   {% endif %}
+
+  {% if periods|length == 1 %}
+      <li><a href="{% url teleforma-exam-scripts-scores-all periods.0.id %}" class="green">&nbsp;{% trans "Scores" %}</a></li>
+  {% else %}
+    <li><a href="#scores#" class="green">&nbsp;{% trans "Scores" %}</a>
+      <ul>
+        {% for period in periods %}
+        <li><a href="{% url teleforma-exam-scripts-scores-all period.id %}" class="green">{{ period.name }}</a></li>
+        {% endfor %}
+      </ul>
+    </li>
   {% endif %}
 
  {% if user.is_authenticated %}