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

Commit

Permalink
Merge branch 'release/6.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeed Marzban authored and Saeed Marzban committed Jun 6, 2018
2 parents 2f3ac19 + 3abd1fc commit f2d6f75
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGE LOG
==========

6.8.0
-----
- Remove hardcoded groups for displaying the surveys in wagtail menu

6.7.6
-----
- Bugfix: Ensure results of surveys, that are children of articles, pull through to the admin view
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.7.6
6.8.0
6 changes: 6 additions & 0 deletions local_test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
CELERY_ALWAYS_EAGER = True
BROKER_BACKEND = 'memory'

ALLOWED_HOSTS = [
'localhost',
'.localhost',
'site2',
]

PERSONALISATION_SEGMENTS_ADAPTER = (
'molo.surveys.adapters.PersistentSurveysSegmentsAdapter'
)
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

0 comments on commit f2d6f75

Please sign in to comment.