def test_modification_proposal_request(self):
        self.form_data["title"] = "New title"
        self.form_data["title_english"] = "New english title"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.MODIFICATION.name)
Exemplo n.º 2
0
def learning_unit_identification(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)
    learning_unit_year = context['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[
        'can_propose'] = learning_unit_proposal.is_eligible_for_modification_proposal(
            learning_unit_year, person)
    context['proposal'] = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)
    context['proposal_folder_entity_version'] = \
        entity_version.get_by_entity_and_date(context['proposal'].folder.entity, None) if context['proposal'] else None
    context[
        'can_delete'] = learning_unit_deletion.can_delete_learning_unit_year(
            person, learning_unit_year)

    return layout.render(request, "learning_unit/identification.html", context)
Exemplo n.º 3
0
def check_learning_unit_year_deletion(learning_unit_year):
    msg = {}

    proposal = proposal_learning_unit.find_by_learning_unit_year(learning_unit_year)
    if proposal:
        msg[proposal] = _("%(subtype)s %(acronym)s is in proposal") \
                        % {'subtype': _str_partim_or_full(learning_unit_year),
                           'acronym': learning_unit_year.acronym}

    enrollment_count = len(learning_unit_enrollment.find_by_learning_unit_year(learning_unit_year))
    if enrollment_count > 0:
        msg[learning_unit_year] = _("There is %(count)d enrollments in %(subtype)s %(acronym)s for the year %(year)s") \
                                  % {'subtype': _str_partim_or_full(learning_unit_year),
                                     'acronym': learning_unit_year.acronym,
                                     'year': learning_unit_year.academic_year,
                                     'count': enrollment_count}

    if learning_unit_year.subtype == learning_unit_year_subtypes.FULL and learning_unit_year.learning_container_year:
        msg.update(_check_related_partims_deletion(learning_unit_year.learning_container_year))

    msg.update(_check_attribution_deletion(learning_unit_year))
    for component in learning_unit_component.find_by_learning_unit_year(learning_unit_year):
        msg.update(_check_learning_unit_component_deletion(component))

    for group_element_year in learning_unit_year.find_list_group_element_year():
        msg.update(_check_group_element_year_deletion(group_element_year))

    for tutoring in tutoring_learning_unit_year.find_learning_unit_year(learning_unit_year=learning_unit_year):
        msg.update(_check_tutoring_learning_unit_year(tutoring))

    next_year = learning_unit_year.get_learning_unit_next_year()
    if next_year:
        msg.update(check_learning_unit_year_deletion(next_year))

    return msg
Exemplo n.º 4
0
def learning_unit_proposal_comparison(request, learning_unit_year_id):
    learning_unit_year = get_object_or_404(
        LearningUnitYear.objects.all().select_related(
            'learning_unit', 'learning_container_year', 'campus',
            'campus__organization'),
        pk=learning_unit_year_id)
    initial_data = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year).initial_data
    initial_learning_unit_year, learning_unit_year_fields = get_learning_unit_year_comparison_context(
        initial_data, learning_unit_year)
    components = get_components_identification(learning_unit_year)
    components_list = []
    for component in components['components']:
        volumes = get_volumes_comparison_context(component, initial_data)
        components_list.append([
            _get_value_from_enum(LEARNING_COMPONENT_YEAR_TYPES,
                                 component['learning_component_year'].type),
            volumes
        ])
    context = {
        'learning_unit_year': learning_unit_year,
        'learning_container_year_fields': get_learning_container_year_comparison_context(
            initial_data,
            learning_unit_year
        ),
        'campus': [
            learning_unit_year._meta.get_field('campus').verbose_name,
            initial_learning_unit_year.campus.name,
            learning_unit_year.campus.name] \
            if initial_learning_unit_year.campus.name != learning_unit_year.campus.name else [],
        'entities_fields': get_all_entities_comparison_context(initial_data, learning_unit_year),
        'learning_unit_year_fields': learning_unit_year_fields,
        'components': components_list
    }
    return render(request, "learning_unit/proposal_comparison.html", context)
