From 5ae7ce8c13309d74d63d61d2721b13eb93b9ff6d Mon Sep 17 00:00:00 2001 From: Jamie Campbell Date: Mon, 8 Feb 2016 21:30:18 -0600 Subject: [PATCH] added ability to lock out external survey answering people but still allow logged in users to use the same interface to transcribe paper surveys --- questionnaire/models.py | 1 + questionnaire/views.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/questionnaire/models.py b/questionnaire/models.py index b620fa5..1fdf0c0 100644 --- a/questionnaire/models.py +++ b/questionnaire/models.py @@ -76,6 +76,7 @@ class Questionnaire(models.Model): redirect_url = models.CharField(max_length=128, help_text="URL to redirect to when Questionnaire is complete. Macros: $SUBJECTID, $RUNID, $LANG", default="/static/complete.html") html = models.TextField(u'Html', blank=True) parse_html = models.BooleanField("Render html instead of name for survey?", null=False, default=False) + admin_access_only = models.BooleanField("Only allow access to logged in users? (This allows entering paper surveys without allowing new external submissions)", null=False, default=False) def __unicode__(self): return self.name diff --git a/questionnaire/views.py b/questionnaire/views.py index a04cf69..dcde5db 100644 --- a/questionnaire/views.py +++ b/questionnaire/views.py @@ -372,6 +372,10 @@ def questionnaire(request, runcode=None, qs=None): commit() return HttpResponseRedirect('/') + if runinfo.questionset.questionnaire.admin_access_only == 1: + if not request.user.is_superuser: + return HttpResponseRedirect(runinfo.questionset.questionnaire.redirect_url) + # let the runinfo have a piggy back ride on the request # so we can easily use the runinfo in places like the question processor # without passing it around