示例#1
0
def learning_unit_specifications_edit(request, learning_unit_year_id):
    if request.method == 'POST':
        form = LearningUnitSpecificationsEditForm(request.POST)
        if form.is_valid():
            form.save()
        return HttpResponseRedirect(
            reverse("learning_unit_specifications",
                    kwargs={'learning_unit_year_id': learning_unit_year_id}))

    context = get_common_context_learning_unit_year(
        learning_unit_year_id, get_object_or_404(Person, user=request.user))
    label_name = request.GET.get('label')
    text_lb = text_label.get_by_name(label_name)
    language = request.GET.get('language')
    form = LearningUnitSpecificationsEditForm(
        **{
            'learning_unit_year': context['learning_unit_year'],
            'language': language,
            'text_label': text_lb
        })
    form.load_initial()  # Load data from database
    context['form'] = form

    user_language = mdl.person.get_user_interface_language(request.user)
    context['text_label_translated'] = get_text_label_translated(
        text_lb, user_language)
    context['language_translated'] = find_language_in_settings(language)
    return render(request, "learning_unit/specifications_edit.html", context)
示例#2
0
def education_group_year_pedagogy_edit(request, root_id,
                                       education_group_year_id):
    if request.method == 'POST':
        return education_group_year_pedagogy_edit_post(
            request, root_id, education_group_year_id)

    education_group_year = get_object_or_404(EducationGroupYear,
                                             pk=education_group_year_id)

    context = {
        'education_group_year': education_group_year,
    }

    label_name = request.GET.get('label')
    language = request.GET.get('language')

    text_lb = find_root_by_name(label_name)
    form = EducationGroupPedagogyEditForm(
        **{
            'education_group_year': context['education_group_year'],
            'language': language,
            'text_label': text_lb,
        })

    form.load_initial()
    context['form'] = form
    user_language = mdl.person.get_user_interface_language(request.user)
    context['text_label_translated'] = get_text_label_translated(
        text_lb, user_language)
    context['language_translated'] = find_language_in_settings(language)
    context['group_to_parent'] = request.GET.get("group_to_parent")

    return layout.render(request, 'education_group/pedagogy_edit.html',
                         context)
示例#3
0
def edit_learning_unit_pedagogy(request, learning_unit_year_id, redirect_url):
    if request.method == 'POST':
        _post_learning_unit_pedagogy_form(request)
        return redirect(redirect_url)

    context = get_common_context_learning_unit_year(
        learning_unit_year_id, get_object_or_404(Person, user=request.user))
    label_name = request.GET.get('label')
    language = request.GET.get('language')
    text_lb = TextLabel.objects.prefetch_related(
        Prefetch('translatedtextlabel_set',
                 to_attr="translated_text_labels")).get(label=label_name)
    form = LearningUnitPedagogyEditForm(
        **{
            'learning_unit_year': context['learning_unit_year'],
            'language': language,
            'text_label': text_lb
        })
    form.load_initial()  # Load data from database
    context['form'] = form
    user_language = mdl.person.get_user_interface_language(request.user)
    context['text_label_translated'] = get_text_label_translated(
        text_lb, user_language)
    context['language_translated'] = find_language_in_settings(language)
    context['cms_label_pedagogy_fr_only'] = CMS_LABEL_PEDAGOGY_FR_ONLY
    context['label_name'] = label_name
    return render(request, "learning_unit/pedagogy_edit.html", context)
示例#4
0
def learning_unit_specifications_edit(request, learning_unit_year_id):
    if request.method == 'POST':
        form = LearningUnitSpecificationsEditForm(request.POST)
        if form.is_valid():
            field_label, last_academic_year = form.save()
            display_success_messages(
                request,
                build_success_message(last_academic_year, learning_unit_year_id, form.postponement)
            )
        return HttpResponse()
    else:
        context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                        get_object_or_404(Person, user=request.user))
        label_name = request.GET.get('label')
        text_lb = TextLabel.objects.prefetch_related(
            Prefetch('translatedtextlabel_set', to_attr="translated_text_labels")
        ).get(label=label_name)
        form = LearningUnitSpecificationsEditForm(**{
            'learning_unit_year': context['learning_unit_year'],
            'text_label': text_lb
        })
        form.load_initial()  # Load data from database
        context['form'] = form
        context['text_label_translated'] = get_text_label_translated(text_lb, get_language())
        return render(request, "learning_unit/specifications_edit.html", context)