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.
Merge pull request #91 from praekelt/feature/rearrange-content-panels
add molopage to survey page, rearrange content panels
- Loading branch information
Showing
10 changed files
with
145 additions
and
31 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
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'), | ||
), | ||
] |
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
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,78 @@ | ||
from django.test import TestCase, Client | ||
|
||
from molo.core.models import Main, SiteLanguageRelation, Languages | ||
from molo.core.tests.base import MoloTestCaseMixin | ||
from molo.core.utils import generate_slug | ||
from molo.surveys.models import ( | ||
SurveysIndexPage, | ||
MoloSurveyPage, | ||
MoloSurveyFormField | ||
) | ||
from wagtail.wagtailcore.models import Site | ||
|
||
|
||
class TestSites(TestCase, MoloTestCaseMixin): | ||
|
||
def setUp(self): | ||
self.mk_main() | ||
self.main = Main.objects.all().first() | ||
self.english = SiteLanguageRelation.objects.create( | ||
language_setting=Languages.for_site(self.main.get_site()), | ||
locale='en', | ||
is_active=True) | ||
self.yourmind = self.mk_section( | ||
self.section_index, title='Your mind') | ||
self.surveys_index = SurveysIndexPage.objects.child_of( | ||
self.main).first() | ||
|
||
def create_molo_survey_page(self, parent, **kwargs): | ||
molo_survey_page = MoloSurveyPage( | ||
title='Test Survey', slug='test-survey', | ||
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() | ||
molo_survey_form_field = MoloSurveyFormField.objects.create( | ||
page=molo_survey_page, | ||
sort_order=1, | ||
label='Your favourite animal', | ||
field_type='singleline', | ||
required=True | ||
) | ||
return molo_survey_page, molo_survey_form_field | ||
|
||
def test_two_sites_point_to_one_root_page(self): | ||
# assert that there is only one site rooted at main | ||
self.assertEquals(self.main.sites_rooted_here.count(), 1) | ||
client_1 = Client() | ||
# add a site that points to the same root page | ||
site_2 = Site.objects.create( | ||
hostname=generate_slug('site2'), port=80, root_page=self.main) | ||
# create a link buetween the current langauges and the new site | ||
Languages.objects.create( | ||
site_id=site_2.pk) | ||
SiteLanguageRelation.objects.create( | ||
language_setting=Languages.for_site(site_2), | ||
locale='en', | ||
is_active=True) | ||
client_2 = Client(HTTP_HOST=site_2.hostname) | ||
|
||
# assert that there are now two sites rooted at main | ||
self.assertEquals(self.main.sites_rooted_here.count(), 2) | ||
|
||
# create molo survey page | ||
molo_survey_page, molo_survey_form_field = \ | ||
self.create_molo_survey_page( | ||
parent=self.surveys_index, | ||
homepage_button_text='share your story yo') | ||
|
||
# assert that both sites render the survey | ||
response = client_1.get('/surveys-main-1/test-survey/') | ||
self.assertEquals(response.status_code, 200) | ||
response = client_2.get( | ||
site_2.root_url + '/surveys-main-1/test-survey/') | ||
self.assertEquals(response.status_code, 200) |
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