From: Guillaume Pellerin Date: Sat, 28 Jun 2014 15:26:42 +0000 (+0200) Subject: show exam tabs for student.platform_only X-Git-Tag: 1.1~451 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=852b4f0ecfc4882bb31d4a4fa35e3471c44c58b9;p=teleforma.git show exam tabs for student.platform_only --- diff --git a/example/settings.py b/example/settings.py index 3999a8dd..3e4576ac 100644 --- a/example/settings.py +++ b/example/settings.py @@ -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 index 00000000..92e64628 --- /dev/null +++ b/teleforma/exam/context_processors.py @@ -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 + + +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} + diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index 27bebf32..8f27e366 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -111,6 +111,7 @@ alt="logo" />
  • {% trans "Annals" %}
  • + {% if exam_access %} {% if periods|length == 1 %}
  •  {% trans "Scripts" %}  {% if user.is_staff or user.correctors.all %}{% untreated_scripts_count user periods.0.id %} @@ -127,6 +128,7 @@ alt="logo" />
  • {% endif %} + {% endif %} {% if user.is_authenticated %} {% if user.is_staff %}