Beispiel #1
0
 def is_valid(self):
     management.check_authorized_relationship(self.parent,
                                              self.link,
                                              to_delete=True)
     if self._get_options_to_detach() and self.get_parents_program_master():
         self._check_detatch_options_rules()
     return True
Beispiel #2
0
    def clean_link_type(self):
        """
        All of these controls only work with child branch.
        The validation with learning_units (child_leaf) is in the model.
        """
        data_cleaned = self.cleaned_data.get('link_type')
        if not self.instance.child_branch:
            return data_cleaned

        try:
            new_link = GroupElementYear(child_branch=self.instance.child_branch, link_type=data_cleaned)
            check_authorized_relationship(self.instance.parent, new_link)
        except AuthorizedRelationshipNotRespectedException as e:
            raise ValidationError(e.errors)
        return data_cleaned
Beispiel #3
0
    def clean_link_type(self):
        """
        All of these controls only work with child branch.
        The validation with learning_units (child_leaf) is in the model.
        """
        data_cleaned = self.cleaned_data.get('link_type')
        if not self.instance.child_branch:
            return data_cleaned

        try:
            new_link = GroupElementYear(
                child_branch=self.instance.child_branch,
                link_type=data_cleaned)
            check_authorized_relationship(self.instance.parent, new_link)
        except AuthorizedRelationshipNotRespectedException as e:
            raise ValidationError(e.errors)
        return data_cleaned
Beispiel #4
0
 def test_when_limit_respected(self):
     self.create_authorized_relationship()
     check_authorized_relationship(self.parent_egy, self.new_link)
Beispiel #5
0
    def test_should_raise_exception_when_min_count_subceeded(self):
        self.create_authorized_relationship(min_count=3)

        with self.assertRaises(AuthorizedRelationshipNotRespectedException):
            check_authorized_relationship(self.parent_egy, self.new_link)
Beispiel #6
0
 def test_when_no_authorized_relationship(self):
     with self.assertRaises(AuthorizedRelationshipNotRespectedException):
         check_authorized_relationship(self.parent_egy, self.new_link)
Beispiel #7
0
 def is_valid(self):
     management.check_authorized_relationship(self.parent, self.link, to_delete=True)
     if self._get_options_to_detach() and self.get_parents_program_master():
         self._check_detatch_options_rules()
     return True