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

add homepage introduction field (BED) #92

Merged
merged 5 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
20 changes: 20 additions & 0 deletions molo/surveys/migrations/0025_add homepage introduction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-02-12 16:56
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('surveys', '0024_add_molo_page'),
]

operations = [
migrations.AddField(
model_name='molosurveypage',
name='homepage_introduction',
field=models.TextField(blank=True),
),
]
2 changes: 2 additions & 0 deletions molo/surveys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MoloSurveyPage(
base_form_class = MoloSurveyForm

introduction = TextField(blank=True)
homepage_introduction = TextField(blank=True)
image = models.ForeignKey(
'wagtailimages.Image',
null=True,
Expand Down Expand Up @@ -178,6 +179,7 @@ class MoloSurveyPage(
content_panels = surveys_models.AbstractSurvey.content_panels + [
ImageChooserPanel('image'),
FieldPanel('introduction', classname='full'),
FieldPanel('homepage_introduction', classname='full'),
FieldPanel('homepage_button_text', classname='full'),
StreamFieldPanel('description'),
InlinePanel('survey_form_fields', label='Form fields'),
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.introduction }}</h4>
<h4 class="surveys__intro">{{ survey.homepage_introduction }}</h4>

{% if not survey.display_survey_directly %}
{% trans "Take The Survey" as button_text %}
Expand Down
1 change: 1 addition & 0 deletions molo/surveys/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def create_survey(fields={}, **kwargs):
for index, field in enumerate(reversed(fields)):
sort_order = num_questions - (index + 1)
create_molo_survey_form_field(survey, sort_order, field)
return survey


class TestPageBreakWithTwoQuestionsInOneStep(TestCase, MoloTestCaseMixin):
Expand Down
19 changes: 15 additions & 4 deletions molo/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_molo_survey_page(self, parent, **kwargs):
molo_survey_page = MoloSurveyPage(
title='Test Survey', slug='test-survey',
introduction='Introduction to Test Survey ...',
homepage_introduction='Shorter homepage introduction',
thank_you_text='Thank you for taking the Test Survey',
submit_text='survey submission text',
**kwargs
Expand All @@ -96,6 +97,16 @@ def test_homepage_button_text_customisable(self):
self.assertContains(response, 'share your story yo')
self.assertNotContains(response, 'Take the Survey')

def test_correct_intro_shows_on_homepage(self):
molo_survey_page, molo_survey_form_field = \
self.create_molo_survey_page(
parent=self.surveys_index,
homepage_button_text='share your story yo')
self.client.login(username='tester', password='tester')
response = self.client.get('/')
self.assertContains(response, 'Shorter homepage introduction')
self.assertNotContains(response, 'Take the Survey')

def test_anonymous_submissions_not_allowed_by_default(self):
molo_survey_page, molo_survey_form_field = \
self.create_molo_survey_page(parent=self.section_index)
Expand Down Expand Up @@ -326,7 +337,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.introduction)
self.assertContains(response, molo_survey_page.homepage_introduction)
user = User.objects.create_superuser(
username='testuser', password='password', email='test@email.com')
self.client2.login(user=user)
Expand All @@ -338,7 +349,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.introduction)
self.assertContains(response, molo_survey_page.homepage_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 +454,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.introduction)
self.assertContains(response, molo_survey_page.homepage_introduction)

def test_translated_survey_on_section_page(self):
self.user = self.login()
Expand Down Expand Up @@ -481,7 +492,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.introduction)
self.assertContains(response, molo_survey_page.homepage_introduction)

def test_survey_list_display_direct_logged_out(self):
molo_survey_page, molo_survey_form_field = \
Expand Down