def update_announcement(id, **kwargs): with DBSession() as session: announcement = Announcement.update( id=id, fields={**kwargs, "uid": current_user.id,}, field_names=["uid", "message", "url_regex", "can_dismiss"], session=session, ) announcement_dict = announcement.to_dict_admin() return announcement_dict
def create_announcement(message, url_regex="", can_dismiss=True): with DBSession() as session: announcement = Announcement.create( { "uid": current_user.id, "url_regex": url_regex, "can_dismiss": can_dismiss, "message": message, }, session=session, ) announcement_dict = announcement.to_dict_admin() return announcement_dict
def create_announcement( message, url_regex="", can_dismiss=True, active_from=None, active_till=None, ): with DBSession() as session: announcement = Announcement.create( { "uid": current_user.id, "url_regex": url_regex, "can_dismiss": can_dismiss, "message": message, "active_from": active_from, "active_till": active_till, }, session=session, ) announcement_dict = announcement.to_dict_admin() return announcement_dict
def delete_announcement(id): Announcement.delete(id)
def get_announcements_admin(): announcements = Announcement.get_all() announcements_dict = [ announcement.to_dict_admin() for announcement in announcements ] return announcements_dict
def get_announcements(): return Announcement.get_all()