Ejemplo n.º 1
0
def upload(request):
    sendjson = Sendjson()
    uf = uploadfile(request.POST, request.FILES)
    print("wait")
    if uf.is_valid():
        print("success")
        user_id = uf.cleaned_data["userid"]
        imgtype = uf.cleaned_data["imgtype"]
        img = uf.cleaned_data["photo"]

        if (imgtype == "car_id"):
            path = "static/uploadcar/"
            handle_uploaded_file(img, user_id, path)
            user_info.objects.filter(user_id=user_id).update(car_id=img)

        elif (imgtype == "driver_id"):
            path = "static/uploaddriver/"
            handle_uploaded_file(img, user_id, path)
            user_info.objects.filter(user_id=user_id).update(driver_id=img)
        param = {"car_path": path + user_id + "_" + img.name}
        sendjson.set_resParam(param)
        sendjson.set_resNode("success")
    else:
        uf = uploadfile()
        print("false")
        sendjson.set_resNode("fales")
    return sendjson.get_json()
Ejemplo n.º 2
0
def listview(request):
    sendjson = Sendjson()
    user_id = request.POST["user_id"]
    try:
        list = order.objects.get(user_id=user_id)
        return_param = {"param": sendjson.list_json(list)}
        sendjson.set_resNode("success")
        sendjson.set_resParam(return_param)
    except:
        sendjson.set_resNode("error")
Ejemplo n.º 3
0
def checkpassword(request):
    sendjson = Sendjson()
    loginid = request.POST["loginid"]
    password = request.POST["password"]
    try:
        login.objects.get(login_ID=loginid, password=password)
        sendjson.set_resNode("success")
    except:
        sendjson.set_resNode("wrong password")
    return sendjson.get_json()
Ejemplo n.º 4
0
def getuserinfor(request):
    sendjson = Sendjson()
    user_id = request.POST["user_id"]
    try:
        userinfor = user_info.objects.get(user_id=user_id)
        user_dic = model_to_dict(userinfor)
        return_param = {"user_info": user_dic}
        sendjson.set_resNode("success")
        sendjson.set_resParam(return_param)
    except Exception as e:
        sendjson.set_resNode(e)
    return sendjson.get_json()
Ejemplo n.º 5
0
def changpassword(request):
    sendjson = Sendjson()
    loginid = request.POST["loginid"]
    password = request.POST["password"]
    try:
        changlog = login.objects.get(login_ID=loginid)
        changlog.password = password
        changlog.save()
        sendjson.set_resNode("success")
    except:
        sendjson.set_resNode("false")
    return sendjson.get_json()
Ejemplo n.º 6
0
def getpicurl(request):
    sendjson = Sendjson()
    voyage_id = request.POST["voyage_id"]

    imgurl = voyage.objects.get(voyage_id=voyage_id).imgname
    imgurl = "/mystatic/equipment/" + str(imgurl)
    sendjson.set_resNode("success")
    return_param = {"imgurl": imgurl}

    sendjson.set_resParam(return_param)

    return sendjson.get_json()
Ejemplo n.º 7
0
def register(request):
    sendjson = Sendjson()
    reg_username = request.POST["username"]
    reg_password = request.POST["password"]
    getlog = login.objects.get_or_create(username=reg_username,
                                         password=reg_password)
    if (getlog[1]):
        login_ID = login.objects.get(username=reg_username,
                                     password=reg_password).login_ID
        request.session['log_id'] = login_ID
        sendjson.set_resNode("success")
    else:
        sendjson.set_resNode("this name is been used")
    return sendjson.get_json()
Ejemplo n.º 8
0
def getorder(request):
    sendjson = Sendjson()
    type = request.POST["type"]
    user_id = request.POST["userid"]

    if (type != "2"):
        list = order.objects.filter(type=type, take_user_id=user_id)
    else:
        list = order.objects.filter(take_user_id=user_id)
    return_param = {"param": sendjson.list_json(list)}
    sendjson.set_resNode("success")
    sendjson.set_resParam(return_param)

    return sendjson.get_json()
