Ejemplo n.º 1
0
def importFromXLS4():
    import xlrd
    customList = xlrd.open_workbook("ALL PARTY DETAILS.xlsx")
    worksheet = customList.sheet_by_name("Sheet1")

    for i in range(2, 50):
        customer = worksheet.cell(i, 0).value
        city = worksheet.cell(i, 3).value
        address = worksheet.cell(i, 10).value
        customerObject = Customer()
        customerObject.cName = customer
        customerObject.address = address
        customerObject.city = city
        customerObject.save()
Ejemplo n.º 2
0
 def save(self, user):
     try:	
         data = user.get_profile()
     except:
         data = Customer(user=user)
         
     print 'Inside save method of UserRegForm'
     
     data.first_name = self.cleaned_data["first_name"]
     data.last_name = self.cleaned_data["last_name"]
     data.address = self.cleaned_data["address"]
     data.city = self.cleaned_data["city"]
     data.zip = self.cleaned_data["zip"]
     data.date_of_birth = self.cleaned_data["date_of_birth"]
     data.save()
Ejemplo n.º 3
0
def importFromXLS():
    import xlrd
    customList = xlrd.open_workbook("list.xls")
    worksheet = customList.sheet_by_name("Sheet1")

    for i in range(9, 3582):
        if worksheet.cell(i, 9).value != "":
            city = worksheet.cell(i, 9).value
        if worksheet.cell(i, 7).value != "":
            uniqueCode = worksheet.cell(i, 3).value
            customer = worksheet.cell(i, 7).value
            address = worksheet.cell(i, 14).value
            customerObject = Customer()
            customerObject.cName = customer
            customerObject.address = address
            customerObject.city = city
            customerObject.usn = uniqueCode
            customerObject.save()
Ejemplo n.º 4
0
def importFromXLS1():
    import xlrd
    customList = xlrd.open_workbook("VVM STOCKIEST LIST.XLS")
    worksheet = customList.sheet_by_name("Sheet1")

    for i in range(5, 707, 6):
        code = worksheet.cell(i, 1).value
        customer = worksheet.cell(i, 3).value

        address1 = worksheet.cell(i + 1, 3).value
        address2 = worksheet.cell(i + 2, 3).value
        address3 = worksheet.cell(i + 3, 3).value
        city = worksheet.cell(i + 4, 3).value
        customerObject = Customer()
        customerObject.cName = customer
        customerObject.address = address1 + " " + address2 + " " + address3
        customerObject.city = city
        customerObject.usn = code
        customerObject.save()
Ejemplo n.º 5
0
def register_customer():
    if request.method == 'POST':
        token = request.headers.get('token')
        if not token:
            return Response(json.dumps(
                {"Message": "Please supply proper credentials"}),
                            status=400,
                            content_type="application/json")
        if not check_auth(token):
            return Response(json.dumps({"Message": "Unauthorized access"}),
                            status=401,
                            content_type="application/json")
        json_request = json.loads(request.data)
        c = Customer()
        try:
            c.first_name = json_request['first_name']
            c.last_name = json_request['last_name']
            c.address = json_request['address']
            c.contact_no = json_request['contact_no']
            c.driving_licence_link = json_request['driving_licence_link']
            c.email = json_request['email']
            c.password = json_request['password']
            vehicles = json_request['vehicles']
        except:
            return Response(json.dumps({"Message": "In-Complete form data"}),
                            status=400,
                            content_type="application/json")
        try:
            if not (int(c.contact_no) > 1000000000
                    and int(c.contact_no) <= 9999999999):
                return Response(json.dumps(
                    {"Message": "Contact no. not valid"}),
                                status=400,
                                content_type="application/json")
        except:
            return Response(json.dumps({"Message": "Contact no. not valid"}),
                            status=400,
                            content_type="application/json")
        for vehicle in vehicles:
            v = Vehicle()
            try:
                v.vehicle_type = vehicle['vehicle_type']
                v.vehicle_number = vehicle['vehicle_number']
                v.vehicle_rc_link = vehicle['vehicle_rc_link']
            except:
                return Response(json.dumps(
                    {"Message": "In-Complete form data"}),
                                status=400,
                                content_type="application/json")
            v.save()
            c.vehicles.append(v)
        try:
            c.save()
        except NotUniqueError:
            for vehicle in c.vehicles:
                v = Vehicle.objects.get(vid=vehicle.vid)
                v.delete()
            return Response(json.dumps(
                {"Message": "Customer with same e-mail already exists"}),
                            status=400,
                            content_type="application/json")
        ewallet_reg_url = "http://0.0.0.0:8000/login?x=1&name=" + str(
            c.cid) + "&password="******"QR_CODE_DATA": c.QR_CODE_DATA}),
                        status=200,
                        content_type="application/json")