def add_owner(username, owner): if username is not None: if Owners.get_owner(username, owner.shop_name) is not False: if RegisteredUsers.get_user(owner.username) is not False: if Owners.get_owner(owner.username, owner.shop_name) is not False: to_return = 'FAILED! ' + owner.username + ' is already an owner' return to_return result = Owners.add_owner(owner) if result: result = HistoryAppointings.add_history_appointing( username, owner.username, 'Owner', owner.shop_name, strftime("%d-%m-%Y %H:%M:%S", gmtime()), 'Owner') else: return "FAILED" if result and is_manager_of_shop(owner.username, owner.shop_name): result = remove_store_manager(username, owner.shop_name, owner.username) if result: return "SUCCESS" else: return "FAILED" elif result: return "SUCCESS" else: return "FAILED" else: return "FAILED: Username does not exists" else: return "FAILED: You are not the owner of this shop" else: return "FAILED: Missing Parameters"
def create_shop(shop, username): if shop is not None and username is not None: if Shops.search_shop(shop.name) is False: if Shops.create_shop(shop): if Owners.add_owner(Owner(username, shop.name, None)): LoggerLogic.add_event_log(username, "OPEN SHOP") return "SUCCESS" return "FAILED: Adding Owner" return "FAILED: Adding Shop" return "FAILED: Shop name is taken" return "FAILED: Missing parameters"