Esempio n. 1
0
File: perms.py Progetto: dukku1/osis
def is_eligible_to_update_learning_unit_pedagogy(learning_unit_year, person):
    """
    Permission to edit learning unit pedagogy needs many conditions:
        - The person must have the permission can_edit_learning_pedagogy
        - The person must be link to requirement entity
        - The person can be a faculty or a central manager
        - The person can be a tutor:
            - The learning unit must have its flag summary_locked to false
            - The person must have an attribution for the learning unit year
            - The attribution must have its flag summary responsible to true.

    :param learning_unit_year: LearningUnitYear
    :param person: Person
    :return: bool
    """
    if not person.user.has_perm('base.can_edit_learningunit_pedagogy'):
        return False
    if is_year_editable(learning_unit_year, raise_exception=False):
        # Case faculty/central: We need to check if user is linked to entity
        if person.is_faculty_manager or person.is_central_manager:
            return person.is_linked_to_entity_in_charge_of_learning_unit_year(
                learning_unit_year)

        # Case Tutor: We need to check if today is between submission date
        if tutor.is_tutor(person.user):
            return can_user_edit_educational_information(
                user=person.user,
                learning_unit_year_id=learning_unit_year.id).is_valid()

    return False
Esempio n. 2
0
def is_eligible_to_update_learning_unit_pedagogy(learning_unit_year, person):
    """
    Permission to edit learning unit pedagogy needs many conditions:
        - The person must have the permission can_edit_learning_pedagogy
        - The person must be link to requirement entity
        - The person can be a faculty or a central manager
        - The person can be a tutor:
            - The learning unit must have its flag summary_locked to false
            - The person must have an attribution for the learning unit year
            - The attribution must have its flag summary responsible to true.

    :param learning_unit_year: LearningUnitYear
    :param person: Person
    :return: bool
    """
    if not person.user.has_perm('base.can_edit_learningunit_pedagogy'):
        return False

    # Case faculty/central: We need to check if user is linked to entity
    if person.is_faculty_manager or person.is_central_manager:
        return person.is_linked_to_entity_in_charge_of_learning_unit_year(learning_unit_year)

    # Case Tutor: We need to check if today is between submission date
    if tutor.is_tutor(person.user):
        return can_user_edit_educational_information(user=person.user, learning_unit_year_id=learning_unit_year.id). \
            is_valid()

    return False
Esempio n. 3
0
 def test_is_not_tutor(self):
     user_unknown = UserFactory()
     self.assertFalse(tutor.is_tutor(user_unknown))
Esempio n. 4
0
 def test_is_tutor(self):
     self.assertTrue(tutor.is_tutor(self.user))