Exemplo n.º 5
0
def reinitialize_learning_unit_year(components_list, context, initial_data,
                                    learning_unit_year):
    initial_data = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year).initial_data
    _reinitialize_model(learning_unit_year, initial_data["learning_unit_year"])
    _reinitialize_model(learning_unit_year.learning_container_year,
                        initial_data["learning_container_year"])
    _reinitialize_components(initial_data["learning_component_years"] or {})
    for component in initial_data['learning_component_years']:
        volumes = {
            _('Volume total annual'):
            component['hourly_volume_total_annual'] or 0,
            _('Planned classes'):
            component['planned_classes'] or 0,
            _('Volume Q1'):
            component['hourly_volume_partial_q1'] or 0,
            _('Volume Q2'):
            component['hourly_volume_partial_q2'] or 0,
            _('Requirement entity'):
            component['repartition_volume_requirement_entity'] or 0,
            _('Additional requirement entity 1'):
            component['repartition_volume_additional_entity_1'] or 0,
            _('Additional requirement entity 2'):
            component['repartition_volume_additional_entity_2'] or 0
        }
        components_list[_get_value_from_enum(LEARNING_COMPONENT_YEAR_TYPES,
                                             component['type'])] = volumes
    context['components'] = components_list
    return initial_data
    def test_transformation_and_modification_proposal_request(self):
        self.form_data["acronym"] = "OSIS1452"
        self.form_data["title"] = "New title"
        self.form_data["title_english"] = "New english title"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.TRANSFORMATION_AND_MODIFICATION.name)
Exemplo n.º 7
0
    def test_folder_reuse(self):
        folder = ProposalFolderFactory(entity=self.entity_version.entity, folder_id=1)

        form = LearningUnitProposalModificationForm(self.form_data)
        form.save(self.learning_unit_year, self.person, PROPOSAL_TYPE, PROPOSAL_STATE)

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unt.folder, folder)
Exemplo n.º 8
0
    def f_can_edit_learning_unit_proposal(request, learning_unit_year_id):
        proposal = proposal_learning_unit.find_by_learning_unit_year(
            learning_unit_year_id)
        pers = get_object_or_404(Person, user=request.user)

        if not business_perms.is_eligible_to_edit_proposal(proposal, pers):
            raise PermissionDenied(
                "User has not sufficient rights to edit proposal.")
        return view_func(request, learning_unit_year_id)
Exemplo n.º 9
0
def _check_learning_unit_proposal(learning_unit_year):
    msg = {}

    proposal = proposal_learning_unit.find_by_learning_unit_year(learning_unit_year)
    if proposal:
        error_proposal = "%(subtype)s %(acronym)s is in proposal for the year %(year)s"
        msg[proposal] = _(error_proposal) % {'subtype': _str_partim_or_full(proposal.learning_unit_year),
                                             'acronym': proposal.learning_unit_year.acronym,
                                             'year': proposal.learning_unit_year.academic_year}
    return msg
Exemplo n.º 10
0
def _check_learning_unit_proposal(learning_unit_year):
    msg = {}

    proposal = proposal_learning_unit.find_by_learning_unit_year(learning_unit_year)
    if proposal:
        error_proposal = "%(subtype)s %(acronym)s is in proposal for the year %(year)s"
        msg[proposal] = _(error_proposal) % {'subtype': _str_partim_or_full(proposal.learning_unit_year),
                                             'acronym': proposal.learning_unit_year.acronym,
                                             'year': proposal.learning_unit_year.academic_year}
    return msg
Exemplo n.º 11
0
def is_eligible_for_modification_end_date(learn_unit_year, a_person):
    if is_old_learning_unit(learn_unit_year.learning_unit):
        return False
    if proposal_learning_unit.find_by_learning_unit_year(learn_unit_year):
        return False
    if a_person.is_faculty_manager(
    ) and not _can_faculty_manager_modify_end_date(learn_unit_year):
        return False
    return a_person.is_linked_to_entity_in_charge_of_learning_unit_year(
        learn_unit_year)
