From 621583c2672b490fdc0094519601d606b4d18173 Mon Sep 17 00:00:00 2001 From: Gael Le Mignot Date: Fri, 28 Feb 2020 14:54:00 +0100 Subject: [PATCH] More complete blocking of consultation fictive for users having access to a conference directly --- teleforma/models/pro.py | 1 - teleforma/templates/teleforma/inc/steps.html | 25 +++++++++++--------- teleforma/views/core.py | 1 + teleforma/views/pro.py | 5 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/teleforma/models/pro.py b/teleforma/models/pro.py index c4005e23..0d00d9be 100644 --- a/teleforma/models/pro.py +++ b/teleforma/models/pro.py @@ -330,7 +330,6 @@ class Auditor(models.Model): verbose_name = _('Auditor') ordering = ['user__last_name'] - class SeminarRevision(models.Model): seminar = models.ForeignKey(Seminar, related_name="revision", verbose_name=_('seminar')) diff --git a/teleforma/templates/teleforma/inc/steps.html b/teleforma/templates/teleforma/inc/steps.html index df51abf9..6ac29594 100644 --- a/teleforma/templates/teleforma/inc/steps.html +++ b/teleforma/templates/teleforma/inc/steps.html @@ -23,34 +23,37 @@ {% include "teleforma/inc/document_step.html" %} {% endwith %} -{% with seminar.question as questions %} + {% if not seminar.conference in user.auditor.get.conferences.all %} + + {% with seminar.question as questions %}

{% trans "Step" %} 4

{% include "teleforma/inc/question_step.html" %} -{% endwith %} + {% endwith %} -{% if seminar_progress == 100 %} -{% with seminar.docs_correct as docs %} -
+ {% if seminar_progress == 100 %} + {% with seminar.docs_correct as docs %} +

{% trans "Step" %} 5

{% include "teleforma/inc/document_step.html" %} -{% endwith %} + {% endwith %} -{% with seminar.form as form %} + {% with seminar.form as form %}

{% trans "Step" %} 6 :

{% include "teleforma/inc/evaluation_form.html" %} -{% endwith %} -{% endif %} + {% endwith %} + {% endif %} -{% if seminar|validated:user %} + {% if seminar|validated:user %}

{% trans "Step" %} 7

{% include "teleforma/inc/testimonial_step.html" %} -{% endif %} + {% endif %} + {% endif %} diff --git a/teleforma/views/core.py b/teleforma/views/core.py index e2400af7..8247017f 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -320,6 +320,7 @@ class MediaView(DetailView): media.set_mime_type() if not self.request.user in media.readers.all(): media.readers.add(self.request.user) + context['HOST'] = self.request.META.get('HOST') context['media'] = media context['mime_type'] = media.mime_type context['course'] = media.course diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 8e3f524e..a10ab5db 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -35,6 +35,7 @@ from teleforma.views.core import * from teleforma.context_processors import * +from django.core.exceptions import PermissionDenied from telemeta.util.unicode import UnicodeWriter @@ -300,6 +301,10 @@ class AnswerView(SeminarAccessMixin, SeminarRevisionMixin, FormView): self.question = Question.objects.get(pk=self.kwargs['pk']) self.user = self.get_user() + + if self.question.seminar.conference in self.user.auditor.get().conferences.all(): + raise PermissionDenied + answers = Answer.objects.filter(user=self.user, question=self.question).order_by('-date_submitted') if answers: -- 2.39.5