Example #1
0
def learning_unit_specifications(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,
                                                    person)
    learning_unit_year = context['learning_unit_year']

    user_language = mdl.person.get_user_interface_language(request.user)
    context['cms_labels_translated'] = get_cms_label_data(
        CMS_LABEL_SPECIFICATIONS, user_language)

    fr_language = find_language_in_settings(settings.LANGUAGE_CODE_FR)
    en_language = find_language_in_settings(settings.LANGUAGE_CODE_EN)

    context.update({
        'form_french':
        LearningUnitSpecificationsForm(learning_unit_year, fr_language),
        'form_english':
        LearningUnitSpecificationsForm(learning_unit_year, en_language)
    })

    context.update(get_achievements_group_by_language(learning_unit_year))
    context.update({
        'LANGUAGE_CODE_FR': settings.LANGUAGE_CODE_FR,
        'LANGUAGE_CODE_EN': settings.LANGUAGE_CODE_EN
    })
    context[
        'can_update_learning_achievement'] = can_update_learning_achievement(
            learning_unit_year, person)
    context['experimental_phase'] = True
    return render(request, "learning_unit/specifications.html", context)
Example #2
0
def get_specifications_context(learning_unit_year, request):
    user_language = mdl.person.get_user_interface_language(request.user)
    fr_language = find_language_in_settings(settings.LANGUAGE_CODE_FR)
    en_language = find_language_in_settings(settings.LANGUAGE_CODE_EN)
    return {
        'cms_specification_labels_translated': get_cms_label_data(CMS_LABEL_SPECIFICATIONS, user_language),
        'form_french': LearningUnitSpecificationsForm(learning_unit_year, fr_language),
        'form_english': LearningUnitSpecificationsForm(learning_unit_year, en_language)
    }
Example #3
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)
Example #4
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)
Example #5
0
    def __init__(self, *args, learning_unit_year=None, language_code=None, **kwargs):
        self.learning_unit_year = learning_unit_year
        self.language = find_language_in_settings(language_code)

        self.load_initial()
        super().__init__(*args, **kwargs)