From: Guillaume Pellerin Date: Tue, 14 Jul 2015 08:45:15 +0000 (+0200) Subject: cleanup context_processor, add Score tab, add professor to script views X-Git-Tag: 1.1~228 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ff19c7037cd40b3b97ce6f0312c5a5e6231ba202;p=teleforma.git cleanup context_processor, add Score tab, add professor to script views --- diff --git a/teleforma/exam/context_processors.py b/teleforma/exam/context_processors.py deleted file mode 100644 index c547afe1..00000000 --- a/teleforma/exam/context_processors.py +++ /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 - - -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} - diff --git a/teleforma/exam/templates/exam/scores.html b/teleforma/exam/templates/exam/scores.html index 5d3b71f2..d90fb0e1 100644 --- a/teleforma/exam/templates/exam/scores.html +++ b/teleforma/exam/templates/exam/scores.html @@ -12,8 +12,8 @@ {% load_chart data.charttype data.chartdata data.chartcontainer data.extra %} {% endblock extra_javascript %} -{% block module-action %} +{% block modules %}

playlists{% trans "My courses" %}

@@ -29,8 +29,12 @@
+{% block module-action %} {% endblock module-action %} +{% endblock modules %} + + {% block answers %}
diff --git a/teleforma/exam/urls.py b/teleforma/exam/urls.py index 9f6dc360..f5525763 100644 --- a/teleforma/exam/urls.py +++ b/teleforma/exam/urls.py @@ -42,21 +42,19 @@ from jsonrpc import jsonrpc_site urlpatterns = patterns('', - url(r'^exam/periods/(?P.*)/script/(?P.*)/detail/$', ScriptView.as_view(), + url(r'^scripts/periods/(?P.*)/(?P.*)/detail/$', ScriptView.as_view(), name="teleforma-exam-script-detail"), - - url(r'^exam/periods/(?P.*)/scripts/list/$', ScriptsView.as_view(), + url(r'^scripts/periods/(?P.*)/list/$', ScriptsView.as_view(), name="teleforma-exam-script-list"), - - url(r'^exam/periods/(?P.*)/scripts/create/$', ScriptCreateView.as_view(), + url(r'^scripts/periods/(?P.*)/create/$', ScriptCreateView.as_view(), name="teleforma-exam-script-create"), + url(r'^scripts/periods/(?P.*)/pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"), + url(r'^scripts/periods/(?P.*)/treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"), + url(r'^scripts/periods/(?P.*)/rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"), - url(r'^exam/periods/(?P.*)/scripts_pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"), - url(r'^exam/periods/(?P.*)/scripts_treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"), - url(r'^exam/periods/(?P.*)/scripts_rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"), - url(r'^exam/periods/(?P.*)/scripts_scores_all/$', ScriptsScoreAllView.as_view(), name="teleforma-exam-scripts-scores-all"), - url(r'^exam/periods/(?P.*)/scripts_scores/(?P.*)/$', ScriptsScoreCourseView.as_view(), name="teleforma-exam-scripts-scores-course"), + url(r'^scores/periods/(?P.*)/all/$', ScriptsScoreAllView.as_view(), name="teleforma-exam-scripts-scores-all"), + url(r'^scores/periods/(?P.*)/courses/(?P.*)/$', ScriptsScoreCourseView.as_view(), name="teleforma-exam-scripts-scores-course"), - url(r'^exam/periods/(?P.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"), + # url(r'^exam/periods/(?P.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"), ) diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 46a0ca1b..8f28fc52 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -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 = [] diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index 97d4c434..9cf52162 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -112,14 +112,13 @@ alt="logo" />
  • {% trans "Annals" %}
  • - {% if exam_access %} {% if periods|length == 1 %}
  •  {% 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 %}
  • {% else %} -
  •  {% trans "Scripts" %} +
  •  {% 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 %}
      @@ -129,6 +128,17 @@ alt="logo" />
  • {% endif %} + + {% if periods|length == 1 %} +
  •  {% trans "Scores" %}
  • + {% else %} +
  •  {% trans "Scores" %} + +
  • {% endif %} {% if user.is_authenticated %}