Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
def delete_announcement(id):
    Announcement.delete(id)
Пример #5
0
def get_announcements_admin():
    announcements = Announcement.get_all()
    announcements_dict = [
        announcement.to_dict_admin() for announcement in announcements
    ]
    return announcements_dict
Пример #6
0
def get_announcements():
    return Announcement.get_all()