def _learning_units_search(request, search_type): if request.GET.get('academic_year_id'): form = LearningUnitYearForm(request.GET) else: form = LearningUnitYearForm() found_learning_units = None try: if form.is_valid(): if search_type == SIMPLE_SEARCH: found_learning_units = form.get_activity_learning_units() elif search_type == SERVICE_COURSES_SEARCH: found_learning_units = form.get_service_course_learning_units() _check_if_display_message(request, found_learning_units) except TooManyResultsException: messages.add_message(request, messages.ERROR, _('too_many_results')) 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': mdl.academic_year.current_academic_year(), 'experimental_phase': True, 'search_type': search_type } return layout.render(request, "learning_units.html", context)
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)
def learning_units_proposal_search(request): search_form = LearningUnitProposalForm(request.GET or None) proposals = [] try: if search_form.is_valid(): proposals = search_form.get_proposal_learning_units() check_if_display_message(request, proposals) except TooManyResultsException: display_error_messages(request, 'too_many_results') if proposals: proposals = _proposal_management(request, proposals) a_person = find_by_user(request.user) context = { 'form': search_form, 'academic_years': get_last_academic_years(), 'current_academic_year': current_academic_year(), 'experimental_phase': True, 'search_type': PROPOSAL_SEARCH, 'proposals': proposals, 'is_faculty_manager': a_person.is_faculty_manager() } return layout.render(request, "learning_units.html", context)