Skip to content
Snippets Groups Projects
Commit b30d1a73 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add workflow and test we can get the class from the fund

parent 270d76d9
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-12-19 12:09
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('apply', '0002_fund_workflow'),
]
operations = [
migrations.AlterField(
model_name='fund',
name='workflow',
field=models.CharField(choices=[('single', 'Single Stage'), ('double', 'Two Stage')], default='single', max_length=100),
),
]
......@@ -8,6 +8,10 @@ from opentech.utils.models import SocialFields, ListingFields
from .workflow import SingleStage, DoubleStage
WORKFLOW_CLASS = {
SingleStage.name: SingleStage,
DoubleStage.name: DoubleStage,
}
class ApplyHomePage(Page, SocialFields, ListingFields):
# Only allow creating HomePages at the root level
......@@ -32,9 +36,13 @@ class ApplyHomePage(Page, SocialFields, ListingFields):
class FundPage(Page):
parent_page_types = [ApplyHomePage]
WORKFLOWS = (
('single', SingleStage),
('double', DoubleStage),
('single', SingleStage.name),
('double', DoubleStage.name),
)
name = models.CharField(max_length=60)
workflow = models.CharField(choices=WORKFLOWS, max_length=100, default=WORKFLOWS[0][0])
@property
def workflow_class(self):
return WORKFLOW_CLASS[self.get_workflow_display()]
from django.test import TestCase
from opentech.apply.models import Fund
from opentech.apply.workflow import SingleStage
class TestFundModel(TestCase):
def test_can_access_workflow_class(self):
fund = Fund.objects.create(name='Internet Freedom Fund')
self.assertEqual(fund.workflow, 'single')
self.assertEqual(fund.workflow_class, SingleStage)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment