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

Add the workflow to the round on save

parent 31c28236
No related branches found
No related tags found
No related merge requests found
...@@ -223,6 +223,12 @@ class Round(SubmittableStreamForm): ...@@ -223,6 +223,12 @@ class Round(SubmittableStreamForm):
], heading="Dates") ], heading="Dates")
] ]
def save(self, *args, **kwargs):
if hasattr(self, 'parent_page'):
# We attached the parent page as part of the before_create_hook
self.workflow = self.parent_page.workflow
super().save(*args, **kwargs)
def get_submit_meta_data(self, **kwargs): def get_submit_meta_data(self, **kwargs):
return super().get_submit_meta_data( return super().get_submit_meta_data(
page=self.get_parent(), page=self.get_parent(),
......
...@@ -68,7 +68,7 @@ class TestFundModel(TestCase): ...@@ -68,7 +68,7 @@ class TestFundModel(TestCase):
self.assertEqual(self.fund.open_round, None) self.assertEqual(self.fund.open_round, None)
class TestRoundModel(TestCase): class TestRoundModelDates(TestCase):
def setUp(self): def setUp(self):
self.fund = FundTypeFactory(parent=None) self.fund = FundTypeFactory(parent=None)
...@@ -139,6 +139,18 @@ class TestRoundModel(TestCase): ...@@ -139,6 +139,18 @@ class TestRoundModel(TestCase):
new_round.clean() new_round.clean()
class TestRoundModelWorkflowAndForms(TestCase):
def setUp(self):
self.fund = FundTypeFactory(parent=None)
# we only add parent_page on create, so if the object exists already this should not affect testing
self.round = RoundFactory()
self.round.parent_page = self.fund
def test_workflow_is_copied_to_new_rounds(self):
self.round.save()
self.assertEqual(self.round.workflow, self.fund.workflow)
class TestFormSubmission(TestCase): class TestFormSubmission(TestCase):
def setUp(self): def setUp(self):
self.site = Site.objects.first() self.site = Site.objects.first()
......
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