Holger Frey
7 years ago
5 changed files with 33 additions and 10 deletions
@ -0,0 +1,14 @@ |
|||||||
|
{% macro flash_messages() -%} |
||||||
|
{% for queue in ('success', 'info', 'warning', 'error') %} |
||||||
|
{% for message in request.session.pop_flash(queue) %} |
||||||
|
{% set css_class = 'danger' if queue == 'error' else queue %} |
||||||
|
<div class="alert alert-{{ css_class }} alert-dismissible" role="alert"> |
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> |
||||||
|
<strong>{{message.message|safe}}</strong> |
||||||
|
{% if message.description %} |
||||||
|
<br>{{message.description|safe}} |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
{% endfor %} |
||||||
|
{% endfor %} |
||||||
|
{%- endmacro %} |
@ -1,8 +0,0 @@ |
|||||||
{% extends "ordr2:templates/layout.jinja2" %} |
|
||||||
|
|
||||||
{% block content %} |
|
||||||
<div class="content"> |
|
||||||
<h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy project</span></h1> |
|
||||||
<p class="lead">Welcome to <span class="font-normal">Ordr2</span>, a Pyramid application generated by<br><span class="font-normal">Cookiecutter</span>.</p> |
|
||||||
</div> |
|
||||||
{% endblock content %} |
|
@ -1 +1,16 @@ |
|||||||
# package |
from collections import namedtuple |
||||||
|
|
||||||
|
|
||||||
|
FlashMessage = namedtuple('FlashMessage', 'message description') |
||||||
|
|
||||||
|
|
||||||
|
def flash(request, channel, message, description=''): |
||||||
|
''' small wrapper around request.session.flash ''' |
||||||
|
msg = FlashMessage(message=message, description=description) |
||||||
|
request.session.flash(msg, channel, allow_duplicate=False) |
||||||
|
|
||||||
|
|
||||||
|
def includeme(config): |
||||||
|
''' adding a request helper for views ''' |
||||||
|
config.add_request_method(flash, 'flash') |
||||||
|
|
||||||
|
Reference in new issue