def set_watch(entity, set_watch=True): """ Make sure that the current user watches entity, if set_watch is True. Make sure that the current user doesn't watch entity, if set_watch is False. """ has_watch = Watch.find_by_entity(c.user, entity) if set_watch and has_watch is None: Watch.create(c.user, entity) meta.Session.commit() elif not set_watch and has_watch is not None: has_watch.delete() meta.Session.commit()
def set_watch(entity, set_watch=True): """ Make sure that the current user watches entity, if set_watch is True. Make sure that the current user doesn't watch entity, if set_watch is False. """ has_watch = Watch.find_by_entity(c.user, entity) if set_watch and has_watch is None: Watch.create(c.user, entity) meta.Session.commit() elif not set_watch and has_watch is not None: has_watch.delete() meta.Session.commit()
def find_watch(entity): return Watch.find_by_entity(c.user, entity)
def find_watch(entity): return Watch.find_by_entity(c.user, entity)