def loadEntries(bot): Entries.entries = [] if hasattr(bot, "_id"): categories = Database.find(Database.COLLECTIONS.CATEGORY, {"bot": bot._id}) for data in categories: c = Category(bot, data) Entries.entries.append(c) if (len(Entries.entries) > 0): Entries.currentEntry = Entries.entries[0] else: Entries.currentEntry = Entries.newEntry(bot) Entries._notify(Entries.UPDATE.ALL)
def loadBots(): bots = Database.find(Database.COLLECTIONS.BOT, {}) Bots.__bots__ = [] for document in bots: bot = Bot(document["name"]) bot.load(document) Bots.__bots__.append(bot) if not any(bot.name == Bots.GENERAL_NAME_TAG for bot in Bots.__bots__): bot = Bot(Bots.GENERAL_NAME_TAG) bot.save() Bots.__bots__.insert(0, bot) Bots._notify()
def loadEmotions(): emotions = Database.find(Database.COLLECTIONS.EMOTION, {}) __emotions__ = [] for document in emotions: __emotions__.append(document["name"])
def load(): domains = Database.find(Database.COLLECTIONS.DOMAIN, {}) Domains.__domains__ = [] for document in domains : Domains.__domains__ .append(document["name"]) Domains._notify()
def find_by_controller_id(cls, controller_id): hospitals = Database.find(collection='blogs', query={'controller_id': controller_id}) return [cls(**hospital) for hospital in hospitals]
def from_hospital(id): return [ patient for patient in Database.find(collection='posts', query={'hospital_id': id}) ]