def cruise_deals(request): try: page = request.GET.get('page', 1) page = int(page) except PageNotAnInteger: page = 1 except ValueError: raise Http404 cruises_deals = CruiseDeal.objects.order_by('order') paginator = PaginatorCustom(cruises_deals,OBJECTS_PER_PAGE, request=request) cruises_deals_page = paginator.page(page) return render(request, 'frontend/cruise_deals.html', {'cruises_deals': cruises_deals,'deals_page': cruises_deals_page,'base_image_url':BASE_IMAGES_URL}, )
def get_saved_travels(request): if request.user.is_authenticated: travel_dates = request.user.traveldates_set.all() travel_dates = _get_sort_result(request, travel_dates) try: page = request.GET.get('page', 1) page = int(page) except PageNotAnInteger: page = 1 except ValueError: raise Http404 paginator = PaginatorCustom(travel_dates,OBJECTS_PER_PAGE, request=request) try: travel_dates_page = paginator.page(page) travel_dates_data = travel_obj_to_list(travel_dates_page.object_list, request) except Exception: paginator = PaginatorCustom(TravelDates.objects.none(),OBJECTS_PER_PAGE, request=request) travel_dates_page = paginator.page(1) travel_dates_data = {} params = {'travels': travel_dates_data, 'pager': travel_dates_page} return render(request, 'frontend/saved_travels.html',params)
def cruise_by_line_departure(request, cruise_line_slug, departure_port_slug): travel_dates = TravelDates.objects.get_by_cruise_line_slug(cruise_line_slug).\ get_by_departure_port_slug(departure_port_slug) travel_dates = _get_sort_result(request, travel_dates) try: page = request.GET.get('page', 1) page = int(page) except PageNotAnInteger: page = 1 except ValueError: raise Http404 paginator = PaginatorCustom(travel_dates,OBJECTS_PER_PAGE, request=request) try: travel_dates_page = paginator.page(page) travel_dates_data = travel_obj_to_list(travel_dates_page.object_list, request) except Exception: paginator = PaginatorCustom(TravelDates.objects.none(),OBJECTS_PER_PAGE, request=request) travel_dates_page = paginator.page(1) travel_dates_data = {} params = {'travels': travel_dates_data, 'pager': travel_dates_page} return render(request, 'frontend/search_result.html',params)
def cruise_by_destination(request, type, destination): if type == 'subregion': travel_dates = TravelDates.objects.get_by_subregion_slug(destination).order_by('depart_date') elif type == 'region': travel_dates = TravelDates.objects.get_by_region_slug(destination).order_by('depart_date') travel_dates = _get_sort_result(request, travel_dates) try: page = request.GET.get('page', 1) page = int(page) except PageNotAnInteger: page = 1 except ValueError: raise Http404 paginator = PaginatorCustom(travel_dates,OBJECTS_PER_PAGE, request=request) try: travel_dates_page = paginator.page(page) travel_dates_data = travel_obj_to_list(travel_dates_page.object_list, request) except Exception: paginator = PaginatorCustom(TravelDates.objects.none(),OBJECTS_PER_PAGE, request=request) travel_dates_page = paginator.page(1) travel_dates_data = {} params = {'travels': travel_dates_data, 'pager': travel_dates_page} return render(request, 'frontend/search_result.html',params)
travel_dates = travel_dates.filter(Q(name__icontains = query_text) | Q(destination_port__name__icontains = query_text) | Q(ship__name__icontains = query_text) | Q(ship__cruise_line__name__icontains = query_text) | Q(departure_port__name__icontains = query_text)) try: page = request.GET.get('page', 1) page = int(page) except PageNotAnInteger: page = 1 except ValueError: raise Http404 travel_dates = _get_sort_result(request, travel_dates) paginator = PaginatorCustom(travel_dates,OBJECTS_PER_PAGE, request=request) try: travel_dates_page = paginator.page(page) travel_dates_data = travel_obj_to_list(travel_dates_page.object_list, request) except Exception: paginator = PaginatorCustom(TravelDates.objects.none(),OBJECTS_PER_PAGE, request=request) travel_dates_page = paginator.page(1) travel_dates_data = {} params = {'travels': travel_dates_data, 'pager': travel_dates_page} return render(request, 'frontend/search_result.html',params) def cruise_by_destination_port(request, destination_port):