예제 #1
0
 def save(self, commit=True):
     if hasattr(self.instance, 'learning_unit_year'):
         # When we save a creation_proposal, we do not need to save the initial_data
         if self.instance.type != ProposalType.CREATION.name and not self.instance.initial_data:
             self.instance.initial_data = copy_learning_unit_data(
                 get_by_id(self.instance.learning_unit_year.id))
     return super().save(commit)
예제 #2
0
    def test_when_proposal_of_type_modification_and_accepted_with_partim(self):
        old_academic_year = AcademicYearFactory(
            year=datetime.date.today().year - 2)
        current_academic_year = AcademicYearFactory(
            year=datetime.date.today().year)
        generator_container = GenerateContainer(old_academic_year,
                                                current_academic_year)
        generator_container.generated_container_years[
            0].learning_unit_year_full.learning_unit.end_year = None
        LearningUnitYearPartimFactory(
            learning_container_year=generator_container.
            generated_container_years[0].learning_unit_year_full.
            learning_container_year,
            academic_year=generator_container.generated_container_years[0].
            learning_unit_year_full.academic_year)

        proposal = ProposalLearningUnitFactory(
            state=proposal_state.ProposalState.ACCEPTED.name,
            type=proposal_type.ProposalType.MODIFICATION.name,
            learning_unit_year=generator_container.
            generated_container_years[0].learning_unit_year_full,
            initial_data=copy_learning_unit_data(
                generator_container.generated_container_years[0].
                learning_unit_year_full))

        consolidate_proposal(proposal)
        partim = proposal.learning_unit_year.get_partims_related()
        self.assertEqual(proposal.learning_unit_year.acronym,
                         partim[0].acronym[:-1])
예제 #3
0
파일: generic.py 프로젝트: ultrasound/osis
def step_impl(context, acronym, year, entity):
    luy = LearningUnitYear.objects.get(acronym=acronym,
                                       academic_year__year=year[:4])
    e = Entity.objects.filter(entityversion__acronym=entity).first()

    ProposalLearningUnitFactory(learning_unit_year=luy,
                                type=ProposalType.SUPPRESSION.name,
                                state=ProposalState.FACULTY.name,
                                entity=e,
                                initial_data=copy_learning_unit_data(luy))
