This repository has been archived by the owner on Feb 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
108 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from molo.surveys.views import index | ||
|
||
urlpatterns = [ | ||
# re-route to overwritten index view, originally in wagtailsurveys | ||
url(r'^$', index, name='index'), | ||
] |
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
molo/surveys/test_templates/wagtailsurveys/list_forms.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from molo.surveys.models import ( | ||
MoloSurveyFormField, | ||
MoloSurveyPage, | ||
SurveysIndexPage, | ||
) | ||
from .utils import skip_logic_data | ||
|
||
|
||
def create_molo_survey_form_field(survey, sort_order, obj): | ||
if obj['type'] == 'radio': | ||
skip_logic = skip_logic_data(choices=obj['choices']) | ||
else: | ||
skip_logic = None | ||
|
||
return MoloSurveyFormField.objects.create( | ||
page=survey, | ||
sort_order=sort_order, | ||
label=obj["question"], | ||
field_type=obj["type"], | ||
required=obj["required"], | ||
page_break=obj["page_break"], | ||
admin_label=obj["question"].lower().replace(" ", "_"), | ||
skip_logic=skip_logic | ||
) | ||
|
||
|
||
def create_molo_survey_page( | ||
parent, title="Test Survey", slug='test-survey', **kwargs): | ||
molo_survey_page = MoloSurveyPage( | ||
title=title, slug=slug, | ||
introduction='Introduction to Test Survey ...', | ||
thank_you_text='Thank you for taking the Test Survey', | ||
submit_text='survey submission text', | ||
**kwargs | ||
) | ||
|
||
parent.add_child(instance=molo_survey_page) | ||
molo_survey_page.save_revision().publish() | ||
|
||
return molo_survey_page | ||
|
||
|
||
def create_survey(fields={}, **kwargs): | ||
survey = create_molo_survey_page(SurveysIndexPage.objects.first()) | ||
|
||
if not fields == {}: | ||
num_questions = len(fields) | ||
for index, field in enumerate(reversed(fields)): | ||
sort_order = num_questions - (index + 1) | ||
create_molo_survey_form_field(survey, sort_order, field) | ||
return survey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters