def setservices(self): from customer.factories import CustomerServicesFactory self.customer_service_factory = CustomerServicesFactory() self.dealer_service_factory = CustomerServicesFactory() self.cuserservice = self.customer_service_factory.get_instance("user") self.userservice = self.dealer_service_factory.get_instance("user") self.appointment_service = self.dealer_service_factory.get_instance( "appointment") self.vehicle_service = self.dealer_service_factory.get_instance( "vehicle") self.repair_service = self self.dealership_service = self.dealer_service_factory.get_instance( "dealership")
def get_all_advisor(request, dealer_code): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() service_layer = customer_factory.get_instance("user") #CUserService() media_url = settings.MEDIA_URL dealer_service = dealer_factory.get_instance( "dealership") #DealerShipService() dealership = dealer_service.get_dealer_by( request.session.get("dealer_code")) selected_advisor_id = None appointment = None rtype = request.GET.get("type", "appointment") profile_id = request.GET.get("profile_id") """when saving for appointment""" if rtype == "appointment": appointment_id = request.GET.get("appointment_id") service = dealer_factory.get_instance( "appointment") #AppointmentService() appointment = service.get_appointment(appointment_id) if appointment and appointment.advisor: selected_advisor_id = appointment.advisor.id if selected_advisor_id == None and appointment: try: customer_advisor = CustomerAdvisor.objects.get( customer_id=appointment.customer.id) selected_advisor_id = customer_advisor.advisor.id except Exception, e: print e customer_advisor = None
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 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 login(request, dealer_code=None): '''Get username ,password and authenticate ''' customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.user.is_authenticated() and request.user.groups.filter( name__in=[confg.GROUP_NAME]): return HttpResponseRedirect(reverse('customer:main')) if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password']) if user is not None: if user.is_active: auth_login(request, user) request.session["dealer_code"] = dealer_code referrer = request.POST.get("referrer", "") if referrer and referrer != "": # return HttpResponseRedirect(reverse('customer:main')) return HttpResponseRedirect(referrer) else: return HttpResponseRedirect(reverse('customer:main')) else: form.add_error("username", "User is not active") else: try: user = User.objects.get( username=form.cleaned_data['username']) form.add_error("username", "Password is incorrect.") except Exception, e: form.add_error("username", "Username is incorrect.")
def createuser(request, dealer_code=None): customer_factory = CustomerServicesFactory() userservice = customer_factory.get_instance("user") #CUserService() if request.method == 'POST': form = CreateUserForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] profile_id = form.cleaned_data["profile"] profile = userservice.get_user_profile(profile_id) user = userservice.create_customer(username) referrer = request.POST.get("referrer") if user: user.set_password(form.cleaned_data['new']) user.save() messages.success( request, "Account has been successfully created. Your information will be stored for future service appointment needs. Please click 'DONE' to review your appointment, make changes or cancel the appointment." ) if profile: profile.user = user profile.save() if referrer: return HttpResponseRedirect(referrer) else: return HttpResponseRedirect( reverse('customer:index') + "?dealer_code=" + dealer_code) else: print form.errors print "form not valid"
def get_cart(request,dealer_code,profile,appointment): try: if appointment: customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance("dealership") dealer = dealer_service.get_dealer_by(dealer_code) userservice = customer_factory.get_instance("user") appointmentservice = dealer_factory.get_instance("appointment") repairservice = dealer_factory.get_instance("repair") services = repairservice.get_service_for(appointment.id,'s') repairs = repairservice.get_service_for(appointment.id,'r') print services print repairs context = { "mainurl":settings.MEDIA_ROOT, "appointment":appointment, "dealer_code":dealer_code, "services":services,"repairs":repairs, "cart_count":len(repairs)+len(services) } return render(request, "customer/cart/main.html",context) else: # return "" return render(request, "customer/cart/main.html",{}) except Exception,e: print e
def passreset(request, dealer_code=None): '''Reseting Password email''' customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.method == 'POST': form = ResetForm(request.POST) if form.is_valid(): try: user_service = customer_factory.get_instance("user") profile = user_service.get_user_profile_by_email( form.cleaned_data['email']) if profile == None: raise Exception("Email not found") token = user_service.create_token(profile.user) try: user_service.send_pass_reset_link_profile( profile, token, form.cleaned_data['email'], dealer_code) messages.success(request, 'Email has been sent') except Exception, e: print e form.add_error("email", "email sending failed") except Exception, e: form.add_error("email", "email doesnot exist")
def index(request, dealer_code, profile): """ this method is the index view for the chat session. Its just a test page currently for advisors """ customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance( "dealership") #DealerShipService() dealership = dealer_service.get_dealer_by(dealer_code) userservice = customer_factory.get_instance("user") #CUserService() # userservice = UserService() advisor = userservice.get_advisor_for_chat(dealership, profile) img = UploadForm() template_name = 'livechat/advisorchat.html' chat_username = getUserName(request) chat_nick = getChatNick(request) return render( request, template_name, { "CENTRIFUGE_URL": settings.CENTRIFUGE_URL, "CENTRIFUGE_SECRET": settings.CENTRIFUGE_SECRET, "advisor": advisor, "chat_username": chat_username, "chat_nick": chat_nick, 'form': img })
def index(request, appointment_id): customer_factory = CustomerServicesFactory() service = customer_factory.get_instance("user") templates = "customer/statusalert/index.html" try: appt_details = Appointment.objects.get(id=appointment_id) except Appointment.DoesNotExist: raise Http404 flages = Flags.objects.filter(type=3, customer_facing=True, dealer_id=appt_details.dealer.id) recmndations = AppointmentRecommendation.objects.filter( appointment_id=appointment_id) total = 0 for obj in recmndations: total += obj.price appt_services = AppointmentService.objects.filter( appointment_id=appointment_id) if appt_details: userprofile = appt_details.customer # userprofile =service.get_userprofile(request.user) service_total = 0 for obj in appt_services: service_total += obj.price approved_recmm = AppointmentRecommendation.objects.filter( appointment_id=appointment_id, status="Accept") for obj in approved_recmm: service_total += obj.price dealer = appt_details.dealer dealer_code = None if dealer: dealer_code = dealer.dealer_code context = { 'flages': flages, 'appt': appt_details, 'recommandations': recmndations, 'total': total, 'appt_services': appt_services, 'approved_rec': approved_recmm, 's_total': service_total, 'dealer_code': dealer_code } service.set_centrifuge_context(request, dealer_code, userprofile, context, chatposition="top") return render(request, templates, context)
def ocr_snap(request): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.POST.get("imgBase64") != None: cameraservice = customer_factory.get_instance( "camera") #CameraService() img = cameraservice.get_image_from_base64( request.POST.get("imgBase64")) print img qr_text = cameraservice.get_zbar_from(img) # qr_text = "baAe" return JsonResponse({"resp": qr_text})
def delete(request): try: customer_factory = CustomerServicesFactory() user = request.user service = customer_factory.get_instance("account") #AccountService() resp = service.delete_account(user.userprofile) if resp: messages.success(request, "Account Deleted Successfully") else: messages.success(request, "Unable to Delete Account") except: messages.error(request, "Unable to Deleted account. Try later") return HttpResponseRedirect(reverse("customer:accountsettings"))
def save_customer_number(request): if request.GET.get("phone_number"): customer_factory = CustomerServicesFactory() user_service = customer_factory.get_instance("user") profile = user_service.get_userprofile(request.user) phone_number = request.GET.get("phone_number") carrier_choices = request.GET.get("carrier") user_service.save_active_phone(profile, phone_number, carrier_choice=carrier_choices) return JsonResponse({"success": True}, safe=False) else: return JsonResponse({"success": False}, safe=False)
def notificationssettings(request,dealer_code,profile): """ This is the notification screen. This is used to save settings """ customer_factory = CustomerServicesFactory() dealer_factory= DealerShipServicesFactory() user_service = customer_factory.get_instance("user") profile = user_service.get_userprofile(request.user) notificationservice = dealer_factory.get_instance("notification") remindersettings = notificationservice.get_user_remindersettings(profile,True) phone_numbers = user_service.get_profile_numbers(profile) emails = user_service.get_profile_emails(profile) carrier_choices = ( ("Verizon"), ("AT & T"), ) tab = "notification" if request.method == "POST": special_offer_notify = False if request.POST.get("special_offer_notify"): special_offer_notify = True ids = request.POST.getlist("settings_id") for id in ids: textset = False phoneset=False emailset = False if request.POST.get("setting_email_"+id): emailset = True if request.POST.get("setting_text_"+id): textset=True if request.POST.get("setting_phone_"+id): phoneset=True notificationservice.save_reminder_settings(id,emailset,textset,phoneset) # user_service.save_active_phone(profile,request.POST.get("active_phone_number")) user_service.save_active_email(profile,request.POST.get("active_email")) user_service.save_special_offer_notify(profile,special_offer_notify) messages.success(request, "Reminder settings saved successfully") return HttpResponseRedirect(reverse("customer:notifications")) else: context = {"dealer_code":dealer_code,"tab":tab,"page_title":"Customer Profile", "remindersettings":remindersettings, "phonenumbers":phone_numbers, "emails":emails,"profile":profile,"carrier_choices":carrier_choices} user_service.set_centrifuge_context(request, dealer_code,profile,context,chatposition="top") return render(request, "customer/notifications.html",context )
def sync_gcalendar(request): gcalservice = GoogleService() if request.GET.get("appointment_id"): if request.GET.get("refferrer"): request.session["refferrer"] = request.GET.get("refferrer") customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance("dealership") # dealer = dealer_service.get_dealer_by(dealer_code) uservice = customer_factory.get_instance("user") #CUserService() appt_service = dealer_factory.get_instance( "appointment") #AppointmentService() appointment = appt_service.get_appointment( request.GET.get("appointment_id")) #,dealer) # REDIRECT_URI = 'http://127.0.0.1:8000/customer/oauth2callback/'#?appointment_id='+request.GET.get("appointment_id") request.session["oauth_appointment"] = request.GET.get( "appointment_id") #REDIRECT_URI = "https://%s%s" % ( # get_current_site(request).domain, reverse("customer:return")) REDIRECT_URI = settings.SITE_MAIN_URL + reverse("customer:return") CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), gcalservice.CLIENT_SECRET_FILE) FLOW = flow_from_clientsecrets(CLIENT_SECRETS, scope=gcalservice.SCOPES, redirect_uri=REDIRECT_URI) storage = Storage(CredentialsModel, 'id', appointment, 'credential') credential = storage.get() if credential is None or credential.invalid is True: FLOW.params['state'] = xsrfutil.generate_token( settings.SECRET_KEY, appointment) authorize_url = FLOW.step1_get_authorize_url() f = FlowModel(id=appointment, flow=FLOW) f.save() return HttpResponseRedirect(authorize_url) else: resp = gcalservice.create_event(appointment, credential) messages.success( request, "Your appointment has been added to Google Calendars") if request.session.get("refferrer"): refferrer = request.session["refferrer"] del request.session["refferrer"] return HttpResponseRedirect(refferrer) else: return JsonResponse({"success": resp}, safe=False)
def save_all_services(request, dealer_code=None): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() service_layer = dealer_factory.get_instance("repair") #RepairService() success = False stype = request.GET.get("type") if request.GET.get("appointment_id") != None and request.GET.get( "services") != None: appt_id = request.GET.get("appointment_id") services = mainjson.loads(request.GET.get("services")) service_layer.create_update_delete_appointment_services( appt_id, services, stype) success = True return JsonResponse({"success": success})
def get_vehicle(request): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() resp = {} make = request.GET.get("make") model = request.GET.get("model") trim = request.GET.get("trim") year = request.GET.get("year") service = dealer_factory.get_instance("vehicle") #VehicleService() vehicles = service.get_vehichles(make, model, trim, year, 1) # vehicles = serializers.serialize('json', vehicles) resp["success"] = True resp["media_url"] = settings.MEDIA_URL resp["vehicles"] = list(vehicles) return JsonResponse(resp, safe=False)
def testing(request, dealer_code=None): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance( "dealership") #DealerShipService() dealership = dealer_service.get_dealer_by( request.session.get("dealer_code")) capacityservice = dealer_factory.get_instance("capacity") # slab_time = timezone.now() - timedelta(hours=44) slab_time = datetime.datetime.strptime('Jan 29 2016 9:20AM', '%b %d %Y %I:%M%p') slab_time = timezone.make_aware(slab_time) print slab_time capacity = capacityservice.check_slab_availibity(slab_time, dealership) print capacity
def del_vehicle(request, dealer_code, profile): """ this request is used to delete the vehicle """ customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.GET.get("vehicle_id"): vid = request.GET.get("vehicle_id") service = dealer_factory.get_instance("vehicle") #VehicleService() if service.user_allowed_delete(vid, request.user.userprofile.id): service.delete_customer_vehicle(vid) messages.success(request, "Vehicle delete successfully") else: messages.error(request, "User not allowed to delete vehicle", "danger") return HttpResponseRedirect(reverse("customer:main"))
def setservices(self): from customer.factories import CustomerServicesFactory from dealership.factories import DealerShipServicesFactory self.customer_service_factory = CustomerServicesFactory() self.dealer_service_factory = DealerShipServicesFactory() self.cuserservice = self.customer_service_factory.get_instance("user") self.userservice = self.dealer_service_factory.get_instance("user") self.vehicle_service = self.dealer_service_factory.get_instance( "vehicle") self.repair_service = self.dealer_service_factory.get_instance( "repair") self.dealership_service = self.dealer_service_factory.get_instance( "dealership") self.capacity_service = self.dealer_service_factory.get_instance( "capacity") self.email_service = self.dealer_service_factory.get_instance("email") self.appointment_service = self
def appointment_update_insurance(request): customer_factory = CustomerServicesFactory() service = customer_factory.get_instance("user") account_service = customer_factory.get_instance("account") if request.method == 'POST': userprofile =service.get_user_profile(request.POST.get('user')) insurance_profile = service.get_user_driver_insurance(userprofile) driver_initial =account_service.get_initial_driver_form(request.POST.get('customer_id'), insurance_profile,userprofile) driver_form = CustomerInsuranceForm(request.POST,instance = insurance_profile, initial=driver_initial) if driver_form.is_valid(): resp = driver_form.save() #result = account_service.save_driver_form(insurance_profile,driver_form) return JsonResponse({"status":"success", "message":"Insurance Information Updated Successfully"}) else: return JsonResponse({"status":"error", "message":"Insurance Data is not Valid"}) return JsonResponse({"status":"error"})
def registeruer(request, dealer_code=None): customer_factory = CustomerServicesFactory() cuser = customer_factory.get_instance("user") if request.GET.get("profile_id"): profile = cuser.get_user_profile(request.GET.get("profile_id")) if profile: initial_user_form = {"profile": profile.id} usercreateform = CreateUserForm(initial=initial_user_form) return render( request, "customer/registeruser.html", { "usercreationform": usercreateform, "profile": profile, "done_disable": True, "request": request }) else: raise Http404("Profile not found")
def appointment_update_creditcard(request): customer_factory = CustomerServicesFactory() service = customer_factory.get_instance("user") account_service = customer_factory.get_instance("account") if request.method == 'POST': userprofile =service.get_user_profile(request.POST.get('user')) cc_profile = service.get_cc_profile(userprofile) cc_form = CreditDebitForm(request.POST,instance = cc_profile) if cc_form.is_valid(): resp = account_service.save_cc_form(cc_profile,cc_form) if resp == True: return JsonResponse({"status":"success", "message":"Credit Card Information Updated Successfully"}) else: return JsonResponse({"status":"error", "message":"Credit Card Information Failed to Update"}) else: return JsonResponse({"status":"error", "message":"Credit Card Data is not Valid"}) #return JsonResponse({"status":"error", "errors":cc_form.errors}) return JsonResponse({"status":"error"})
def passcreate(request, dealer_code=None): '''Setting new password''' customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() form = UserPasswordResetForm() template = 'customer/404.html' question = '' token = request.GET.get('token') if token is not None: user_service = customer_factory.get_instance("user") user = user_service.get_user_from_token(token) if user is not None: template = 'customer/password_create.html' # question = user_service.get_user_question(user) if request.method == 'POST': form = UserPasswordResetForm(request.POST) if form.is_valid(): # if user_service.verify_user_answer(user, form.cleaned_data['answer']) == True: user_service.save_user_password(user, form.cleaned_data['new']) messages.success( request, 'Password has been updated. Please provide the new credentials' ) return HttpResponseRedirect( reverse('customer:index') + "?dealer_code=" + dealer_code) # else: # form.add_error("answer","You have not provided the correct answer") else: print form.errors else: print "user not found" context = { 'form': form, 'question': None, 'token': token, "dealer_code": dealer_code } return render(request, template, context)
def index(request, dealer_code=None): '''Main Page View''' customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.user.is_authenticated() and request.user.groups.filter( name__in=[confg.GROUP_NAME]): return HttpResponseRedirect(reverse('customer:main')) form = LoginForm() userservice = customer_factory.get_instance("user") #CUserService() context = { 'form': form, "dealer_code": dealer_code, "tab": "", "request": request } template_name = 'customer/login_form.html' userservice.set_centrifuge_context(request, dealer_code, None, context) return render(request, template_name, context)
def auth_return(request): # user = request.user if request.session.get("oauth_appointment"): customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() dealer_service = dealer_factory.get_instance("dealership") appt_service = dealer_factory.get_instance( "appointment") #AppointmentService() appointment = appt_service.get_appointment( request.session.get("oauth_appointment")) #,dealer) # if not xsrfutil.validate_token( # settings.SECRET_KEY, request.REQUEST['state'], user): # return HttpResponseBadRequest() FLOW = FlowModel.objects.get(id=appointment).flow credential = FLOW.step2_exchange(request.REQUEST) storage = Storage(CredentialsModel, 'id', appointment, 'credential') storage.put(credential) return HttpResponseRedirect( reverse('customer:sync_gcalendar') + "?appointment_id=" + str(appointment.id))
def userreset(request, dealer_code=None): """ UserReset * Request to retrieve username """ customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.method == 'POST': form = ResetForm(request.POST) if form.is_valid(): try: cuser_service = customer_factory.get_instance("user") duser_service = dealer_factory.get_instance("user") profile = cuser_service.get_user_profile_by_email( form.cleaned_data['email']) if profile == None: raise Exception("Email not found") if dealer_group_check(profile.user) == False: form.add_error("email", conf.RESET_EMAIL_GROUP_ERROR) else: # user_service = UserService() try: duser_service.send_username_link_new( profile.user, form.cleaned_data['email']) messages.success(request, conf.RESET_EMAIL_SENT_MESSAGE) except: form.add_error("email", conf.RESET_EMAIL_SENT_ERROR) except: form.add_error("email", conf.RESET_EMAIL_EXIST_ERROR) else: form = ResetForm() template = login_template + 'username_reset.html' return render( request, template, { 'form': form, "name": request.session["dealer_name"], "code": request.session["dealer_code"] })
def edit_customer(request): if request.POST: customer_factory = CustomerServicesFactory() uservice = customer_factory.get_instance("user") phone_number = request.POST.get("phone_number_1") email = request.POST.get("email_1") id = request.POST.get("id") profile = uservice.get_user_profile_by_phone(phone_number) if profile == None or profile.id == id: profile = uservice.get_user_profile_by_email(email) if profile == None or profile.id == id: profile = UserProfile.objects.get(id=id) customer_form = CustomerGuestAccountForm(request.POST, instance=profile) if customer_form.is_valid(): customer_form.save() return JsonResponse({"success": True, 'message': 'accepted'}) else: return JsonResponse({ "success": False, 'message': [(k, v[0]) for k, v in customer_form.errors.items()] })
def passreset(request, dealer_code=None): """ PassCreate * Request for creating new password """ customer_factory = CustomerServicesFactory() dealer_factory = DealerShipServicesFactory() if request.method == 'POST': form = ResetForm(request.POST) if form.is_valid(): try: # user = User.objects.get(email = form.cleaned_data['email']) cuser_service = customer_factory.get_instance("user") duser_service = dealer_factory.get_instance("user") profile = cuser_service.get_user_profile_by_email( form.cleaned_data['email']) if profile == None: raise Exception("Email not found") if dealer_group_check(profile.user) == False: print "Not in dealer group" form.add_error("email", conf.RESET_EMAIL_GROUP_ERROR) else: # user_service = UserService() try: duser_service.send_pass_reset_link_new( profile.user, request, reverse("dealership:passcreate"), form.cleaned_data['email'], dealer_code) messages.success(request, conf.RESET_EMAIL_SENT_MESSAGE) except Exception, e: print e form.add_error("email", conf.RESET_EMAIL_SENT_ERROR) except Exception, e: print e form.add_error("email", conf.RESET_EMAIL_EXIST_ERROR)
def appointment_detail_ajax_view(request): template = 'overview/detail.html' context = {} customer_factory = CustomerServicesFactory() if request.method == 'POST': dealer_factory = DealerShipServicesFactory() aptservice = dealer_factory.get_instance("appointment") vehicleservice = dealer_factory.get_instance("vehicle") service = customer_factory.get_instance("user") account_service = customer_factory.get_instance("account") userprofile =service.get_user_profile(request.POST.get('customer_id')) context = aptservice.get_appointment_by_id(request.POST.get('appointment_id')); print context['appointment'].checkin_time,"$$$$$$$$$$" #get credit card form cc_profile = service.get_cc_profile(userprofile) cc_initial = account_service.get_initial_cc_form(request.POST.get('customer_id'),cc_profile,userprofile) cc_form = CreditDebitForm(instance=cc_profile,initial=cc_initial) context['cc_form'] = cc_form #get vechicle information form vehicle_instance = vehicleservice.get_customer_vehicle(request.POST.get('vehicle_id')) vehicle_form = CustomerVehichleForm(instance=vehicle_instance) context['vehicle_form'] = vehicle_form #insurence form insurance_profile = service.get_user_driver_insurance(userprofile) driver_initial =account_service.get_initial_driver_form(request.POST.get('customer_id'), insurance_profile,userprofile) ins_form = CustomerInsuranceForm(instance=insurance_profile,initial=driver_initial) context['ins_form'] = ins_form if request.POST.get('checkin'): context['checkin'] = 'true' else: context['checkin'] = 'false' return render(request, template, context)