Skip to content

Commit

Permalink
Merge pull request #1133 from jefmoura/461-add-tolatables-factory
Browse files Browse the repository at this point in the history
Create TolaTable factory
  • Loading branch information
jefmoura authored Aug 16, 2018
2 parents 4c24d96 + 58d6cf2 commit 9b12a36
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions factories/indicators_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PeriodicTarget as PeriodicTargetM,
ReportingPeriod as ReportingPeriodM,
StrategicObjective as StrategicObjectiveM,
TolaTable as TolaTableM,
)
from .workflow_models import (Organization, WorkflowLevel1)

Expand Down Expand Up @@ -137,3 +138,33 @@ class Meta:
class PeriodicTarget(DjangoModelFactory):
class Meta:
model = PeriodicTargetM


class TolaTable(DjangoModelFactory):
class Meta:
model = TolaTableM

name = 'Table A'
organization = SubFactory(Organization)

@post_generation
def country(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return

if extracted:
# A list of country were passed in, use them
for country in extracted:
self.country.add(country)

@post_generation
def workflowlevel1(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return

if extracted:
# A list of workflowlevel1 were passed in, use them
for workflowlevel1 in extracted:
self.workflowlevel1.add(workflowlevel1)

0 comments on commit 9b12a36

Please sign in to comment.