def service_history(request, vehicle_id): template_name = 'customer/vehicle_services.html' user = request.user # user = User.objects.get(id=user.id) profile = UserProfile.objects.get(user_id=user.id) dealer_code = request.session["dealer_code"] customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance( "dealership") #DealerShipService() appt_service = dealer_factory.get_instance( "appointment") #DealerShipService() dealership = dealer_service.get_dealer_by( request.session.get("dealer_code")) appts_list = appt_service.get_old_appointments_by(vehicle_id, dealership) paginator = Paginator(appts_list, 10) page = request.GET.get('page', 1) try: appts = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. appts = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. appts = paginator.page(paginator.num_pages) context = { "appts": appts, "dealer_code": dealer_code, "vehicle_id": int(vehicle_id) } return render(request, template_name, context)
def search_ros_ajax(request): filter_dict = {} value = "" type = "" temp_params = {"isOrdered" : False} page = request.GET.get("page",1) try: filter_dict['status'] = request.GET.get("status","active") if "roNumber" in request.GET: value = filter_dict['ro_number'] = request.GET.get("roNumber") type = "roNumber" elif "advisor" in request.GET: value = filter_dict['advisor'] = request.GET.get("advisor") type = "advisor" elif "flags" in request.GET: value = filter_dict['flags'] = request.GET.get("flags") type = "flags" temp_params["orderBy"] = filter_dict["orderBy"] = request.GET.get("orderBy","ro_date") temp_params["isOrdered"] = True temp_params["order"] = filter_dict["order"] = request.GET.get("order","desc") # if page == 1: temp_params["order"] = "asc" if filter_dict["order"] == "desc" else "desc" # if request.GET.get("order"): # filter_dict["order"] = request.GET.get("order") # temp_params["isOrdered"] = True # temp_params["order"] = request.GET.get("order") # if page == 1: # temp_params["order"] = "asc" if request.GET.get("order") == "desc" else "desc" ro_services = RoServices(request.session["dealer_id"]) ro = ro_services.getRos(filter_dict) paginator = Paginator(ro, 25) ro = paginator.page(page) except PageNotAnInteger: ro = paginator.page(1) except EmptyPage: ro = paginator.page(paginator.num_pages) if len(ro) == 1: temp_params["roDetails"] = ro_services.getROdetails(ro[0].ro.ro_number) temp_params["color"] = ro_services.getColorForRO(ro[0].ro.ro_number) temp_params["ro_list"] = ro temp_params["ro_number"] = value temp_params["status"] = request.GET.get("status","active") temp_params["type"] = type temp_params["page"] = page return render(request,"flagging_app/ro_list.html",temp_params)