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)
def f_can_update_learning_achievement(request, learning_unit_year_id, *args, **kwargs): learn_unit_year = get_object_or_404( learning_unit_year.LearningUnitYear, pk=learning_unit_year_id) pers = get_object_or_404(Person, user=request.user) if not business_perms.can_update_learning_achievement( learn_unit_year, pers): raise PermissionDenied( "The user is not linked to the learning unit year") return view_func(request, learning_unit_year_id, *args, **kwargs)
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'] context.update(get_specifications_context(learning_unit_year, request)) context.update(get_achievements_group_by_language(learning_unit_year)) context.update(get_languages_settings()) context['can_update_learning_achievement'] = can_update_learning_achievement(learning_unit_year, person) return render(request, "learning_unit/specifications.html", context)
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'] context.update(get_specifications_context(learning_unit_year, request)) context.update(get_achievements_group_by_language(learning_unit_year)) context.update(get_languages_settings()) context["achievements"] = list(itertools.zip_longest( context.get("achievements_FR", []), context.get("achievements_EN", []) )) context['can_update_learning_achievement'] = can_update_learning_achievement(learning_unit_year, person) context['tab_active'] = 'learning_unit_specifications' # Corresponds to url_name return render(request, "learning_unit/specifications.html", context)
def test_is_eligible_to_update_learning_achievement_after_2017( self, mock_flag): self.luy.academic_year = AcademicYearFactory(year=2019) self.assertTrue( can_update_learning_achievement(self.luy, self.central_manager))
def test_is_not_eligible_to_update_learning_achievement_cause_before_2018( self, mock_flag): self.luy.academic_year = AcademicYearFactory(year=2015) self.assertFalse( can_update_learning_achievement(self.luy, self.central_manager))