Ejemplo n.º 9
0
def getvoyage(request):
    sendjson = Sendjson()
    voyage_id = request.POST["voyage_id"]
    user_id = request.POST["userid"]
    try:
        voyagemod = voyage.objects.get(voyage_id=voyage_id,
                                       take_user_id=user_id)
        voyagemod_dic = model_to_dict(voyagemod)
        return_param = {"param": voyagemod_dic}
        sendjson.set_resNode("success")
        sendjson.set_resParam(return_param)
    except Exception as e:
        sendjson.set_resNode(e)
    return sendjson.get_json()
Ejemplo n.º 10
0
def insertuserinfor(request):
    sendjson = Sendjson()
    loginid = request.POST["loginid"]
    truename = request.POST["truename"]
    carnumber = request.POST["carnumber"]
    phone = request.POST["phone"]
    name = request.POST["name"]
    address = request.POST["address"]
    try:
        obj = user_info(truename=truename,
                        carnumber=carnumber,
                        phone=phone,
                        address=address,
                        name=name)
        obj.save()
        login.objects.filter(login_ID=loginid).update(user_id=obj.user_id)
        sendjson.set_resNode("success")
    except:
        sendjson.set_resNode("wrong")
    return sendjson.get_json()
Ejemplo n.º 11
0
def getvoyagelist(request):
    sendjson = Sendjson()
    voyage_id = request.POST["voyage_id"]
    user_id = request.POST["userid"]

    voyagelist = order.objects.filter(voyage_id=voyage_id,
                                      take_user_id=user_id)
    voyagemod = voyage.objects.values("voyage_id", "voyage_num",
                                      "voyage_models", "get_box_address",
                                      "in_return_box",
                                      "take_user_id").get(voyage_id=voyage_id,
                                                          take_user_id=user_id)
    #voyagemod_dic = model_to_dict(voyagemod)
    return_param = {
        "param": sendjson.list_json(voyagelist),
        "object": voyagemod
    }
    sendjson.set_resNode("success")
    sendjson.set_resParam(return_param)

    return sendjson.get_json()
Ejemplo n.º 12
0
def log(request):
    sendjson = Sendjson()
    in_username = request.POST["username"]
    in_password = request.POST["password"]
    try:
        userlogin = login.objects.get(username=in_username,
                                      password=in_password)
        if (userlogin.user_id == None):
            sendjson.set_resNode("improve")
            return_param = {"userlogin": userlogin.login_ID}
            sendjson.set_resParam(return_param)
        else:
            sendjson.set_resNode("success")
            token = str(uuid.uuid1())
            userlogin.token = token
            userlogin.save()
            return_param = {
                "userlogin": userlogin.login_ID,
                "user_id": userlogin.user_id
            }
            sendjson.set_resParam(return_param)
            sendjson.set_reSession_ID(token)
    except Exception as e:
        sendjson.set_resNode("password wrong")
    return sendjson.get_json()
Ejemplo n.º 13
0
def inputorder(request):
    sendjson = Sendjson()
    if(chack_requset_type(request)):
        order_id = request.POST["order_id"]
        user_id = request.POST["user_id"]
        try:
            market_user_get.objects.create(order_id=order_id,user_id=user_id,company="person")
            sendjson.set_resNode("success")
        except:
            sendjson.set_resNode("failde")
    else:
        sendjson.set_resNode("wrong request type")
    return HttpResponse(sendjson.get_json())
Ejemplo n.º 14
0
def getorder(request):
    sendjson = Sendjson()
    if(chack_requset_type(request)):
         page = int(request.POST['page'])
         count = int(request.POST['count'])
         try:
            list =   market_user_pub.objects.exclude(is_valid=1)[(page-1)*count:page*count-1]
            return_param = {
                "param": sendjson.list_json(list)
            }
            sendjson.set_resNode("success")
            sendjson.set_resParam(return_param)
         except Exception as e:
             sendjson.set_resNode(e)
    else:
        sendjson.set_resNode("wrong request type")
    return HttpResponse(sendjson.get_json())
Ejemplo n.º 15
0
def aslog(query):
    sendjson = Sendjson()
    sendjson.set_resNode("success")
    params = {"userlogin": query.login_ID, "user_id": query.user_id}
    sendjson.set_resParam(params)
    return sendjson.get_json()