def post(self): user = users.get_current_user() person = login.is_roommate_account_initialized(user) home = Home.query(Home.key == person.home_key).fetch()[0] bill_name = self.request.get('bill_name') payer_id = self.request.get('payer') payer_name = Person.query().filter( Person.user_id == payer_id).fetch()[0].name home_key = home.key bill = Bills(bill_name=bill_name, home_key=home_key, payer_id=payer_id, payer_name=payer_name) bill.put() render.render_page(self, 'billsCreated.html', 'Bill Created') helpers.redirect(self, '/dashboard', 1000)
def main(): DBconnection() db = DBconnection.getInstance().connection while True: print("Acciones a realizar: \n \ 1. Cliente\n \ 2. Categorías de item\n \ 3. Items\n \ 4. Factura\n \ 5. Salir") action = input("Ingrese el número de la acción que desea realizar: ") if action == "1": customer = Customers(db) elif action == "2": category = ItemCategories(db) elif action == "3": item = Items(db) elif action == "4": bill = Bills(db) elif action == "5": exit() else: print("Ingrese un número válido")
def getDashData(self, person): if person: home = Home.query().filter(Home.key == person.home_key).fetch() dnd_state = False home_stickies = [] checked_in = [] checked_out = [] people_in_home = [] has_dnd_on = [] for id in home[0].occupants: people_in_home.append(Person.query().filter(id == Person.user_id).fetch()[0]) for p in people_in_home: if p.location: checked_in.append(p) else: checked_out.append(p) if p.do_not_disturb: has_dnd_on.append(p) # Check for and delete expired sticky notes for sticky_note in Sticky.query().filter(Sticky.home_key == person.home_key).fetch(): if sticky_note.expiration < time.time(): sticky_note.key.delete() else: home_stickies.append(sticky_note) # fetch chores chores = Chore.query().filter(Chore.home_key==home[0].key).fetch() # update chores for chore in chores: if chore.end_time < time.time(): chore.end_time = chore.end_time + chore.duration chore.index = (chore.index + 1)%len(chore.workers) chore.completed = False chore.put() # fetch bills bills = Bills.query().filter(Bills.home_key==home[0].key).fetch() # fetch room name room_name = home[0].name # for person in people_in_home: # logging.info(person.name) return_data = {'room_name': room_name, 'bills': bills, 'chores': chores, 'checked_in' : checked_in, 'checked_out' : checked_out, 'has_dnd_on' : has_dnd_on ,'home_stickies' : home_stickies, 'person': person} return return_data
def removeFromRoom(self, user): person = login.is_roommate_account_initialized(user) if person: home = Home.query().filter(Home.key == person.home_key).fetch()[0] logging.info("Person: ") logging.info(person) logging.info("Home Occupants: ") logging.info(home.occupants) else: logging.info("no person") #Removes person from record of Home if person.user_id in home.occupants: home.occupants.remove(person.user_id) logging.info("Home occupants: ") logging.info(home.occupants) chores = Chore.query().filter(Chore.home_key == home.key) bills = Bills.query().filter(Bills.home_key == home.key) if len(home.occupants) == 0: for c in chores: c.key.delete() for b in bills: b.key.delete() home.key.delete() else: #Creo que esto funcione for c in chores: if person.user_id in c.workers: c.workers.remove(person.user_id) for b in bills: if b.payer_id == person.user_id: b.key.delete() home.put() #Find stickies associated with person stickies = Sticky.query().filter(Sticky.author == person.user_id) for note in stickies: note.key.delete() #Updates person and home entries person.key.delete()
def on_bills_clicked(self): self.bills = Bills(self.wm, self.user) self.setVisible(False)
def get_last(bills_qty=1): bills_details = Bills().get_last_with_details(bills_qty) transactions = Transactions().get_all() return BillTransactions.__process_bill_transactions( bills_details, transactions)