Exemplo n.º 12
0
    def test_creation_proposal_learning_unit(self):
        initial_data_expected = {
            "learning_container_year": {
                "id":
                self.learning_unit_year.learning_container_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "common_title":
                self.learning_unit_year.learning_container_year.common_title,
                "container_type":
                self.learning_unit_year.learning_container_year.container_type,
                "in_charge":
                self.learning_unit_year.learning_container_year.in_charge
            },
            "learning_unit_year": {
                "id": self.learning_unit_year.id,
                "acronym": self.learning_unit_year.acronym,
                "specific_title": self.learning_unit_year.specific_title,
                "internship_subtype":
                self.learning_unit_year.internship_subtype,
                "language": self.learning_unit_year.language.pk,
                "credits": self.learning_unit_year.credits,
                "campus": self.learning_unit_year.campus.id,
                "periodicity": self.learning_unit_year.periodicity,
            },
            "learning_unit": {
                "id": self.learning_unit_year.learning_unit.id,
                'end_year': self.learning_unit_year.learning_unit.end_year
            },
            "entities": {
                entity_container_year_link_type.REQUIREMENT_ENTITY:
                self.entity_container_year.entity.id,
                entity_container_year_link_type.ALLOCATION_ENTITY:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
                None
            }
        }

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             initial_data_expected)
Exemplo n.º 13
0
    def test_creation_proposal_learning_unit(self):
        self.maxDiff = None
        form = ProposalBaseForm(self.form_data, self.person, self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data, self._get_initial_data_expected())
Exemplo n.º 14
0
def extract_xls_data_from_proposal(luy):
    proposal = find_by_learning_unit_year(luy)
    return [
        luy.entity_requirement, luy.acronym, luy.complete_title,
        luy.learning_container_year.get_container_type_display(),
        proposal.get_type_display(),
        proposal.get_state_display(), proposal.folder,
        luy.learning_container_year.get_type_declaration_vacant_display(),
        dict(PERIODICITY_TYPES)[luy.periodicity], luy.credits,
        luy.entity_allocation,
        proposal.date.strftime('%d-%m-%Y')
    ]
Exemplo n.º 15
0
def extract_xls_data_from_proposal(luy):
    proposal = find_by_learning_unit_year(luy)
    return [luy.entity_requirement,
            luy.acronym,
            luy.complete_title,
            luy.learning_container_year.get_container_type_display(),
            proposal.get_type_display(),
            proposal.get_state_display(),
            proposal.folder,
            luy.learning_container_year.get_type_declaration_vacant_display(),
            dict(PERIODICITY_TYPES)[luy.periodicity],
            luy.credits,
            luy.entity_allocation,
            proposal.date.strftime('%d-%m-%Y')]
Exemplo n.º 16
0
def _get_optional_data(data, luy, optional_data_needed, gey):
    if optional_data_needed['has_required_entity']:
        data.append(luy.learning_container_year.requirement_entity)
    if optional_data_needed['has_allocation_entity']:
        data.append(luy.learning_container_year.allocation_entity)
    if optional_data_needed['has_credits']:
        data.append(gey.relative_credits or '-')
        data.append(luy.credits.to_integral_value() or '-')
    if optional_data_needed['has_periodicity']:
        data.append(luy.get_periodicity_display())
    if optional_data_needed['has_active']:
        data.append(str.strip(yesno(luy.status)))
    if optional_data_needed['has_quadrimester']:
        data.append(luy.get_quadrimester_display() or '')
    if optional_data_needed['has_session_derogation']:
        data.append(luy.get_session_display() or '')
    if optional_data_needed['has_volume']:
        luys = annotate_qs(LearningUnitYear.objects.filter(id=luy.id))
        data.extend(volume_information(luys[0]))
    if optional_data_needed['has_teacher_list']:
        attribution_values = attribution_charge_new.find_attribution_charge_new_by_learning_unit_year_as_dict(
            luy).values()
        data.append(";".join([
            _get_attribution_line(value.get('person'))
            for value in attribution_values
        ]))
        data.append(";".join(
            [value.get('person').email for value in attribution_values]))
    if optional_data_needed['has_proposition']:
        proposal = find_by_learning_unit_year(luy)
        if proposal:
            data.append(proposal.get_type_display())
            data.append(proposal.get_state_display())
        else:
            data.append('')
            data.append('')
    if optional_data_needed['has_english_title']:
        data.append(luy.complete_title_english)
    if optional_data_needed['has_language']:
        data.append(luy.language)
    if optional_data_needed['has_specifications']:
        specifications_data = _build_specifications_cols(luy, gey)
        for k, v in zip(specifications_data._fields, specifications_data):
            data.append(v)
    if optional_data_needed['has_description_fiche']:
        description_fiche = _build_description_fiche_cols(luy, gey)
        for k, v in zip(description_fiche._fields, description_fiche):
            data.append(v)
    return data
