def login(self): for user in connection.get_users(): if user.get('username') == self.usernameLineEdit.text() and user.get( 'password') == self.passwordLineEdit.text(): self.user_window = UserWindow(user) self.user_window.show() self.hide()
def delete_reserve(self): if self.reservesTableWidget.item(self.reservesTableWidget.currentRow(), 0) is not None: name = self.reservesTableWidget.item(self.reservesTableWidget.currentRow(), 0).text() for user in connection.get_users(): if user.get('name') == name: connection.delete_reserve_by_user_id(user.get('_id')) self.refresh_table() break
def order_paid(self): if self.ordersList_2.currentItem() is None: return users = connection.get_users() for i in users: if i.get('username') == self.ordersList_2.currentItem().text(): connection.paid_order(i.get('_id')) self.refresh_orders_list_2()
def send_to_kitchen(self): if self.ordersList.currentItem() is None: return users = connection.get_users() for i in users: if i.get('username') == self.ordersList.currentItem().text(): connection.set_order_status(i.get('_id'), "cooking") self.refresh_orders_list()
def send_to_paid(self): if self.ordersList.currentItem() is None: return users = connection.get_users() for i in users: if i.get('username') == self.ordersList.currentItem().text(): connection.set_order_status(i.get('_id'), "completed") break self.refresh_orders_list()
def registration(self): if len(self.usernameLineEdit.text()) < 1 or len(self.passwordLineEdit.text()) < 1 or len( self.nameLineEdit.text()) < 1 or len(self.surnameLineEdit.text()) < 1: self.info("Ви заповнили не всі поля") return for user in connection.get_users(): if user.get('username') == self.usernameLineEdit.text(): self.usernameLineEdit.clear() self.info("Користувачів з таким логіном вже існує") return user = {'username': self.usernameLineEdit.text(), 'password': self.passwordLineEdit.text(), 'name': self.nameLineEdit.text() + " " + self.surnameLineEdit.text()} connection.insert_user(user) self.close()
def mark_attendance(subject, hostid=1): COUNT = 0 userinfos = connection.get_users(hostid) for _, username, password, _ in userinfos: for ATTEMPT in range(MAX_ATTEMPTS): try: COUNT += int(mark_and_log(username, password, subject)) break except Exception as e: print( f"EXCEPTION [{ATTEMPT}/{MAX_ATTEMPTS}] {username} - {str(e)}" ) if (COUNT > 0): return f"OK - {COUNT}/{len(userinfos)}" else: return f"NOT SUCCESSFUL"