Esempio n. 1
0
def _is_eligible_to_add_education_group(person, education_group, category, education_group_type=None,
                                        raise_exception=False):
    return check_permission(person, "base.add_educationgroup", raise_exception) and \
           _is_eligible_to_add_education_group_with_category(person, category, raise_exception) and \
           _is_eligible_education_group(person, education_group, raise_exception) and \
           (not management.is_max_child_reached(education_group, education_group_type.name)
            if education_group_type and education_group
            else check_authorized_type(education_group, category, raise_exception))
Esempio n. 2
0
 def clean_name(self):
     education_group_type = self.cleaned_data.get("name")
     if education_group_type:
         if self.parent and management.is_max_child_reached(self.parent, education_group_type.name):
             raise ValidationError(_("The number of children of type \"%(child_type)s\" for \"%(parent)s\" "
                                     "has already reached the limit.") % {
                 'child_type': education_group_type,
                 'parent': self.parent
             })
     return education_group_type
Esempio n. 3
0
def _is_eligible_to_add_education_group(person,
                                        education_group,
                                        category,
                                        education_group_type=None,
                                        raise_exception=False):
    return check_permission(person, "base.add_educationgroup", raise_exception) and \
           _is_eligible_to_add_education_group_with_category(person, category, raise_exception) and \
           _is_eligible_education_group(person, education_group, raise_exception) and \
           (not management.is_max_child_reached(education_group, education_group_type.name)
            if education_group_type and education_group
            else check_authorized_type(education_group, category, raise_exception))
Esempio n. 4
0
 def clean_name(self):
     education_group_type = self.cleaned_data.get("name")
     if education_group_type:
         if self.parent and management.is_max_child_reached(
                 self.parent, education_group_type.name):
             raise ValidationError(
                 _("The number of children of type \"%(child_type)s\" for \"%(parent)s\" "
                   "has already reached the limit.") % {
                       'child_type': education_group_type,
                       'parent': self.parent
                   })
     return education_group_type