Skip to content

Commit

Permalink
wip: Adding more checkers up to and including WMO
Browse files Browse the repository at this point in the history
  • Loading branch information
miggol committed Aug 19, 2024
1 parent 6c46870 commit 60cd6f7
Showing 1 changed file with 107 additions and 2 deletions.
109 changes: 107 additions & 2 deletions proposals/utils/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __call__(self, *args, **kwargs):
def check(self):
"""
This method gets called to process an item in the proposal creation
process. It finall returns a list of checkers with which to continue
process. It finally returns a list of checkers with which to continue
the checking process. This list can be empty.
"""
return []
Expand Down Expand Up @@ -252,10 +252,115 @@ class OtherResearchersChecker(

def check(self):
self.stepper.items.append(self.make_stepper_item())
return []
return [
FundingChecker(
self.stepper,
parent=self.parent,
)
]

def get_url(self):
return reverse(
"proposals:other_researchers",
args=(self.proposal.pk,),
)


class FundingChecker(
ModelFormChecker,
):
title = _("Financiering")
form_class = forms.FundingForm

def check(self):
self.stepper.items.append(self.make_stepper_item())
return [
GoalChecker(
self.stepper,
parent=self.parent,
)
]

def get_url(self):
return reverse(
"proposals:funding",
args=(self.proposal.pk,),
)

class GoalChecker(
ModelFormChecker,
):
title = _("Onderzoeksdoel")
form_class = forms.ResearchGoalForm

def check(self):
self.stepper.items.append(self.make_stepper_item())
return [WMOChecker]

def get_url(self):
return reverse(
"proposals:research_goal",
args=(self.proposal.pk,),
)

class WMOItem(
StepperItem,
):
location = "wmo"
title = _("WMO")

def __init__(
self,
*args,
**kwargs,
):
super().__init__(*args, **kwargs)
self.proposal = self.stepper.proposal
self.wmo = self.get_wmo()

def get_wmo(self,):
if hasattr(
self.proposal,
"wmo",
):
return self.proposal.wmo
return None

def get_url(self,):
if self.wmo:
return reverse(
"proposals:wmo_update",
args=[self.wmo.pk],
)
else:
return reverse(
"proposals:wmo_create",
args=[self.proposal.pk],
)

def wmo_exists(self,):
return hasattr(
self.proposal,
"wmo",
)


class WMOChecker(
Checker,
):

def check(self,):
self.item = WMOItem(self.stepper)
self.stepper.items.append(self.item)
if self.item.wmo:
return self.check_wmo()
else:
return []

def check_wmo(self,):
"""
This method should check the correctness of the
WMO object.
"""
# Just assume any WMO is correct as long as it exists
return [] # TODO next item

0 comments on commit 60cd6f7

Please sign in to comment.