def save_advisor(request, dealer_code): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() resp = True user = None dealer_service = dealer_factory.get_instance( "dealership") #DealerShipService() dealership = dealer_service.get_dealer_by( request.session.get("dealer_code")) rtype = request.GET.get("type", "appointment") if rtype == "appointment": # if request.GET.get("advisor_id"): try: appointment_id = request.GET.get("appointment_id") service = AppointmentService() appointment = service.get_appointment(appointment_id) advisor_id = request.GET.get("advisor_id", appointment.advisor_id) save_advisor = service.save_advisor(appointment, advisor_id) cservice = customer_factory.get_instance("user") #CUserService() if save_advisor: resp = True print appointment.customer.id print dealership.id print advisor_id save = cservice.save_my_advisor(appointment.customer.id, dealership.id, advisor_id) if save == False: resp = False except Exception, e: print e
def overview(request): searchform = SearchCustomerForm() aptservice = AppointmentService() breadcrumb = ["Today's Overview", "Daily View"] meters = aptservice.get_meters_data() template = 'overview/index.html' return render(request, template, {'breadcrumb':breadcrumb, 'meters':meters, 'searchform':searchform})
def index(request, appointment_id): template = "mobilecheckin/checkin/checkin.html" date_time = timezone.now() dservice = AS() try: app_details = Appointment.objects.get(id=appointment_id) except Appointment.DoesNotExist: raise Http404 status = AppointmentStatus.objects.get(name="In Progress") if app_details.appointment_status == status: if app_details.checkin_time: time_left = dservice.get_in_progress_remaining_time( app_details.checkin_time) else: time_left = {'min': 5, 'sec': 0} app_details.appointment_status = status app_details.checkin_time = date_time app_details.save() app_service = AppointmentService.objects.filter( appointment_id=appointment_id) return render( request, template, { 'app_details': app_details, 'app_services': app_service, 'time_left': time_left, 'dealer_code': request.session["dealer_code"] })
def time_weekly_slab_ajax_view(request): template = 'mobilecheckin/appoinments/time_weekly_slab.html' context = {} if request.method == 'POST': aptservice = AppointmentService() context = aptservice.get_appoiontments_by_time(request.POST.get('year'),request.POST.get('month'),request.POST.get('day'),request.POST.get('hour'),request.POST.get('minute')) context["id"] = request.POST.get('id') return render(request, template, context)
def appointment_row_ajax_view(request): template = 'mobilecheckin/appoinments/time_daily_row.html' context = {} if request.method == 'POST': aptservice = AppointmentService() context = {'row':aptservice.get_appointment_by_id(request.POST.get('id'))} print context return render(request, template, context)
def status_daily_slab_ajax_view(request): template = 'mobilecheckin/appointments/time_daily_slab.html' context = {} print "new function " if request.method == 'POST': aptservice = AppointmentService() context = aptservice.get_appointments_by_status(request.POST.get('year'),request.POST.get('month'),request.POST.get('day'),request.POST.get('id'), request.POST.get('title')) print context return render(request, template, context)
def advisor_ajax_view(request): #template = 'overview/daily_slab.html' context = {} #print "old function " if request.method == 'POST': aptservice = AppointmentService() context = aptservice.get_appointments_advisor() #context['id'] = request.POST.get('id') #return render(request, template, context) return JsonResponse(context)
def appointment_detail_ajax_view(request): template = 'mobilecheckin/appointments/detail.html' context = {} if request.method == 'POST': aptservice = AppointmentService() id = request.POST.get('id') print id row = aptservice.get_appointment_by_id(id) context = {"id": request.POST.get('id'), "row": row }#aptservice.get_appointment_by_id(request.POST.get('id')); return render(request, template, context)
def appointment_time_ajax_view(request): template = 'appointment/time.html' grid_data = {} if request.method == 'POST': aptservice = AppointmentService() grid_data = aptservice.get_weekly_time_grid( request.POST.get('appt_id'), request.POST.get('date'), request.session["dealer_id"]) return render(request, template, {'grid_data': grid_data})
def appointment_book_ajax_view(request): appointment = {} template = 'appointment/partials/confirmation_modal_content.html' dealer_factory = DealerShipServicesFactory() aptservice = dealer_factory.get_instance("appointment") if request.method == 'POST': aptservice = AppointmentService() #try: data = {} for key, value in request.POST.iteritems(): if key == "start_time": #value = datetime.datetime.strptime(value, '%b. %d, %Y, %I:%M %p') value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M') value = timezone.make_aware(value) data[key] = value aptservice = AppointmentService() context = aptservice.create_update_appointment(data) aptservice.book_appointment_with_id(request.POST.get('id'), request.session["dealer_id"]) appointment = aptservice.get_appointment_by_id(request.POST.get('id')) print appointment #except Exception, ex: #pass return render(request, template, appointment)
def appointment_create_update(request): context = {} if request.method == 'POST': data = {} for key, value in request.POST.iteritems(): if key == "start_time": #value = datetime.datetime.strptime(value, '%b. %d, %Y, %I:%M %p') value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M') value = timezone.make_aware(value) data[key] = value aptservice = AppointmentService() context = aptservice.create_update_appointment(data) return JsonResponse(context)
def appointment(request): searchform = SearchCustomerForm() custform = CustomerGuestAccountForm() vehicleform = CustomerVehichleForm() apptform = GuestAppointmentForm() guestform = GuestAccountForm() aptservice = AppointmentService() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance("dealership") vehicle_service = dealer_factory.get_instance("vehicle") dealer = dealer_service.get_dealer_by(request.session.get("dealer_code")) vehichles = vehicle_service.get_vehichles_dealer(dealer) vehicles = list(vehichles) breadcrumb = BreadCrumb() breadcrumb = breadcrumb.create_breadcrumb(["appointment"]) status = aptservice.get_appointments_status() wayaway = aptservice.get_wayaway() advisors = aptservice.get_appointments_advisor( request.session["dealer_id"]) wallboard = aptservice.get_appointments_wallboard_data( request.session["dealer_id"]) template = 'appointment/index.html' qstring = {} for key, value in request.GET.iteritems(): qstring[key] = value dealer_service = dealer_factory.get_instance("dealership") favorites = dealer_service.get_dealer_favorites( request.session["dealer_id"]) config = { "username": request.user, "dealer_code": request.session["dealer_code"], "dealer_name": request.session["dealer_name"], "dealer_id": request.session["dealer_id"], "group": request.session["group"], "tab": "appointment", "CENTRIFUGE_URL": settings.CENTRIFUGE_URL, "CENTRIFUGE_SECRET": settings.CENTRIFUGE_SECRET } return render( request, template, { 'config': config, "favorites": favorites, 'breadcrumb': breadcrumb, 'wallboard': wallboard, 'searchform': searchform, 'qstring': qstring, 'searchform': searchform, 'custform': custform, 'guestform': guestform, 'vehicleform': vehicleform, 'apptform': apptform, 'vehicles': mainjson.dumps(vehicles), 'status': status['data'], 'wayaway': wayaway['data'], 'advisors': advisors, 'qstring': qstring })
def get_instance(self, name): if name == "user": return UserService() elif name == "vehicle": return VehicleService() elif name == "dealership": return DealerShipService() elif name == "repair": return RepairService() elif name == "appointment": return AppointmentService() elif name == "wayaway": return WayAwayService() elif name == "notification": return NotificationService() elif name == "capacity": return CapacityService() elif name == "email": return EmailService()
def meters_ajax_view(request): aptservice = AppointmentService() meters = aptservice.get_meters_data() template = 'dealership/app/meters.html' return render(request, template, {'meters':meters})
def status_ajax_view(request): context = {} if request.method == 'POST': aptservice = AppointmentService() context = aptservice.get_appointments_status() return JsonResponse(context)