Skip to content

Commit

Permalink
chore: add message to base template
Browse files Browse the repository at this point in the history
  • Loading branch information
djs0109 committed Sep 6, 2022
1 parent 72cccfd commit 9fbe60d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/Entirety/entirety/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
TemplateBackendModel,
)
from utils.generators import generate_secret_key

from django.contrib.messages import constants as messages
__version__ = "0.3.1"


Expand Down Expand Up @@ -78,6 +78,14 @@ class Settings(PydanticSettings):
"mozilla_django_oidc.middleware.SessionRefresh",
]

MESSAGE_TAGS = {
messages.DEBUG: 'alert-info',
messages.INFO: 'alert-info',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}

ROOT_URLCONF = "entirety.urls"
FORM_RENDERER = "django.forms.renderers.TemplatesSetting"
TEMPLATES: List[TemplateBackendModel] = [
Expand Down
1 change: 1 addition & 0 deletions app/Entirety/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<div class="container-fluid ps-0 d-flex">
{% include 'sidebar.html' %}
<main class="d-flex flex-column flex-fill ps-4 pe-3 py-3">
{% include 'messages.html' %}
{% block content %}(no content - should not be here) {% endblock %}
</main>
{% include 'modal.html' %}
Expand Down
9 changes: 9 additions & 0 deletions app/Entirety/templates/messages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if messages %}
<ul class="messages">
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible" role="alert">
{{ message }}
</div>
{% endfor %}
</ul>
{% endif %}

0 comments on commit 9fbe60d

Please sign in to comment.