Beispiel #1
0
def _learning_units_search(request, search_type):
    service_course_search = search_type == SERVICE_COURSES_SEARCH

    form = LearningUnitYearForm(request.GET or None,
                                service_course_search=service_course_search)

    found_learning_units = []
    try:
        if form.is_valid():
            found_learning_units = form.get_activity_learning_units()

            check_if_display_message(request, found_learning_units)
    except TooManyResultsException:
        messages.add_message(request, messages.ERROR, _('too_many_results'))

    if request.GET.get('xls_status') == "xls":
        return create_xls(request.user, found_learning_units)

    context = {
        'form': form,
        'academic_years': get_last_academic_years(),
        'container_types':
        learning_container_year_types.LEARNING_CONTAINER_YEAR_TYPES,
        'types': learning_unit_year_subtypes.LEARNING_UNIT_YEAR_SUBTYPES,
        'learning_units': found_learning_units,
        'current_academic_year': current_academic_year(),
        'experimental_phase': True,
        'search_type': search_type
    }
    return layout.render(request, "learning_units.html", context)
Beispiel #2
0
def learning_units_search(request, search_type):
    service_course_search = search_type == SERVICE_COURSES_SEARCH
    borrowed_course_search = search_type == BORROWED_COURSE

    form = LearningUnitYearForm(
        request.GET or None,
        service_course_search=service_course_search,
        borrowed_course_search=borrowed_course_search,
        initial={'academic_year_id': starting_academic_year()}
    )
    found_learning_units = LearningUnitYear.objects.none()
    try:
        if form.is_valid():
            found_learning_units = form.get_activity_learning_units()
            check_if_display_message(request, found_learning_units)

    except TooManyResultsException:
        display_error_messages(request, 'too_many_results')

    if request.POST.get('xls_status') == "xls":
        return create_xls(request.user, found_learning_units, _get_filter(form, search_type))

    if request.POST.get('xls_status') == "xls_comparison":
        return create_xls_comparison(
            request.user,
            found_learning_units,
            _get_filter(form, search_type),
            request.POST.get('comparison_year')
        )

    if request.POST.get('xls_status') == "xls_with_parameters":
        return create_xls_with_parameters(
            request.user,
            found_learning_units,
            _get_filter(form, search_type),
            {
                WITH_GRP: request.POST.get('with_grp') == 'true',
                WITH_ATTRIBUTIONS: request.POST.get('with_attributions') == 'true'
            }
        )

    form_comparison = SelectComparisonYears(academic_year=get_academic_year_of_reference(found_learning_units))

    context = {
        'form': form,
        'academic_years': get_last_academic_years(),
        'container_types': learning_container_year_types.LEARNING_CONTAINER_YEAR_TYPES,
        'types': learning_unit_year_subtypes.LEARNING_UNIT_YEAR_SUBTYPES,
        'learning_units_count': len(found_learning_units)
        if isinstance(found_learning_units, list) else
        found_learning_units.count(),
        'current_academic_year': starting_academic_year(),
        'experimental_phase': True,
        'search_type': search_type,
        'is_faculty_manager': request.user.person.is_faculty_manager,
        'form_comparison': form_comparison,
        'page_obj': paginate_queryset(found_learning_units, request.GET),
    }

    return render(request, "learning_units.html", context)
Beispiel #3
0
def learning_units_search(request, search_type):
    service_course_search = search_type == SERVICE_COURSES_SEARCH
    borrowed_course_search = search_type == BORROWED_COURSE

    form = LearningUnitYearForm(
        request.GET or None,
        service_course_search=service_course_search,
        borrowed_course_search=borrowed_course_search,
        initial={'academic_year_id': current_academic_year()})
    found_learning_units = []
    try:
        if form.is_valid():
            found_learning_units = form.get_activity_learning_units()
            check_if_display_message(request, found_learning_units)
    except TooManyResultsException:
        messages.add_message(request, messages.ERROR, _('too_many_results'))

    if request.POST.get('xls_status') == "xls":
        return create_xls(request.user, found_learning_units,
                          _get_filter(form, search_type))
    if request.POST.get('xls_status') == "xls_attribution":
        return create_xls_attribution(request.user, found_learning_units,
                                      _get_filter(form, search_type))

    a_person = find_by_user(request.user)
    context = {
        'form': form,
        'academic_years': get_last_academic_years(),
        'container_types':
        learning_container_year_types.LEARNING_CONTAINER_YEAR_TYPES,
        'types': learning_unit_year_subtypes.LEARNING_UNIT_YEAR_SUBTYPES,
        'learning_units': found_learning_units,
        'current_academic_year': current_academic_year(),
        'experimental_phase': True,
        'search_type': search_type,
        'is_faculty_manager': a_person.is_faculty_manager()
    }
    return layout.render(request, "learning_units.html", context)