Skip to content

Commit

Permalink
If survey categories are treated as sub-surveys, the survey gets clos…
Browse files Browse the repository at this point in the history
…ed after all answers has been collected, even with external redirect
  • Loading branch information
dkalpakchi committed Dec 15, 2022
1 parent f690fd1 commit 9637d23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 0 additions & 8 deletions scientific_survey/views/confirm_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from datetime import date, timedelta

from django.views.generic import TemplateView

from scientific_survey.models import Response
Expand All @@ -14,10 +12,4 @@ def get_context_data(self, **kwargs):
context = super(ConfirmView, self).get_context_data(**kwargs)
context["uuid"] = str(kwargs["uuid"])
context["response"] = Response.objects.get(interview_uuid=context["uuid"])

if context["response"].survey.categories_as_surveys:
cats2choose = context["response"].survey.get_bookable_categories()
if not cats2choose:
context["response"].survey.expire_date = date.today() - timedelta(days=1)
context["response"].survey.save()
return context
7 changes: 7 additions & 0 deletions scientific_survey/views/survey_detail.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import logging
from datetime import date, timedelta

from django.conf import settings
from django.shortcuts import Http404, redirect, render, reverse
Expand Down Expand Up @@ -103,6 +104,12 @@ def handle_invalid_form(context, form, request, survey):
return render(request, template_name, context)

def final_redirect(self, survey, response):
if survey.categories_as_surveys:
cats2choose = survey.get_bookable_categories()
if not cats2choose:
survey.expire_date = date.today() - timedelta(days=1)
survey.save()

if survey.external_redirect:
return redirect(survey.external_redirect)
else:
Expand Down

0 comments on commit 9637d23

Please sign in to comment.