def on_from_clicked(self, button): entry = self.from_entry dbconf = dbconfig.dbConfig() #3:from subj? 5:from key if self.type_index is not None and self.type_configs[self.type_index][3]: if self.type_configs[self.type_index][5] == None: sub = subjects.Subjects() else: keys = self.type_configs[self.type_index][5] parent_id=[] for key in keys.split(','): if key == 'cash': val = dbconf.get_value(key) sub = share.config.db.session.query(Subject).filter(Subject.id == val).first() pID = sub.parent_id if pID !=0: parent_id.append(pID) else: parent_id.append(key) else: parent_id+=dbconf.get_int_list(key) sub = subjects.Subjects(parent_id=parent_id) sub.connect('subject-selected', self.on_subject_selected, entry, False) else: cust = customers.Customer() cust.connect('customer-selected', self.on_customer_selected, entry, False) cust.viewCustomers(True)
def customer_create_account(): """Checks if the input username is in the username_list. If so the function will call itself and tell the user the name is taken. If the username is available then a new line is inserted into the 'customers' table containing the username, and the change is committed. Customer and Basket objects are then instantiated, before calling customer_options()""" global item_number, item_list, user, user_basket, user_order, product_list, vendorname_list username = str(input("Please enter a new username:\n>>")) if username in username_list: print("Username already taken.") customer_create_account() elif username == 'cancel': quit() else: cur.execute("""INSERT INTO customers VALUES (?, ?, ?)""", (username, '', '')) con.commit() print("User account created.") user = customers.Customer(username) user_basket = customers.Basket() customer_options()
def selectSeller(self, sender=0): # not needed in submiting factor customer_win = customers.Customer() customer_win.viewCustomers() code = self.payerEntry.get_text() if code != '': customer_win.highlightCust(code) customer_win.connect("customer-selected", self.sellerSelected)
def random_valid_customer_for_transfer(context): creditor_name = names.get_full_name() creditor_document = customers.generate_cpf() creditor = customers.Customer(creditor_name, creditor_document) debtor_name = names.get_full_name() debtor_document = customers.generate_cpf() debtor = customers.Customer(debtor_name, debtor_document) creditor_response = creditor.create(context) debtor_response = debtor.create(context) assert creditor_response.status_code == 201 assert debtor_response.status_code == 201 random_value = random.random() * random.randint(1, 100) random_amount = float("{:.2f}".format(random_value)) context.transfer = Transfer(creditor, debtor, random_amount)
def selectSeller(self, sender=0): customer_win = customers.Customer() customer_win.viewCustomers() code = self.payerEntry.get_text() if code != '': customer_win.highlightCust(code) customer_win.connect("customer-selected", self.sellerSelected) print code
def test_customer(): auid = int(random.uniform(0, 1000)) alat = random.uniform(-90, 90) along = random.uniform(-180, 180) alice = customers.Customer(auid, 'Alice', coords.Coords(alat, along)) assert alice.user_id == auid assert alice.name == 'Alice' assert alice.coords.latitude == math.radians(alat) assert alice.coords.longitude == math.radians(along)
def signup(): first_name = request.form["first_name"] last_name = request.form["last_name"] email = request.form["email"] hashed_password = request.form["password"] new_customer = customers.Customer(first_name, last_name, email, hashed_password) customers.customers[email] = new_customer print(customers.customers) return redirect ('/melons')
def read_customers(self, fname): # Clears previous configuration self.customers.clear() # Closes the file when f gets out of scope with open(fname, 'r') as f: for line in f: # I'm parsing the json here and converting the data to the types # expected by the internal apis. jsline = json.loads(line) coords = cd.Coords(float(jsline['latitude']), float(jsline['longitude'])) self.customers.append( cs.Customer(jsline['user_id'], jsline['name'], coords))
def on_to_clicked(self, button): entry = self.to_entry dbconf = dbconfig.dbConfig() if self.type_configs[self.type_index][4]: if self.type_configs[self.type_index][6] == None: sub = subjects.Subjects() else: keys = self.type_configs[self.type_index][6] parent_id=[] for key in keys.split(','): parent_id+=dbconf.get_int_list(key) sub = subjects.Subjects(parent_id=parent_id) sub.connect('subject-selected', self.on_subject_selected, entry, True) else: cust = customers.Customer() cust.connect('customer-selected', self.on_customer_selected, entry, True) cust.viewCustomers(True)
def customer_login(): """If the input username is in the username_list above then this function creates a Customer and a Basket object and calls customer_options(). If the username is not in the list then it calls customer_int() again.""" global item_number, item_list, user, user_basket, user_order, product_list, vendorname_list username = str(input("Please enter username:\n>>")) if username in username_list: user = customers.Customer(username) user_basket = customers.Basket() customer_options() elif username == 'cancel': quit() else: print("Username not found") customer_int()
def selectCustomers(self, sender=0): customer_win = customers.Customer() customer_win.viewCustomers() customer_win.connect("customer-selected", self.sellerSelected)
def addCustomers(nameList): global names names = nameList for i in range(0, len(names)): c.Customer(names[i]) c.customersMap[names[i]] = i