Beispiel #1
0
 def test_is_not_eligible_to_modify_cause_user_is_administrative_manager(
         self):
     administrative_manager = AdministrativeManagerFactory()
     luy = LearningUnitYearFactory(learning_unit=self.learning_unit,
                                   learning_container_year=self.lcy)
     self.assertFalse(
         is_eligible_for_modification(luy, administrative_manager))
Beispiel #2
0
    def test_cannot_faculty_manager_modify_full(self):
        for proposal_needed_container_type in TYPES_PROPOSAL_NEEDED_TO_EDIT:
            lunit_container_yr = LearningContainerYearFactory(academic_year=self.academic_year_6,
                                                              container_type=proposal_needed_container_type)
            luy = LearningUnitYearFactory(academic_year=self.academic_year_6,
                                          learning_container_year=lunit_container_yr,
                                          subtype=FULL)

            self.assertFalse(perms.is_eligible_for_modification(luy, self.create_person_with_permission_and_group(FACULTY_MANAGER_GROUP)))
Beispiel #3
0
 def f_can_perform_learning_unit_modification(request,
                                              learning_unit_year_id, *args,
                                              **kwargs):
     learn_unit_year = get_object_or_404(
         learning_unit_year.LearningUnitYear, pk=learning_unit_year_id)
     pers = get_object_or_404(Person, user=request.user)
     if not business_perms.is_eligible_for_modification(
             learn_unit_year, pers):
         raise PermissionDenied("Learning unit year cannot be modified.")
     return view_func(request, learning_unit_year_id, *args, **kwargs)
Beispiel #4
0
    def get_context_permission(self, proposal):
        context = {
            "can_create_partim": is_eligible_to_create_partim(self.object, self.person),
            'can_manage_volume': is_eligible_for_modification(self.object, self.person),
        }

        # append permissions
        context.update(learning_unit_year_permissions(self.object, self.person))
        context.update(learning_unit_proposal_permissions(proposal, self.person, self.object))

        return context
Beispiel #5
0
 def test_when_existing_proposal_in_epc(self):
     luy = LearningUnitYearFactory(
         academic_year=self.academic_yr,
         learning_unit__existing_proposal_in_epc=True)
     self.assertFalse(perms.is_eligible_for_modification(luy, None))
     self.assertFalse(perms.is_eligible_for_modification_end_date(
         luy, None))
     self.assertFalse(perms.is_eligible_to_create_partim(luy, None))
     self.assertFalse(
         perms.is_eligible_to_create_modification_proposal(luy, None))
     self.assertFalse(
         perms.is_eligible_to_delete_learning_unit_year(luy, None))
Beispiel #6
0
def learning_unit_components(request, learning_unit_year_id):
    person = get_object_or_404(Person, user=request.user)
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    context['components'] = get_same_container_year_components(
        context['learning_unit_year'], True)
    context['tab_active'] = 'components'
    context['can_manage_volume'] = business_perms.is_eligible_for_modification(
        context["learning_unit_year"], person)
    context['experimental_phase'] = True
    return layout.render(request, "learning_unit/components.html", context)
Beispiel #7
0
def learning_unit_components(request, learning_unit_year_id):
    person = get_object_or_404(Person, user=request.user)
    context = get_common_context_learning_unit_year(learning_unit_year_id, person)
    learning_unit_year = context['learning_unit_year']
    context['warnings'] = learning_unit_year.warnings
    data_components = get_same_container_year_components(context['learning_unit_year'])
    context['components'] = data_components.get('components')
    context['REQUIREMENT_ENTITY'] = data_components.get('REQUIREMENT_ENTITY')
    context['ADDITIONAL_REQUIREMENT_ENTITY_1'] = data_components.get('ADDITIONAL_REQUIREMENT_ENTITY_1')
    context['ADDITIONAL_REQUIREMENT_ENTITY_2'] = data_components.get('ADDITIONAL_REQUIREMENT_ENTITY_2')
    context['tab_active'] = 'components'
    context['can_manage_volume'] = business_perms.is_eligible_for_modification(context["learning_unit_year"], person)
    return render(request, "learning_unit/components.html", context)
