예제 #1
0
    def test_has_person_the_right_to_add_education_group(self):
        person_without_right = PersonFactory()
        self.assertFalse(
            check_permission(person_without_right, "base.add_educationgroup"))

        person_with_right = PersonWithPermissionsFactory("add_educationgroup")
        self.assertTrue(
            check_permission(person_with_right, "base.add_educationgroup"))
예제 #2
0
def can_user_edit_administrative_data(a_user,
                                      an_education_group_year,
                                      raise_exception=False):
    """
    Edition of administrative data is allowed for user which have permission AND
            if CENTRAL_MANAGER: Check attached entities [person_entity]
            else Check if user is program manager of education group
    """

    # Tricky solution to make compatible several uses
    if isinstance(a_user, Person):
        person = a_user
        a_user = person.user
    else:
        person = Person.objects.get(user=a_user)

    if not check_permission(
            person, "base.can_edit_education_group_administrative_data",
            raise_exception):
        return False

    if person.is_central_manager() and _is_management_entity_linked_to_user(
            person, an_education_group_year):
        return True

    return is_program_manager(
        a_user, education_group=an_education_group_year.education_group)
예제 #3
0
def can_user_edit_administrative_data(a_user, an_education_group_year, raise_exception=False):
    """
    Edition of administrative data is allowed for user which have permission AND
            if CENTRAL_MANAGER: Check attached entities [person_entity]
            else Check if user is program manager of education group
    """

    # Tricky solution to make compatible several uses
    if isinstance(a_user, Person):
        person = a_user
        a_user = person.user
    else:
        person = Person.objects.get(user=a_user)

    if not check_permission(person, "base.can_edit_education_group_administrative_data", raise_exception):
        return False

    if person.is_central_manager and _is_management_entity_linked_to_user(person, an_education_group_year):
        return True

    return is_program_manager(a_user, education_group=an_education_group_year.education_group)
예제 #4
0
파일: perms.py 프로젝트: allouchmed/osis
def is_eligible_to_update_group_element_year_content(person, group_element_year, raise_exception):
    result = check_permission(person, "base.change_educationgroupcontent", raise_exception) and \
         is_eligible_to_update_group_element_year(person, group_element_year, raise_exception)
    can_raise_exception(raise_exception, result, _("The user is not allowed to change education group content."))
    return result