diff --git a/opentech/apply/models.py b/opentech/apply/models.py index f7833f4195d1f54d30cb7bd295c5abd3900abfac..29728c26911b5a1c24806b2dbcecb002db6d0fe9 100644 --- a/opentech/apply/models.py +++ b/opentech/apply/models.py @@ -2,7 +2,6 @@ from django.db import models from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.models import Page from wagtail.wagtailsearch import index -from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel from opentech.utils.models import SocialFields, ListingFields @@ -14,6 +13,7 @@ WORKFLOW_CLASS = { DoubleStage.name: DoubleStage, } + class ApplyHomePage(Page, SocialFields, ListingFields): # Only allow creating HomePages at the root level parent_page_types = ['wagtailcore.Page'] diff --git a/opentech/apply/tests/factories.py b/opentech/apply/tests/factories.py index a4f2cbd4066d2c7d9e8c754f95b5ad8dddf8910c..ab8339646d1f65b3c82fb8a3ed69e076f5b6671a 100644 --- a/opentech/apply/tests/factories.py +++ b/opentech/apply/tests/factories.py @@ -1,6 +1,8 @@ from django.forms import Form import factory +import wagtail_factories +from opentech.apply.models import FundPage from opentech.apply.workflow import Action, Phase, Stage, Workflow @@ -107,3 +109,8 @@ class WorkflowFactory(factory.Factory): stages = kwargs.pop('stage_classes') new_class = type(model_class.__name__, (model_class,), {'name': name, 'stage_classes': stages}) return new_class(*args, **kwargs) + + +class FundPageFactory(wagtail_factories.PageFactory): + class Meta: + model = FundPage diff --git a/opentech/apply/tests/test_models.py b/opentech/apply/tests/test_models.py index 60b2ca2332e499477ca07a71b6dbae21dd88d399..355f9a5a9455ba8f77a206e4bcb86291f054b1cb 100644 --- a/opentech/apply/tests/test_models.py +++ b/opentech/apply/tests/test_models.py @@ -1,11 +1,12 @@ from django.test import TestCase -from opentech.apply.models import Fund from opentech.apply.workflow import SingleStage +from .factories import FundPageFactory + class TestFundModel(TestCase): def test_can_access_workflow_class(self): - fund = Fund.objects.create(name='Internet Freedom Fund') + fund = FundPageFactory(parent=None) self.assertEqual(fund.workflow, 'single') self.assertEqual(fund.workflow_class, SingleStage) diff --git a/opentech/settings/dev.py b/opentech/settings/dev.py index 8992be6f89213411348fed870a91766d5ff96083..c0dbe1a8ffcf708e280843c6c24d6b09a0cc113e 100644 --- a/opentech/settings/dev.py +++ b/opentech/settings/dev.py @@ -8,7 +8,7 @@ SECRET_KEY = 'CHANGEME!!!' INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') -ALLOWED_HOSTS= ['apply.localhost', 'localhost', '127.0.0.1'] +ALLOWED_HOSTS = ['apply.localhost', 'localhost', '127.0.0.1'] BASE_URL = 'http://localhost:8000' diff --git a/requirements.txt b/requirements.txt index c05b0f8260d8df0214a80c2d4655b75c673ad5dc..b4faca247b766cd071cf0f20e18e3861dcb15956 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ wagtail-django-recaptcha==0.1 uwsgidecorators==1.1.0 mypy==0.550 factory_boy==2.9.2 +wagtail_factories==0.3.0 flake8 # Production dependencies