Ejemplo n.º 1
0
def education_group_year_admission_condition_update_text_post(
        request, root_id, education_group_year_id):
    form = UpdateTextForm(request.POST)

    if form.is_valid():
        education_group_year = get_object_or_404(EducationGroupYear,
                                                 pk=education_group_year_id)
        section = form.cleaned_data['section']

        admission_condition = education_group_year.admissioncondition

        setattr(admission_condition, 'text_' + section,
                form.cleaned_data['text_fr'])
        setattr(admission_condition, 'text_' + section + '_en',
                form.cleaned_data['text_en'])
        admission_condition.save()

    return redirect(
        reverse('education_group_year_admission_condition_edit',
                args=[root_id, education_group_year_id]))
Ejemplo n.º 2
0
def education_group_year_admission_condition_update_text_get(
        request, education_group_year_id):
    education_group_year = get_object_or_404(EducationGroupYear,
                                             pk=education_group_year_id)
    section = request.GET['section']

    form = UpdateTextForm(
        initial={
            'section':
            section,
            'text_fr':
            getattr(education_group_year.admissioncondition, 'text_' +
                    section),
            'text_en':
            getattr(education_group_year.admissioncondition, 'text_' +
                    section + '_en'),
        })

    context = {
        'form': form,
    }
    return layout.render(request, 'education_group/condition_text_edit.html',
                         context)