예제 #1
0
파일: detach.py 프로젝트: aelwhishi/osis
 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
예제 #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
예제 #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
예제 #4
0
 def test_when_limit_respected(self):
     self.create_authorized_relationship()
     check_authorized_relationship(self.parent_egy, self.new_link)
예제 #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)
예제 #6
0
 def test_when_no_authorized_relationship(self):
     with self.assertRaises(AuthorizedRelationshipNotRespectedException):
         check_authorized_relationship(self.parent_egy, self.new_link)
예제 #7
0
파일: detach.py 프로젝트: uclouvain/osis
 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