Exemplo n.º 17
0
    def test_post_request(self):
        response = self.client.post(self.url, data=self.form_data)

        redirected_url = reverse('learning_unit', args=[self.learning_unit_year.id])
        self.assertRedirects(response, redirected_url, fetch_redirect_response=False)

        folder = proposal_folder.find_by_entity_and_folder_id(self.entity_version.entity, 1)
        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertTrue(folder)
        self.assertTrue(a_proposal_learning_unit)
        self.assertEqual(a_proposal_learning_unit.author, self.person)

        messages = [str(message) for message in get_messages(response.wsgi_request)]
        self.assertIn(_("success_modification_proposal").format(proposal_type.ProposalType.MODIFICATION.name,
                                                                self.learning_unit_year.acronym),
                      list(messages))
Exemplo n.º 18
0
    def test_creation_proposal_learning_unit(self):
        initial_data_expected = build_initial_data(self.learning_unit_year,
                                                   self.entity_container_year)

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             initial_data_expected)
Exemplo n.º 19
0
def edit_learning_unit_proposal(request, learning_unit_year_id):
    user_person = get_object_or_404(Person, user=request.user)

    context = get_learning_unit_identification_context(learning_unit_year_id, user_person)
    proposal = proposal_learning_unit.find_by_learning_unit_year(learning_unit_year_id)

    proposal_form = ProposalStateModelForm(request.POST or None, instance=proposal)
    if proposal_form.is_valid():
        try:
            proposal_form.save()
            display_success_messages(request, _("proposal_edited_successfully"))
            return HttpResponseRedirect(reverse('learning_unit', args=[learning_unit_year_id]))

        except (IntegrityError, ValueError) as e:
            display_error_messages(request, e.args[0])

    context['form'] = proposal_form
    return layout.render(request, 'learning_unit/proposal/edition_proposal_state.html', context)
Exemplo n.º 20
0
    def test_creation_proposal_learning_unit(self):
        initial_data_expected = {
            "learning_container_year": {
                "id": self.learning_unit_year.learning_container_year.id,
                "acronym": self.learning_unit_year.acronym,
                "title": self.learning_unit_year.title,
                "title_english": self.learning_unit_year.title_english,
                "container_type": self.learning_unit_year.learning_container_year.container_type,
                "campus": self.learning_unit_year.learning_container_year.campus.id,
                "language": self.learning_unit_year.learning_container_year.language.id,
                "in_charge": self.learning_unit_year.learning_container_year.in_charge
            },
            "learning_unit_year": {
                "id": self.learning_unit_year.id,
                "acronym": self.learning_unit_year.acronym,
                "title": self.learning_unit_year.title,
                "title_english": self.learning_unit_year.title_english,
                "internship_subtype": self.learning_unit_year.internship_subtype,
                "credits": self.learning_unit_year.credits,
                "quadrimester": self.learning_unit_year.quadrimester,
            },
            "learning_unit": {
                "id": self.learning_unit_year.learning_unit.id,
                "periodicity": self.learning_unit_year.learning_unit.periodicity
            },
            "entities": {
                entity_container_year_link_type.REQUIREMENT_ENTITY: self.entity_container_year.entity.id,
                entity_container_year_link_type.ALLOCATION_ENTITY: None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: None
            }
        }

        form = LearningUnitProposalModificationForm(self.form_data)
        form.save(self.learning_unit_year, self.person, PROPOSAL_TYPE, PROPOSAL_STATE)

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)

        self.assertDictEqual(a_proposal_learning_unt.initial_data, initial_data_expected)
Exemplo n.º 21
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
Exemplo n.º 22
0
def is_eligible_for_modification_proposal(learning_unit_year, a_person):
    proposal = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)
    current_year = current_academic_year().year
    entity_containers_year = search(
        learning_container_year=learning_unit_year.learning_container_year,
        link_type=entity_container_year_link_type.REQUIREMENT_ENTITY)

    if not filter_by_attached_entities(a_person,
                                       entity_containers_year).count():
        return False

    if learning_unit_year.academic_year.year < current_year:
        return False

    if learning_unit_year.subtype != learning_unit_year_subtypes.FULL:
        return False

    if proposal:
        return False

    return True
