コード例 #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 layout.render(request, "learning_unit/specifications.html", context)
コード例 #2
0
ファイル: education_group.py プロジェクト: austinsdoe/osis
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 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 layout.render(request, "learning_unit/specifications_edit.html",
                         context)
コード例 #4
0
def summary_edit(request, learning_unit_year_id):
    if not is_summary_submission_opened():
        return redirect(reverse_lazy("outside_summary_submission_period"))

    learning_unit_year = get_object_or_404(LearningUnitYear,
                                           pk=learning_unit_year_id)
    if not can_access_summary(request.user, learning_unit_year):
        raise PermissionDenied("User is not summary responsible")

    if request.method == 'POST':
        form = LearningUnitPedagogyEditForm(request.POST)
        if form.is_valid():
            form.save()
        return redirect("learning_unit_summary",
                        learning_unit_year_id=learning_unit_year_id)
    label_name = request.GET.get('label')
    lang = request.GET.get('language')
    text_lb = text_label.find_root_by_name(label_name)
    form = LearningUnitPedagogyEditForm(
        **{
            'learning_unit_year': learning_unit_year,
            'language': lang,
            'text_label': text_lb
        })
    form.load_initial()
    user_language = mdl.person.get_user_interface_language(request.user)
    text_label_translated = next((txt for txt in text_lb.translated_text_labels
                                  if txt.language == user_language), None)
    return layout.render(
        request, "my_osis/educational_information_edit.html", {
            "learning_unit_year": learning_unit_year,
            "form": form,
            "language_translated": find_language_in_settings(lang),
            "text_label_translated": text_label_translated
        })
コード例 #5
0
def edit_learning_unit_pedagogy(request, learning_unit_year_id, redirect_url):
    if request.method == 'POST':
        form = LearningUnitPedagogyEditForm(request.POST)
        if form.is_valid():
            form.save()
        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 = text_label.find_root_by_name(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'] = next(
        (txt for txt in text_lb.translated_text_labels
         if txt.language == user_language), None)
    context['language_translated'] = find_language_in_settings(language)
    return layout.render(request, "learning_unit/pedagogy_edit.html", context)
コード例 #6
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)