Exemplo n.º 1
0
def checkin(request):
    try:
        station = request.user.groups.exclude(name='Associate')[0].name
        student_id = request.POST.get("student_id")
        student = Student.objects.get(id=student_id)
        ride = student.ride_set.latest("checkout_time")
        checkin_ride(ride, station)
        return HttpResponse("success")
    except Exception as error:
        email_razzi("Admin crashed. Locals: {}. Error: {}".format(locals(), error))
        print("Admin: {}".format(locals()))
        return HttpResponse("failure")
Exemplo n.º 2
0
def checkout(request):
    try:
        student = request.POST.get("student")
        student = Student.objects.get(name=student)
        bike = request.POST.get("bike")
        bike = Bike.objects.get(name=bike)
        make_ride(student, bike)
        return HttpResponse("success")
    except Exception as error:
        email_razzi("Admin crashed. Locals: {}. Error: {}".format(locals(), error))
        print("Admin: {}".format(locals()))
        return HttpResponse("failure")
Exemplo n.º 3
0
def verify_payment(request):
    payment = Payment.objects.get(id=request.POST.get('merchantDefinedData1'))
    # source = request.META.get('HTTP_REFERER')
    # source_needed = 'https://orderpage.ic3.com/hop/orderform.jsp'
    amount = str(request.POST.get('orderAmount', 0))
    cost_with_tax = float(payment.plan.cost)*1.08
    if float(amount) != cost_with_tax:
        email_razzi(
            "student didn't pay the right amount! Payment: {} "
            "Amount: {} Cost+tax: {}".format(payment.id, amount, cost_with_tax)
        )
        return HttpResponse('success')
    else:
        reasonCode = request.POST.get('reasonCode')
        good_reasons = [100, 200]
        if (int(reasonCode) in good_reasons):
            payment.satisfied = True
            payment.payment_type = 'credit'
            payment.payment_date = timezone.datetime.today()
            payment.save()
        return HttpResponse('success')