def setUp(self): customer = User.objects.create_user( email='*****@*****.**', password='******', phone_number="+441212121212", first_name="Alex", last_name="Smith") company = Company(phone_number="+441313131313", name="Melani Ltd") company.save() driver = Driver(phone_number="+441111111111", first_name="Prem", last_name="Kowalski", company=company, car_model="BWM", car_color="Black", car_license_plate="ABCD1234") driver.save() timezone.now() today = datetime(2013, 11, 20, 20, 8, 7, 127325, tzinfo=pytz.UTC) trip = Trip(customer=customer, pick_up_time=today, pick_up_place="Luton", drop_off_place="St. Albans", payment_method='1', driver=driver) trip.save()
def items_json(request): driver = Driver() items = driver.get_nearby_items_json( {'lat': 47.668017, 'lng': -122.385753}, 10 ) return StreamingHttpResponse(items, content_type='application/json')
def driver_post(request): print request.user print "-------------" person = Driver() person.user = request.user person.first_name = request.POST['first_name'] person.last_name = request.POST['last_name'] person.rating = 3 person.address = request.POST['address'] person.city = request.POST['city'] person.state = request.POST['state'] # print person person.phone_number =request.POST['phone_number'] person.ship_capacity = request.POST['ship_capacity'] person.vehicle_model = request.POST['vehicle_model'] try: person.photo = request.FILES['photo'] except: return render(request, 'frontEnd/driver.html', {'form': DriverForm()}) try: person.save() except ValueError: success = False else: success= True template_name="frontEnd/driver_post.html" return HttpResponse(render(request, template_name, {'success': success}))