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)