Пример #1
0
def render_flash_messages_from_queues(request):
    """This method is for compatibility with other systems only.
    Some developers are using queues named after bootstrap message flavours.
    I think my system (using only the default queue '') is better,
    because FlashMessage already supports a ``kind`` attribute,
    but this function provides a way to display their flash messages, too.

    You can set QUEUES to something else if you like, from user code.
    """
    msgs = []
    for q in QUEUES:
        for m in request.session.pop_flash(q):
            html = m.bootstrap_alert if isinstance(m, FlashMessage) \
                else bootstrap_alert(m, q)
            msgs.append(html)
    return ''.join(msgs)
Пример #2
0
def render_flash_messages(request) -> str:
    msgs = request.session.pop_flash()  # Pops from the '' queue
    return ''.join((
        bootstrap_alert(m) if isinstance(m, str)
        else m.bootstrap_alert for m in msgs))