Beispiel #8
0
 def test_when_existing_proposal_in_epc(self):
     a_person = create_person_with_permission_and_group(
         CENTRAL_MANAGER_GROUP)
     luy = LearningUnitYearFactory(
         academic_year=self.academic_yr,
         learning_unit__existing_proposal_in_epc=True)
     self.assertFalse(perms.is_eligible_for_modification(luy, a_person))
     self.assertFalse(
         perms.is_eligible_for_modification_end_date(luy, a_person))
     self.assertFalse(perms.is_eligible_to_create_partim(luy, a_person))
     self.assertFalse(
         perms.is_eligible_to_create_modification_proposal(luy, a_person))
     self.assertFalse(
         perms.is_eligible_to_delete_learning_unit_year(luy, a_person))
Beispiel #9
0
def get_learning_unit_identification_context(learning_unit_year_id, person):
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    learning_unit_year = context['learning_unit_year']
    context['warnings'] = learning_unit_year.warnings
    proposal = proposal_learning_unit.find_by_learning_unit(
        learning_unit_year.learning_unit)

    context["can_create_partim"] = is_eligible_to_create_partim(
        learning_unit_year, person)
    context[
        'learning_container_year_partims'] = learning_unit_year.get_partims_related(
        )
    context['organization'] = get_organization_from_learning_unit_year(
        learning_unit_year)
    context['campus'] = learning_unit_year.campus
    context['experimental_phase'] = True
    context.update(get_all_attributions(learning_unit_year))
    components = get_components_identification(learning_unit_year)
    context['components'] = components.get('components')
    context['REQUIREMENT_ENTITY'] = components.get('REQUIREMENT_ENTITY')
    context['ADDITIONAL_REQUIREMENT_ENTITY_1'] = components.get(
        'ADDITIONAL_REQUIREMENT_ENTITY_1')
    context['ADDITIONAL_REQUIREMENT_ENTITY_2'] = components.get(
        'ADDITIONAL_REQUIREMENT_ENTITY_2')
    context['proposal'] = proposal
    context[
        'proposal_folder_entity_version'] = mdl.entity_version.get_by_entity_and_date(
            proposal.entity, None) if proposal else None
    context['differences'] = get_difference_of_proposal(proposal, learning_unit_year) \
        if proposal and proposal.learning_unit_year == learning_unit_year \
        else {}

    # append permissions
    context.update(learning_unit_year_permissions(learning_unit_year, person))
    context.update(
        learning_unit_proposal_permissions(proposal, person,
                                           learning_unit_year))
    context['can_manage_volume'] = is_eligible_for_modification(
        context["learning_unit_year"], person)

    return context
Beispiel #10
0
def get_learning_unit_identification_context(learning_unit_year_id, person):
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    learning_unit_year = context['learning_unit_year']
    proposal = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)

    context[
        'learning_container_year_partims'] = learning_unit_year.get_partims_related(
        )
    context['organization'] = get_organization_from_learning_unit_year(
        learning_unit_year)
    context['campus'] = get_campus_from_learning_unit_year(learning_unit_year)
    context['experimental_phase'] = True
    context['show_subtype'] = show_subtype(learning_unit_year)
    context.update(get_all_attributions(learning_unit_year))
    context['components'] = get_components_identification(learning_unit_year)
    context['proposal'] = proposal
    context[
        'proposal_folder_entity_version'] = mdl_base.entity_version.get_by_entity_and_date(
            proposal.folder.entity, None) if proposal else None
    context['differences'] = _get_difference_of_proposal(proposal)

    # perms learning unit
    context['can_propose'] = is_eligible_to_create_modification_proposal(
        learning_unit_year, person)
    context['can_edit_date'] = is_eligible_for_modification_end_date(
        learning_unit_year, person)
    context['can_edit'] = is_eligible_for_modification(learning_unit_year,
                                                       person)
    context['can_delete'] = can_delete_learning_unit_year(
        learning_unit_year, person)

    # perms proposal
    context['can_cancel_proposal'] = is_eligible_for_cancel_of_proposal(
        proposal, person)
    context['can_edit_learning_unit_proposal'] = is_eligible_to_edit_proposal(
        proposal, person)

    return context
Beispiel #11
0
 def test_is_not_eligible_to_modify_cause_user_is_administrative_manager(
         self):
     administrative_manager = AdministrativeManagerFactory()
     self.assertFalse(
         is_eligible_for_modification(self.luy, administrative_manager))