Esempio n. 1
0
    def state_active_valid(self, intervention, user=None):
        self.check_required_fields(intervention)
        self.check_rigid_fields(intervention, related=True)

        today = date.today()
        if not (intervention.start <= today):
            raise StateValidError([_('Today is not after the start date')])
        if intervention.total_unicef_budget == 0:
            raise StateValidError([_('UNICEF Cash $ or UNICEF Supplies $ should not be 0')])
        return True
Esempio n. 2
0
    def state_ended_valid(self, intervention, user=None):
        self.check_required_fields(intervention)
        self.check_rigid_fields(intervention, related=True)

        today = date.today()
        if not today > intervention.end:
            raise StateValidError([_('Today is not after the end date')])
        return True
Esempio n. 3
0
 def check_rigid_fields(self, intervention, related=False):
     # this can be set if running in a task and old_instance is not set
     if self.disable_rigid_check:
         return
     rigid_fields = [f for f in self.permissions['edit'] if self.permissions['edit'][f] is False]
     rigid_valid, field = check_rigid_fields(intervention, rigid_fields, related=related)
     if not rigid_valid:
         raise StateValidError(['Cannot change fields while in {}: {}'.format(intervention.status, field)])
Esempio n. 4
0
    def state_ended_valid(self, agreement, user=None):
        # for SSFAs there will be no states valid since the states are forced by the Interventions
        # Once signed, nothing will be editable on the agreement level
        if agreement.agreement_type == agreement.SSFA:
            return False

        self.check_required_fields(agreement)
        self.check_rigid_fields(agreement, related=True)
        today = date.today()
        if not today > agreement.end:
            raise StateValidError([_('Today is not after the end date')])
        return True
Esempio n. 5
0
 def check_required_fields(self, intervention):
     required_fields = [
         f for f in self.permissions['required']
         if self.permissions['required'][f] is True
     ]
     required_valid, field = check_required_fields(intervention,
                                                   required_fields)
     if not required_valid:
         raise StateValidError([
             'Required fields not completed in {}: {}'.format(
                 intervention.status, field)
         ])
Esempio n. 6
0
 def test_state_valid_error(self):
     '''Ensure StateValidError inherits from _BaseStateError'''
     self.assertIsInstance(StateValidError(), _BaseStateError)
Esempio n. 7
0
 def state_signed_valid(self, intervention, user=None):
     self.check_required_fields(intervention)
     self.check_rigid_fields(intervention, related=True)
     if intervention.total_unicef_budget == 0:
         raise StateValidError([_('UNICEF Cash $ or UNICEF Supplies $ should not be 0')])
     return True