Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

removed pagination from PollsViaSurveys #103

Merged
merged 8 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion molo/surveys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class MoloSurveyPage(
introduction = TextField(blank=True)
homepage_introduction = TextField(blank=True)
image = models.ForeignKey(

'wagtailimages.Image',
null=True,
blank=True,
Expand Down Expand Up @@ -388,7 +389,8 @@ def serve(self, request, *args, **kwargs):
self.has_user_submitted_survey(request, self.id)):
return render(request, self.template, self.get_context(request))

if self.has_page_breaks or self.multi_step:
if ((self.has_page_breaks or self.multi_step) and
not self.display_survey_directly):
return self.serve_questions(request)

if request.method == 'POST':
Expand Down
72 changes: 69 additions & 3 deletions molo/surveys/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from molo.surveys.models import (
MoloSurveyFormField,
MoloSurveyPage,
PersonalisableSurvey,
SurveysIndexPage,
PersonalisableSurveyFormField
)
from .utils import skip_logic_data

Expand All @@ -25,13 +27,16 @@ def create_molo_survey_form_field(survey, sort_order, obj):


def create_molo_survey_page(
parent, title="Test Survey", slug='test-survey', **kwargs):
parent, title="Test Survey", slug='test-survey',
thank_you_text='Thank you for taking the Test Survey',
homepage_introduction='Shorter homepage introduction',
**kwargs):
molo_survey_page = MoloSurveyPage(
title=title, slug=slug,
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
thank_you_text=thank_you_text,
submit_text='survey submission text',
**kwargs
homepage_introduction=homepage_introduction, **kwargs
)

parent.add_child(instance=molo_survey_page)
Expand All @@ -40,6 +45,25 @@ def create_molo_survey_page(
return molo_survey_page


def create_personalisable_survey_page(
parent, title="Test Personalisable Survey",
slug='test-personalisable-survey',
thank_you_text='Thank you for taking the Personalisable Survey',
**kwargs):
personalisable_survey_page = PersonalisableSurvey(
title=title, slug=slug,
introduction='Introduction to Test Personalisable Survey ...',
thank_you_text=thank_you_text,
submit_text='personalisable survey submission text',
**kwargs
)

parent.add_child(instance=personalisable_survey_page)
personalisable_survey_page.save_revision().publish()

return personalisable_survey_page


def create_survey(fields={}, **kwargs):
survey = create_molo_survey_page(SurveysIndexPage.objects.first())

Expand All @@ -49,3 +73,45 @@ def create_survey(fields={}, **kwargs):
sort_order = num_questions - (index + 1)
create_molo_survey_form_field(survey, sort_order, field)
return survey


def create_molo_dropddown_field(
parent, survey, choices, page_break=False,
sort_order=1, label="Is this a dropdown?", **kwargs):
return MoloSurveyFormField.objects.create(
page=survey,
sort_order=sort_order,
admin_label="is-this-a-drop-down",
label=label,
field_type='dropdown',
skip_logic=skip_logic_data(choices),
required=True,
page_break=page_break
)


def create_personalisable_dropddown_field(
parent, survey, choices, page_break=False,
sort_order=1, label="Is this a dropdown?", **kwargs):
return PersonalisableSurveyFormField.objects.create(
page=survey,
sort_order=sort_order,
admin_label="is-this-a-drop-down",
label=label,
field_type='dropdown',
skip_logic=skip_logic_data(choices),
required=True,
page_break=page_break
)


def create_molo_survey_formfield(
survey, field_type, label="Your favourite animal",
required=False, sort_order=1):
return MoloSurveyFormField.objects.create(
page=survey,
sort_order=sort_order,
label=label,
field_type=field_type,
required=required
)
Loading