def update_menu(req): try: tid = req['tid'] items = req['items'] for item in items: menus = [x.mid for x in Menus.query.filter(Menus.tid == tid).all()] i = Menu_Items.query.filter( Menu_Items.iid == item['iid'], Menu_Items.mid.in_(menus)).one_or_none() if i: try: mid = i.mid cat = item['category'] it = item['item'] inv = item['inv'] descr = item['descr'] price = item['price'] i.update_item(mid, cat, it, inv, descr, price) Session.commit() except Exception as e: logger.critical(e) return -1 else: return -2 except Exception as e: logger.critical(e) return -1 return tid
def delete(): Messages.query.delete() Session.commit() messages = Messages.query.all() if len(messages) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in messages])
def delete(): Menu_Items.query.delete() Session.commit() m_items = Menu_Items.query.all() if len(m_items) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in m_items])
def delete(): Users.query.delete() Session.commit() users = Users.query.all() if len(users) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in users])
def delete(): Trucks.query.delete() Session.commit() trucks = Trucks.query.all() if len(trucks) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in trucks])
def delete(): Truck_Locs.query.delete() Session.commit() locs = Truck_Locs.query.all() if len(locs) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in locs])
def delete(): m_items = [x.asdict() for x in Menu_Items.query.all()] if len(m_items) > 0: print('Clear Menu_Items first.') sys.exit(1) Menus.query.delete() Session.commit() menus = Menus.query.all() if len(menus) == 0: print('[SUCCESS]') else: print('[ERROR]') pprint([x.asdict() for x in menus])
def send_message(message): try: tid = message['tid'] name = message['cntc_name'] email = message['email_addr'] phone = message['phone'] message = message['message'] msg = Messages(tid, name, email, phone, message) Session.add(msg) Session.commit() except Exception as e: logger.critical(e) return -1 return msg.mid
def menu(tid): menus = defaultdict(dict) mid = Session.query(Menus.mid).filter(Menus.tid == tid, Menus.active == 1).first() categories = [ x[0] for x in Session.query(Menu_Items.category).filter( Menu_Items.mid == mid).distinct().all() ] for cat in categories: menus[cat] = [ x.asitem() for x in Menu_Items.query.filter( Menu_Items.mid == mid, Menu_Items.category == cat).all() ] return json.dumps(menus)
def reset_password(req): try: uid = req['id'] old_pw = req['old_pw'] new_pw = req['new_pw'] usr = Users.query.filter(Users.uid == uid).one_or_none() if usr and usr.validate_pswd(old_pw): usr.set_pswd(new_pw) Session.commit() else: return -2 except Exception as e: logger.critical(e) return -1 return usr.uid
def update_location(req): try: tid = req['tid'] lat = req['lat'] lng = req['lng'] opn = req['open'] truck = Truck_Locs.query.filter(Truck_Locs.tid == tid).one_or_none() if truck: truck.update_loc(lat, lng, opn) Session.commit() else: return -2 except Exception as e: logger.critical(e) return -1 return truck.tid
def build(): truck_ids = Session.query(Trucks.tid).all() if len(truck_ids) == 0: print('[ERROR] - There are no trucks.') sys.exit(1) messages = [] messages.append( Messages(truck_ids[0], 'terry backup', '*****@*****.**', '4205551234', 'plz back up')) messages.append( Messages(truck_ids[0], 'terrence backeth', '*****@*****.**', '4205551245', 'back up')) messages.append( Messages(truck_ids[0], 'lord quavious', '*****@*****.**', '4209051256', 'back up plz')) messages.append( Messages(truck_ids[1], 'latrell backemup', '*****@*****.**', '4208951267', 'plz back up tho')) messages.append( Messages(truck_ids[2], 'joe lawdterry', '*****@*****.**', '4207851278', 'srsly back up')) messages.append( Messages(truck_ids[2], 'dave ohlawd', '*****@*****.**', '4206751289', 'dood back up')) messages.append( Messages(truck_ids[3], 'mark baaackup', '*****@*****.**', '4205651290', 'back up 4reel')) messages.append( Messages(truck_ids[3], 'kyle wutizudoin', '*****@*****.**', '4204553434', 'not kid back up')) messages.append( Messages(truck_ids[4], 'kenneth fkitup', '*****@*****.**', '4203454534', 'lawd back up')) messages.append( Messages(truck_ids[5], 'jack terry', '*****@*****.**', '4202355634', 'back up wat iz u doin')) messages.append( Messages(truck_ids[6], 'karl lawd', '*****@*****.**', '4201256734', 'w-w-wat iz u doin terry')) Session.bulk_save_objects(messages) Session.commit() pprint([x.asdict() for x in Messages.query.all()])
def build(): truck_ids = Session.query(Trucks.tid).all() if len(truck_ids) == 0: print('[ERROR] - There are no trucks.') sys.exit(1) users = [] users.append( Users('rjames987', truck_ids[0], 'Rick', 'James', '*****@*****.**', '4025551234')) users.append( Users('tsmith123', truck_ids[1], 'Tom', 'Smith', '*****@*****.**', '4025552345')) users.append( Users('ajohnson', truck_ids[2], 'Alan', 'Johnson', '*****@*****.**', '4025553456')) users.append( Users('pdouglas', truck_ids[3], 'Peter', 'Douglas', '*****@*****.**', '4025554567')) users.append( Users('kwilmes345', truck_ids[4], 'Keith', 'Wilmes', '*****@*****.**', '4025555678')) users.append( Users('jcarter888', truck_ids[5], 'John', 'Carter', '*****@*****.**', '4025556789')) users.append( Users('arodgers', truck_ids[6], 'Alex', 'Rodgers', '*****@*****.**', '4025557890')) users.append( Users('bjeffereies0', truck_ids[7], 'Bill', 'Jefferies', '*****@*****.**', '4025551233')) users.append( Users('bmcelroy33', truck_ids[8], 'Bruce', 'McElroy', '*****@*****.**', '4025552344')) users.append( Users('alarson678', truck_ids[9], 'Adam', 'Larson', '*****@*****.**', '4025553455')) Session.bulk_save_objects(users) Session.commit() pprint([x.asdict() for x in Users.query.all()])
def build(): truck_ids = Session.query(Trucks.tid).all() if len(truck_ids) == 0: print('[ERROR] - There are no trucks.') sys.exit(1) menus = [] menus.append(Menus(truck_ids[0], 'activemenu.com', 1)) menus.append(Menus(truck_ids[0], 'inactivemenu.com', 0)) menus.append(Menus(truck_ids[1], 'realgoodfood.com', 1)) menus.append(Menus(truck_ids[2], 'fudtrucc.com', 1)) menus.append(Menus(truck_ids[3], 'snaccs.com', 1)) menus.append(Menus(truck_ids[4], 'hooraytesturlwebsite.com', 1)) menus.append(Menus(truck_ids[5], 'plsbuyfood.com', 1)) menus.append(Menus(truck_ids[6], 'fudtruccccccccccccc.com', 1)) menus.append(Menus(truck_ids[7], 'grassEatnSzn.com', 1)) menus.append(Menus(truck_ids[8], 'urlsnstuff.com', 1)) menus.append(Menus(truck_ids[9], 'backupterry.com', 1)) Session.bulk_save_objects(menus) Session.commit() pprint([x.asdict() for x in Menus.query.all()])
def build(): trucks = [] trucks.append(Trucks("For the Love of Food Truck", "*****@*****.**")) trucks.append(Trucks("Anthony Piccolo's Mobile Venue", "*****@*****.**")) trucks.append( Trucks("A Taste of New Orleans Food Truck", "*****@*****.**")) trucks.append(Trucks("The Dire Lion", "*****@*****.**")) trucks.append(Trucks("Dos De Oros", "*****@*****.**")) trucks.append(Trucks("KGB Gourmet Food Truck", "*****@*****.**")) trucks.append(Trucks("Maria Bonita Food Truck", "*****@*****.**")) trucks.append(Trucks("Mosaic Pickle", "*****@*****.**")) trucks.append(Trucks("Scotty's Go-Go Grill", "*****@*****.**")) trucks.append(Trucks("Lonchera El Milagro", "*****@*****.**")) Session.bulk_save_objects(trucks) Session.commit() trucks = Trucks.query.all() if len(trucks) == 0: print('[ERROR]') sys.exit(1) else: pprint([x.asdict() for x in trucks])
def build(): truck_ids = [x.tid for x in Trucks.query.all()] locs = [] locs.append(Truck_Locs(truck_ids[0], 41.257680, -95.934471, "Gene Lahey Mall", 0)) locs.append(Truck_Locs(truck_ids[1], 41.257906, -95.933205, "Gene Lahey Mall", 0)) locs.append(Truck_Locs(truck_ids[2], 41.258140, -95.934450, "Gene Lahey Mall", 0)) locs.append(Truck_Locs(truck_ids[3], 41.260269, -95.934536, "Gavilon", 0)) locs.append(Truck_Locs(truck_ids[4], 41.260164, -95.934525, "Gavilon", 0)) locs.append(Truck_Locs(truck_ids[5], 41.238597, -96.015325, "Aksarben Village", 0)) locs.append(Truck_Locs(truck_ids[6], 41.234072, -96.046850, "Canfield's - West Center", 0)) locs.append(Truck_Locs(truck_ids[7], 41.265259, -96.068353, "Westroads Mall", 0)) locs.append(Truck_Locs(truck_ids[8], 41.260010, -96.182198, "Village Pointe", 0)) locs.append(Truck_Locs(truck_ids[9], 41.258541, -95.960062, "Turner Park", 0)) Session.bulk_save_objects(locs) Session.commit() locs = Truck_Locs.query.all() if len(locs) == 0: print('[ERROR]') sys.exit(1) else: pprint([x.asdict() for x in locs])
def shutdown_session(exception=None): Session.remove()
def delete_message(mid): del_flag = Messages.query.filter(Messages.mid == mid).delete() Session.commit() return del_flag
def build(): menu_ids = Session.query(Menus.mid).filter(Menus.active == 1).all() if len(menu_ids) == 0: print('[ERROR] - There are no menus.') sys.exit(1) items = [] items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Black Forest Ham', 5, 'This ham sandwich is great. Like really great.', 3.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Turkey Breast', 5, 'This turkey sandwich is great. Like really great.', 4.99)) items.append( Menu_Items( menu_ids[0], 'Sandwiches', 'Cold Cut Combo', 5, 'This Cold Cut Combo sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Chicken & Bacon Ranch Melt', 5, 'This chicken sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Italian B.M.T.', 5, 'This italian sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Meatball Marinara', 5, 'This meatball sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Roast Beef', 5, 'This roast beef sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Steak & Cheese', 5, 'This steak sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Club', 5, 'This club sandwich is great. Like really great.', 4.99)) items.append( Menu_Items(menu_ids[0], 'Sandwiches', 'Classic Tuna', 5, 'This tuna sandwich is great. Like really great.', 4.99)) items.append( Menu_Items( menu_ids[2], 'Extra Value Combos', 'Hamburger', 15, '(1/4 lb.) Pickle, Onion, Ketchup, Mustard with Regular Fries & Regular Drink', 5.99)) items.append( Menu_Items( menu_ids[2], 'Extra Value Combos', 'Cheeseburger', 15, '(1/4 lb.) Pickle, Onion, Ketchup, Mustard with Regular Fries & Regular Drink', 6.49)) items.append( Menu_Items( menu_ids[2], 'Extra Value Combos', 'Double Dom', 10, '(1/2 lb.) Cheese, Lettuce, Tomato, Bacon, Mayo, with Regular Fries & Regular Drink', 7.99)) items.append( Menu_Items( menu_ids[2], 'Extra Value Combos', 'Double Cheeseburger', 10, '(1/2 lb.) Pickle, Onion, Ketchup, Mustard with Regular Fries & Regular Drink', 7.49)) items.append( Menu_Items(menu_ids[2], 'Extra Value Combos', 'Foot Long Chili Dog', 5, 'With Regular Fries & Regular Drink', 6.89)) items.append( Menu_Items(menu_ids[2], 'Specialty', 'Cheese Frenchee', 5, 'Batter Coated & Cheese Filled', 4.59)) items.append( Menu_Items(menu_ids[2], 'Specialty', 'Chicken Fingers', 5, '(Choice of Honey Mustard, BBQ or Ranch)', 4.99)) items.append( Menu_Items(menu_ids[2], 'Salad', 'Beef Taco Salad', 10, 'With spicy beef & beans.', 5.89)) items.append( Menu_Items(menu_ids[2], 'Baked Potatoes', 'Regular Baked Potato', 5, 'With sour cream, butter & green onions.', 2.29)) items.append( Menu_Items( menu_ids[2], 'Baked Potatoes', '"Loaded" Baked Potato', 5, 'Topped with sour cream, butter, cheddar cheese, bacon bits & green onions.', 2.99)) items.append( Menu_Items(menu_ids[4], 'Appetizers', 'Drummies', 40, '10 plump chicken drummies.', 10.75)) items.append( Menu_Items(menu_ids[4], 'Appetizers', 'Drummies From Hell', 30, 'dipped in hot sauce or on side', 10.75)) items.append( Menu_Items(menu_ids[4], 'Appetizers', 'Drummies From Heaven', 30, 'ranch dressing on side', 10.75)) items.append( Menu_Items(menu_ids[4], 'Appetizers', 'Drummies From West', 30, 'BBQ sauce on side', 10.75)) items.append( Menu_Items( menu_ids[4], 'Soup & Salad', 'Chicken Caesar Salad', 15, 'Grilled or crispy chicken served on a bed of lettuce with fresh shaved parmesan cheese, croutons, bacon bits and traditional Caesar dressing.', 7.95)) items.append( Menu_Items( menu_ids[4], 'Soup & Salad', 'Beef Taco Salad', 15, 'Ruthie\'s favorite salad. Bed of lettuce layered with seasoned ground beef, cheddar cheese, tomatoes, onions, taco Doritos and special dressing.', 8.25)) items.append( Menu_Items( menu_ids[4], 'Soup & Salad', 'Buffalo Chicken Salad', 15, 'Crisp lettuce with cabbage, carrots, tomatoes, bacon bits, cheddar cheese, & choice of grilled or crispy chicken tossed in Barrett\'s buffalo sauce.', 7.75)) items.append( Menu_Items( menu_ids[4], 'Specialties', 'Our Famous Pork Tenderloin', 100, 'This little piggy went to market..but the piggy only goes once a week. First come, first served! A hefty pork tenderloin lightly breaded and served with the works: cheese, mayo, lettuce, tomato, pickles and onions on a sesame seed bun.', 10.25)) items.append( Menu_Items( menu_ids[4], 'Specialties', 'The Blarneystone', 25, 'This pub favorite isn\'t full of Blarney- it\'s full of diced turkey breast mixed w/ cream cheese, sweet red onions and Swiss cheese, grilled marble bread.', 8.25)) items.append( Menu_Items( menu_ids[4], 'Specialties', 'Reuben', 25, 'Corned beef, Swiss cheese, sauerkraut, 1000 island dressing, grilled on marble bread - a favorite in the town it was created. For a healthier choice, ask for a Turkey Reuben!', 8.50)) items.append( Menu_Items(menu_ids[1], "Sandwiches", "Pork Banh Mi", 7, "French loaf and things and meat", 7.99)) items.append( Menu_Items(menu_ids[1], "Sandwiches", "Billy Club", 10, "Roast Beef, Smoked Ham, Grey Poupon, Lettuce, Tomato", 6.99)) items.append( Menu_Items( menu_ids[1], "Sandwiches", "Italian Night Club", 20, "Genoa salami, capicola, ham, provolone, lettuce, tomato, onions, mayo & vinaigrette", 6.99)) items.append( Menu_Items(menu_ids[1], "Sandwiches", "Hunters Club", 69, "Double roast beef, provolone, lettuce, tomato & mayo", 3.99)) items.append( Menu_Items(menu_ids[1], "Sandwiches", "Country Club", 234, "Turkey breast, ham, provolone, lettuce, tomato & mayo.", 9.04)) items.append( Menu_Items( menu_ids[1], "Sandwiches", "Beach Club", 40, "Turkey breast, avocado spread, cucumber, cheese, lettuce, tomato & mayo.", 39.32)) items.append( Menu_Items(menu_ids[1], "Sandwiches", "Bootlegger Club", 34, "Roast beef, turkey breast, lettuce, tomato & mayo.", 0.99)) items.append( Menu_Items(menu_ids[1], "Omelettes", "Bacon Omelette", 2, "Eggs, bacon, cheese, flavuh-flaaaav", 8.99)) items.append( Menu_Items(menu_ids[1], "Omelettes", "Denver Omelette", 3, "Stuffed with pepper, ham, onions, American cheese", 10.50)) items.append( Menu_Items(menu_ids[1], "Omelettes", "Philly Omelette", 4, "Omelette delivered fresh from WaWa", 19.30)) items.append( Menu_Items( menu_ids[3], "Burgers", "Original", 2398502, "Add your choice of Cheddar, Pepperjack, Swiss, American, Habanero Jack or Gouda", 49.29)) items.append( Menu_Items(menu_ids[3], "Burgers", "Three Cheese Burger", 30, "buns/beef/battlestar 3 cheeses", 22.98)) items.append( Menu_Items( menu_ids[3], "Burgers", "Guac On the Moon", 69, "Topped with a generous portion of fresh house-made guacamole, pico de gallo and queso fresco.", 02.93)) items.append( Menu_Items( menu_ids[3], "Burgers", "Elvis Burger", 420, "Topped with creamy peanut butter, 2 slices of bacon and American cheese.", 69.69)) items.append( Menu_Items(menu_ids[3], "Hooch", "Natty Rush", 35, "It's like diet 4loko", 2.99)) items.append( Menu_Items(menu_ids[3], "Beer", "Busch Latte", 20, "for when u love NASCAR", 18.78)) items.append( Menu_Items(menu_ids[3], "Beer", "Bud Diesel", 40, "Actual gasoline, but flavored like America", 17.87)) items.append( Menu_Items(menu_ids[3], "Beer", "PBRRRRRRRR", 203, "Sponsored by yelawolf and hippies", 3.20)) items.append( Menu_Items(menu_ids[3], "Beer", "Kirkland Light", 40, "Generic beer == Beer still", 18.98)) items.append( Menu_Items(menu_ids[3], "Beer", "Michelob Ultra", 28, "sports beer, basically gatorade", 430.20)) items.append( Menu_Items(menu_ids[5], "Beer", "Ranch Punch", 9, "buttermilk ranch on the roccs", 2.00)) items.append( Menu_Items(menu_ids[5], "Beer", "Colt 45", 45, "comes with plastic bag homeless man coozie!", 3.00)) items.append( Menu_Items(menu_ids[5], "Beer", "Montucky Cold Snacks", 890, "all profits donated to charity", 3.50)) items.append( Menu_Items(menu_ids[5], "Beer", "Guinness", 433, "made with McGregor's actual sweat (yum!)(mate)", 2091.30)) items.append( Menu_Items( menu_ids[5], "Hooch", "MD 20|20", 20, "It's like juice but has like 12% abv and will give you mad tooth decay", 4.56)) items.append( Menu_Items(menu_ids[5], "Hooch", "Dirty Sprite", 17, "Houston Export sTrAiGhT uP!", 29.20)) items.append( Menu_Items( menu_ids[5], "Hooch", "Barton's", 1, "Triple Carbon Filtered. Shatterproof bottle, served with a side of gatorade", 10.68)) items.append( Menu_Items(menu_ids[5], "Hooch", "Snorkel", 23, "redbull vodka that you get to shotgun", 4.55)) items.append( Menu_Items(menu_ids[5], "Hooch", "Disgusting Gold Tequila", 230, "Probably contact your uber before ordering", 20.39)) items.append( Menu_Items(menu_ids[5], "Beer", "Heinekin Mini Keg", 227, "What am I, Diplo?", 39.39)) items.append( Menu_Items(menu_ids[7], "Wings", "Buffalo", 30, "Spicy/good", 12.39)) items.append( Menu_Items(menu_ids[7], "Wings", "Lemon Pepper", 35, "Wet. Dozen flats.", 13.49)) items.append(Menu_Items(menu_ids[7], "Wings", "BBQ", 10, "for wimps", 8.90)) items.append( Menu_Items(menu_ids[7], "Wings", "Carribean Jerk", 58, "sponsored by Disney Cruises", 10.34)) items.append( Menu_Items(menu_ids[7], "Wings", "Super Inferno Death Sauce", 39, "please sign a waiver", 9.92)) items.append( Menu_Items(menu_ids[7], "Wings", "Chipotle", 20, "smokey and delicious", 18.99)) items.append( Menu_Items( menu_ids[7], "Wraps", "JCole Jalapeno Cheddar", 29, "probably went double platnum with no features (no sides allowed to be orderd with this)", 8.39)) items.append( Menu_Items(menu_ids[7], "Wraps", "Drake Dijon Mustard Chicken", 10, "i OnLy LoVe My MoM aNd ChIcKeN iM sOrRy", 4.56)) Session.bulk_save_objects(items) Session.commit() pprint([x.asdict() for x in Menu_Items.query.all()])