예제 #4
0
    def test_get_data_from_initial_data(self):
        practical_component = LearningComponentYear.objects.filter(
            learning_unit_year=self.learning_unit_year_1,
            type=PRACTICAL_EXERCISES).first()
        lecturing_component = LearningComponentYear.objects.filter(
            learning_unit_year=self.learning_unit_year_1,
            type=LECTURING).first()

        actual_data = copy_learning_unit_data(self.learning_unit_year_1)
        self.learning_unit_year_1.proposallearningunit.initial_data = actual_data
        self.learning_unit_year_1.proposallearningunit.save()

        data = _get_data_from_initial_data(
            self.learning_unit_year_1.proposallearningunit.initial_data, True)

        to_test = []
        to_test.append((data[0], _('Initial data')))
        to_test.append((data[1], self.original_learning_unit_year_1.acronym))
        to_test.append((data[2], "{}   ({} {})".format(
            self.original_learning_unit_year_1.academic_year.name,
            _('End').lower(),
            self.original_learning_unit_year_1.learning_unit.end_year)
                        ))  # Attention, c'est l'id
        to_test.append((data[3],
                        self.original_learning_unit_year_1.
                        learning_container_year.get_container_type_display()))
        to_test.append(
            (data[4],
             translate_status(self.original_learning_unit_year_1.status)))
        to_test.append(
            (data[5],
             self.original_learning_unit_year_1.get_subtype_display()))
        to_test.append(
            (data[6],
             str(
                 _(self.original_learning_unit_year_1.
                   get_internship_subtype_display())) if
             self.original_learning_unit_year_1.internship_subtype else '-'))
        to_test.append(
            (data[7], str(self.original_learning_unit_year_1.credits)))
        to_test.append(
            (data[8], self.original_learning_unit_year_1.language.name
             or BLANK_VALUE))
        to_test.append((
            data[9],
            str(_(
                self.original_learning_unit_year_1.get_periodicity_display()))
            or BLANK_VALUE))
        to_test.append(
            (data[10], str(_(self.original_learning_unit_year_1.quadrimester))
             or BLANK_VALUE))
        to_test.append(
            (data[11], str(_(self.original_learning_unit_year_1.session))
             or BLANK_VALUE))
        to_test.append((data[12], self.original_learning_unit_year_1.
                        learning_container_year.common_title or BLANK_VALUE))
        to_test.append(
            (data[13], self.original_learning_unit_year_1.specific_title
             or BLANK_VALUE))
        to_test.append(
            (data[14], self.original_learning_unit_year_1.
             learning_container_year.common_title_english or BLANK_VALUE))
        to_test.append(
            (data[15],
             self.original_learning_unit_year_1.specific_title_english
             or BLANK_VALUE))

        to_test.append((data[16],
                        self.original_learning_unit_year_1.entities.get(
                            REQUIREMENT_ENTITY).acronym or BLANK_VALUE))
        to_test.append((data[17],
                        self.original_learning_unit_year_1.entities.get(
                            ALLOCATION_ENTITY).acronym or BLANK_VALUE))
        to_test.append((data[18],
                        self.original_learning_unit_year_1.entities.get(
                            ADDITIONAL_REQUIREMENT_ENTITY_1).acronym
                        if self.original_learning_unit_year_1.entities.get(
                            ADDITIONAL_REQUIREMENT_ENTITY_1) else BLANK_VALUE))
        to_test.append((data[19],
                        self.original_learning_unit_year_1.entities.get(
                            ADDITIONAL_REQUIREMENT_ENTITY_2).acronym
                        if self.original_learning_unit_year_1.entities.get(
                            ADDITIONAL_REQUIREMENT_ENTITY_2) else BLANK_VALUE))
        to_test.append(
            (data[20], _('Yes')
             if self.original_learning_unit_year_1.professional_integration
             else _('No')))
        if self.learning_unit_year_1.campus:
            to_test.append(
                (data[21],
                 self.original_learning_unit_year_1.campus.organization.name))
            to_test.append(
                (data[22], self.original_learning_unit_year_1.campus))
        else:
            to_test.append((data[21], BLANK_VALUE))
            to_test.append((data[22], BLANK_VALUE))
        to_test.append(
            (data[23],
             self.original_learning_unit_year_1.learning_unit.faculty_remark
             or BLANK_VALUE))
        to_test.append(
            (data[24],
             self.original_learning_unit_year_1.learning_unit.other_remark
             or BLANK_VALUE))
        to_test.append(
            (data[25], _('Yes')
             if self.original_learning_unit_year_1.learning_container_year.team
             else _('No')))
        to_test.append(
            (data[26], _('Yes') if self.original_learning_unit_year_1.
             learning_container_year.is_vacant else _('No')))
        to_test.append(
            (data[27],
             self.original_learning_unit_year_1.learning_container_year.
             get_type_declaration_vacant_display() or BLANK_VALUE))
        to_test.append((data[28],
                        self.original_learning_unit_year_1.
                        get_attribution_procedure_display() or BLANK_VALUE))

        to_test.append(
            (data[29], lecturing_component.hourly_volume_total_annual
             or BLANK_VALUE))
        to_test.append((data[30], lecturing_component.hourly_volume_partial_q1
                        or BLANK_VALUE))
        to_test.append((data[31], lecturing_component.hourly_volume_partial_q2
                        or BLANK_VALUE))
        to_test.append((data[32], lecturing_component.real_classes
                        or BLANK_VALUE))
        to_test.append((data[33], lecturing_component.planned_classes
                        or BLANK_VALUE))
        to_test.append(
            (data[38], practical_component.hourly_volume_total_annual
             or BLANK_VALUE))
        to_test.append((data[39], practical_component.hourly_volume_partial_q1
                        or BLANK_VALUE))
        to_test.append((data[40], practical_component.hourly_volume_partial_q2
                        or BLANK_VALUE))
        to_test.append((data[41], practical_component.real_classes
                        or BLANK_VALUE))
        to_test.append((data[42], practical_component.planned_classes
                        or BLANK_VALUE))

        for (i, (result, expected)) in enumerate(to_test):
            with self.subTest(i):
                self.assertEqual(expected, result)