Exemplo n.º 23
0
def learning_unit_modification_proposal(request, learning_unit_year_id):
    learning_unit_year = get_object_or_404(LearningUnitYear,
                                           id=learning_unit_year_id)
    user_person = get_object_or_404(Person, user=request.user)
    initial_data = compute_form_initial_data(learning_unit_year)
    proposal = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)

    form = LearningUnitProposalModificationForm(
        request.POST or None,
        initial=initial_data,
        instance=proposal,
        learning_unit=learning_unit_year.learning_unit,
        person=user_person)

    if form.is_valid():
        type_proposal = business_proposal.compute_proposal_type(
            form.changed_data_for_fields_that_can_be_modified,
            initial_data.get("type"))
        form.save(learning_unit_year, type_proposal,
                  compute_proposal_state(user_person))

        display_success_messages(
            request,
            _("success_modification_proposal").format(
                _(type_proposal), learning_unit_year.acronym))

        return redirect('learning_unit',
                        learning_unit_year_id=learning_unit_year.id)

    return layout.render(
        request, 'learning_unit/proposal/create_modification.html', {
            'learning_unit_year': learning_unit_year,
            'person': user_person,
            'form': form,
            'experimental_phase': True
        })
    def test_creation_proposal_learning_unit(self):
        initial_data_expected = {
            "learning_container_year": {
                "id":
                self.learning_unit_year.learning_container_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "common_title":
                self.learning_unit_year.learning_container_year.common_title,
                "container_type":
                self.learning_unit_year.learning_container_year.container_type,
                "in_charge":
                self.learning_unit_year.learning_container_year.in_charge,
                "team":
                self.learning_unit_year.learning_container_year.team,
                "common_title_english":
                self.learning_unit_year.learning_container_year.
                common_title_english,
                "is_vacant":
                self.learning_unit_year.learning_container_year.is_vacant,
                "type_declaration_vacant":
                self.learning_unit_year.learning_container_year.
                type_declaration_vacant,
            },
            "learning_unit_year": {
                "id":
                self.learning_unit_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "specific_title":
                self.learning_unit_year.specific_title,
                "internship_subtype":
                self.learning_unit_year.internship_subtype,
                "language":
                self.learning_unit_year.language.pk,
                "credits":
                self.learning_unit_year.credits,
                "campus":
                self.learning_unit_year.campus.id,
                "periodicity":
                self.learning_unit_year.periodicity,
                "status":
                self.learning_unit_year.status,
                "session":
                self.learning_unit_year.session,
                "quadrimester":
                self.learning_unit_year.quadrimester,
                "specific_title_english":
                self.learning_unit_year.specific_title_english,
                "professional_integration":
                self.learning_unit_year.professional_integration,
                "attribution_procedure":
                self.learning_unit_year.attribution_procedure,
            },
            "learning_unit": {
                "id":
                self.learning_unit_year.learning_unit.id,
                'end_year':
                self.learning_unit_year.learning_unit.end_year,
                "other_remark":
                self.learning_unit_year.learning_unit.other_remark,
                "faculty_remark":
                self.learning_unit_year.learning_unit.faculty_remark,
            },
            "entities": {
                entity_container_year_link_type.REQUIREMENT_ENTITY:
                self.entity_container_year.entity.id,
                entity_container_year_link_type.ALLOCATION_ENTITY:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
                None
            },
            "learning_component_years": []
        }

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             initial_data_expected)
Exemplo n.º 25
0
 def test_find_by_learning_unit_year(self):
     a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(
         self.proposal_learning_unit.learning_unit_year)
     self.assertEqual(a_proposal_learning_unit, self.proposal_learning_unit)
Exemplo n.º 26
0
    def test_transformation_proposal_request(self):
        self.form_data["acronym"] = "OSIS1452"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.TRANSFORMATION.name)
Exemplo n.º 27
0
def _learning_unit_year_is_on_proposal(learn_unit_year):
    proposal = proposal_learning_unit.find_by_learning_unit_year(
        learn_unit_year)
    return proposal is not None