Exemple #1
0
 def test_is_not_eligible_for_cancel_of_proposal(self):
     luy = LearningUnitYearFactory(academic_year=self.academic_yr)
     an_entity_container_year = EntityContainerYearFactory(
         learning_container_year=luy.learning_container_year,
         type=entity_container_year_link_type.REQUIREMENT_ENTITY)
     a_person = self.create_person_with_permission_and_group()
     a_proposal = ProposalLearningUnitFactory(
         learning_unit_year=luy,
         type=proposal_type.ProposalType.SUPPRESSION.name,
         state=proposal_state.ProposalState.CENTRAL.name,
         initial_data={
             "entities": {
                 entity_container_year_link_type.REQUIREMENT_ENTITY:
                 an_entity_container_year.entity.id,
             }
         })
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
     a_proposal.state = proposal_state.ProposalState.FACULTY.name
     a_proposal.save()
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
     a_proposal.type = proposal_type.ProposalType.MODIFICATION.name
     a_proposal.save()
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
Exemple #2
0
 def test_is_not_eligible_for_cancel_of_proposal(self):
     luy = LearningUnitYearFactory(academic_year=self.academic_yr)
     an_entity = EntityFactory()
     luy.learning_container_year.requirement_entity = an_entity
     luy.learning_container_year.save()
     a_person = create_person_with_permission_and_group()
     a_proposal = ProposalLearningUnitFactory(
         learning_unit_year=luy,
         type=proposal_type.ProposalType.SUPPRESSION.name,
         state=proposal_state.ProposalState.CENTRAL.name,
         initial_data={
             "learning_container_year": {
                 "requirement_entity": an_entity.id,
             }
         })
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
     a_proposal.state = proposal_state.ProposalState.FACULTY.name
     a_proposal.save()
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
     a_proposal.type = proposal_type.ProposalType.MODIFICATION.name
     a_proposal.save()
     self.assertFalse(
         perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
Exemple #3
0
    def test_is_eligible_for_cancel_of_proposal_wrong_state(self):
        generated_container = GenerateContainer(
            start_year=self.academic_yr.year, end_year=self.academic_yr.year)
        generated_container_first_year = generated_container.generated_container_years[
            0]
        an_requirement_entity = generated_container_first_year.requirement_entity_container_year.entity

        luy = generated_container_first_year.learning_unit_year_full
        a_person = self.create_person_with_permission_and_group(
            FACULTY_MANAGER_GROUP, 'can_propose_learningunit')

        a_proposal = ProposalLearningUnitFactory(
            learning_unit_year=luy,
            type=proposal_type.ProposalType.MODIFICATION.name,
            state=proposal_state.ProposalState.CENTRAL.name,
            initial_data={
                "entities": {
                    entity_container_year_link_type.REQUIREMENT_ENTITY:
                    an_requirement_entity.id,
                }
            })

        PersonEntityFactory(person=a_person, entity=an_requirement_entity)
        self.assertFalse(
            perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
Exemple #4
0
    def test_is_eligible_for_cancel_of_proposal_wrong_state(self):
        generated_container = GenerateContainer(
            start_year=self.academic_yr.year, end_year=self.academic_yr.year)
        generated_container_first_year = generated_container.generated_container_years[
            0]
        an_requirement_entity = generated_container_first_year.requirement_entity_container_year

        luy = generated_container_first_year.learning_unit_year_full

        faculty_managers = [
            create_person_with_permission_and_group(
                FACULTY_MANAGER_GROUP, 'can_propose_learningunit'),
            create_person_with_permission_and_group(
                UE_FACULTY_MANAGER_GROUP, 'can_propose_learningunit')
        ]

        a_proposal = ProposalLearningUnitFactory(
            learning_unit_year=luy,
            type=proposal_type.ProposalType.MODIFICATION.name,
            state=proposal_state.ProposalState.CENTRAL.name,
            initial_data={
                "learning_container_year": {
                    "requirement_entity": an_requirement_entity.id,
                }
            })

        for manager in faculty_managers:
            PersonEntityFactory(person=manager, entity=an_requirement_entity)
            self.assertFalse(
                perms.is_eligible_for_cancel_of_proposal(a_proposal, manager))
Exemple #5
0
 def f_can_perform_cancel_proposal(request, learning_unit_year_id):
     learning_unit_proposal = get_object_or_404(
         ProposalLearningUnit, learning_unit_year__id=learning_unit_year_id)
     pers = get_object_or_404(Person, user=request.user)
     if not business_perms.is_eligible_for_cancel_of_proposal(
             learning_unit_proposal, pers):
         raise PermissionDenied(
             "Learning unit proposal cannot be cancelled.")
     return view_func(request, learning_unit_year_id)
Exemple #6
0
    def test_is_eligible_for_cancel_of_proposal_for_creation(self):
        generated_container = GenerateContainer(start_year=self.academic_yr.year,
                                                end_year=self.academic_yr.year)
        generated_container_first_year = generated_container.generated_container_years[0]
        an_requirement_entity = generated_container_first_year.requirement_entity_container_year.entity

        luy = generated_container_first_year.learning_unit_year_full
        a_person = self.create_person_with_permission_and_group(FACULTY_MANAGER_GROUP,
                                                                'can_propose_learningunit')

        a_proposal = ProposalLearningUnitFactory(learning_unit_year=luy,
                                                 type=proposal_type.ProposalType.CREATION.name,
                                                 state=proposal_state.ProposalState.FACULTY.name)

        PersonEntityFactory(person=a_person, entity=an_requirement_entity)
        self.assertTrue(perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
Exemple #7
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
Exemple #8
0
    def test_is_eligible_for_cancel_of_proposal_as_central_manager(self):
        generated_container = GenerateContainer(
            start_year=self.academic_yr.year, end_year=self.academic_yr.year)
        generated_container_first_year = generated_container.generated_container_years[
            0]
        an_requirement_entity = generated_container_first_year.requirement_entity_container_year

        luy = generated_container_first_year.learning_unit_year_full
        a_person = create_person_with_permission_and_group(
            CENTRAL_MANAGER_GROUP, 'can_propose_learningunit')

        a_proposal = ProposalLearningUnitFactory(
            learning_unit_year=luy,
            type=proposal_type.ProposalType.MODIFICATION.name,
            state=proposal_state.ProposalState.CENTRAL.name,
            initial_data={
                "learning_container_year": {
                    "requirement_entity": an_requirement_entity.id,
                }
            })
        PersonEntityFactory(person=a_person, entity=an_requirement_entity)
        self.assertTrue(
            perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))