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

Commit

Permalink
Merge 1cf0dc0 into 8bd7973
Browse files Browse the repository at this point in the history
  • Loading branch information
codiebeulaine committed Feb 12, 2018
2 parents 8bd7973 + 1cf0dc0 commit 8576201
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 31 deletions.
35 changes: 35 additions & 0 deletions molo/surveys/migrations/0024_add_molo_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-02-12 14:31
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('surveys', '0023_add_page_view_model'),
]

operations = [
migrations.RenameField(
model_name='molosurveypage',
old_name='content',
new_name='description',
),
migrations.RenameField(
model_name='molosurveypage',
old_name='intro',
new_name='introduction',
),
migrations.AlterField(
model_name='molosurveyformfield',
name='field_type',
field=models.CharField(choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time'), (b'positive_number', 'Positive Number')], max_length=16, verbose_name='field type'),
),
migrations.AlterField(
model_name='personalisablesurveyformfield',
name='field_type',
field=models.CharField(choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time'), (b'positive_number', 'Positive Number')], max_length=16, verbose_name='field type'),
),
]
15 changes: 8 additions & 7 deletions molo/surveys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def create_survey_index_pages(sender, instance, **kwargs):


class MoloSurveyPage(
TranslatablePageMixinNotRoutable, surveys_models.AbstractSurvey):
TranslatablePageMixinNotRoutable, MoloPage,
surveys_models.AbstractSurvey):
parent_page_types = [
'surveys.SurveysIndexPage', 'core.SectionPage', 'core.ArticlePage']
subpage_types = []
Expand All @@ -106,15 +107,15 @@ class MoloSurveyPage(

base_form_class = MoloSurveyForm

intro = TextField(blank=True)
introduction = TextField(blank=True)
image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
content = StreamField([
description = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', MarkDownBlock()),
('image', ImageChooserBlock()),
Expand Down Expand Up @@ -175,13 +176,13 @@ class MoloSurveyPage(
"Styling options that can be applied to this page "
"and all its descendants"))
content_panels = surveys_models.AbstractSurvey.content_panels + [
FieldPanel('intro', classname='full'),
ImageChooserPanel('image'),
StreamFieldPanel('content'),
FieldPanel('introduction', classname='full'),
FieldPanel('homepage_button_text', classname='full'),
StreamFieldPanel('description'),
InlinePanel('survey_form_fields', label='Form fields'),
FieldPanel('thank_you_text', classname='full'),
FieldPanel('submit_text', classname='full'),
FieldPanel('homepage_button_text', classname='full'),
FieldPanel('thank_you_text', classname='full'),
InlinePanel('terms_and_conditions', label="Terms and Conditions"),
]

Expand Down
2 changes: 1 addition & 1 deletion molo/surveys/templates/surveys/molo_survey_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block content %}
<div class="surveys surveys{{page.get_parent_section.get_effective_extra_style_hints}}">
<h1 class="surveys__title">{{ page.title }}</h1>
<h4 class="surveys__intro">{{ page.intro }}</h4>
<h4 class="surveys__intro">{{ page.introduction }}</h4>
{% if page.terms_and_conditions.exists and page.terms_and_conditions.first.terms_and_conditions.live %}
<a href="{% pageurl page.terms_and_conditions.first.terms_and_conditions %}">{{page.terms_and_conditions.first.terms_and_conditions.title}}</a>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion molo/surveys/templates/surveys/surveys_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="surveys surveys{{survey.get_effective_extra_style_hints}}">
<div class="surveys__item">
<h1 class="surveys__title">{{ survey.title }}</h1>
<h4 class="surveys__intro">{{ survey.intro }}</h4>
<h4 class="surveys__intro">{{ survey.introduction }}</h4>

{% if not survey.display_survey_directly %}
{% trans "Take The Survey" as button_text %}
Expand Down
6 changes: 3 additions & 3 deletions molo/surveys/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setUp(self):
def create_molo_survey_page(self, parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
**kwargs
)
Expand All @@ -79,7 +79,7 @@ def create_personalisable_molo_survey_page(self, parent, **kwargs):

personalisable_survey = PersonalisableSurvey(
title='Test Survey', slug='test-survey',
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
**kwargs
)
Expand All @@ -103,7 +103,7 @@ def test_convert_to_article(self):
self.client.login(username='tester', password='tester')
response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
response = self.client.post(molo_survey_page.url, {
molo_survey_form_field.label.lower().replace(' ', '-'): 'python'
Expand Down
2 changes: 1 addition & 1 deletion molo/surveys/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def create_molo_survey_form_field(survey, sort_order, obj):
def create_molo_survey_page(parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand Down
4 changes: 2 additions & 2 deletions molo/surveys/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_molo_survey_page(self,
molo_survey_page = MoloSurveyPage(
title=title,
slug=slug,
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
**kwargs
)
Expand All @@ -54,7 +54,7 @@ def create_personalisable_survey(
personalisable_survey = PersonalisableSurvey(
title=title,
slug=slug,
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
**kwargs
)
Expand Down
2 changes: 1 addition & 1 deletion molo/surveys/tests/test_the_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setUp(self):
def create_molo_survey_page(self, parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand Down
30 changes: 15 additions & 15 deletions molo/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def setUp(self):
def create_molo_survey_page(self, parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
intro='Introduction to Test Survey ...',
introduction='Introduction to Test Survey ...',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_submit_survey_as_logged_in_user(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
self.assertContains(response, molo_survey_page.submit_text)

Expand All @@ -136,7 +136,7 @@ def test_anonymous_submissions_option(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
response = self.client.post(molo_survey_page.url, {
molo_survey_form_field.label.lower().replace(' ', '-'): 'python'
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_multiple_submissions_option(self, anonymous=False):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand All @@ -200,7 +200,7 @@ def test_show_results_option(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand All @@ -223,7 +223,7 @@ def test_show_results_as_percentage_option(self):

response = self.client.get(molo_survey_page.url)
self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_multi_step_option(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)
self.assertNotContains(response, extra_molo_survey_form_field.label)
self.assertContains(response, 'Next Question')
Expand All @@ -271,7 +271,7 @@ def test_multi_step_option(self):
})

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertNotContains(response, molo_survey_form_field.label)
self.assertContains(response, extra_molo_survey_form_field.label)
self.assertContains(response, molo_survey_page.submit_text)
Expand All @@ -296,7 +296,7 @@ def test_can_submit_after_validation_error(self):
response = self.client.get(molo_survey_page.url)

self.assertContains(response, molo_survey_page.title)
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
self.assertContains(response, molo_survey_form_field.label)

response = self.client.post(molo_survey_page.url, {})
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_survey_template_tag_on_home_page_specific(self):
self.create_molo_survey_page(parent=self.surveys_index)
response = self.client.get("/")
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
user = User.objects.create_superuser(
username='testuser', password='password', email='test@email.com')
self.client2.login(user=user)
Expand All @@ -338,7 +338,7 @@ def test_can_only_see_sites_surveys_in_admin(self):
self.create_molo_survey_page(parent=self.surveys_index)
response = self.client.get("/")
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)
user = User.objects.create_superuser(
username='testuser', password='password', email='test@email.com')
self.client2.login(user=user)
Expand Down Expand Up @@ -443,7 +443,7 @@ def test_survey_template_tag_on_section_page(self):

response = self.client.get(self.section.url)
self.assertContains(response, 'Take The Survey</a>')
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)

def test_translated_survey_on_section_page(self):
self.user = self.login()
Expand Down Expand Up @@ -481,7 +481,7 @@ def test_survey_template_tag_on_article_page(self):
self.assertContains(response,
'Take The Survey</a>'.format(
molo_survey_page.url))
self.assertContains(response, molo_survey_page.intro)
self.assertContains(response, molo_survey_page.introduction)

def test_survey_list_display_direct_logged_out(self):
molo_survey_page, molo_survey_form_field = \
Expand Down Expand Up @@ -679,7 +679,7 @@ def setUp(self):
def new_survey(self, name):
survey = MoloSurveyPage(
title=name, slug=slugify(name),
intro='Introduction to {}...'.format(name),
introduction='Introduction to {}...'.format(name),
thank_you_text='Thank you for taking the {}'.format(name),
submit_text='survey submission text for {}'.format(name),
allow_anonymous_submissions=True,
Expand All @@ -690,7 +690,7 @@ def new_survey(self, name):

def assertSurveyAndQuestions(self, response, survey, questions):
self.assertContains(response, survey.title)
self.assertContains(response, survey.intro)
self.assertContains(response, survey.introduction)
for question in questions:
self.assertContains(response, question.label)
self.assertContains(response, question.label)
Expand Down

0 comments on commit 8576201

Please sign in to comment.