]> git.parisson.com Git - teleforma.git/commitdiff
show exam tabs for student.platform_only
authorGuillaume Pellerin <yomguy@parisson.com>
Sat, 28 Jun 2014 15:26:42 +0000 (17:26 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Sat, 28 Jun 2014 15:26:42 +0000 (17:26 +0200)
example/settings.py
teleforma/exam/context_processors.py [new file with mode: 0644]
teleforma/templates/telemeta/base.html

index 3999a8dd6e8b2669f8ffcaa599bb688c2df14c30..3e4576ac6190301101f6ef490495015d0013c9cb 100644 (file)
@@ -158,6 +158,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.media",
     'django.core.context_processors.static',
     "teleforma.context_processors.periods",
+    "teleforma.exam.context_processors.exam_access",
 )
 
 TELEMETA_ORGANIZATION = 'Pre-Barreau - CRFPA'
diff --git a/teleforma/exam/context_processors.py b/teleforma/exam/context_processors.py
new file mode 100644 (file)
index 0000000..92e6462
--- /dev/null
@@ -0,0 +1,57 @@
+# -*- 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()
+
+        if students:
+            platform_only = students[0].platform_only
+        else:
+            platform_only = False
+
+        if platform_only 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 27bebf323120075605dcf9c33dc55439d8999d87..8f27e366575724bfd4367c769a4c0e799cf64c68 100644 (file)
@@ -111,6 +111,7 @@ 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" %}&nbsp;
       {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user periods.0.id %}
@@ -127,6 +128,7 @@ alt="logo" />
       </ul>
     </li>
   {% endif %}
+  {% endif %}
 
  {% if user.is_authenticated %}
   {% if user.is_staff %}