Verified Commit 15d796f6 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Make alert a templatetag

parent 921cc850
......@@ -9,6 +9,14 @@ thaliawebsite.templatetags package
Submodules
----------
thaliawebsite.templatetags.alert module
---------------------------------------
.. automodule:: thaliawebsite.templatetags.alert
:members:
:undoc-members:
:show-inheritance:
thaliawebsite.templatetags.baseurl module
-----------------------------------------
......
{% extends "base.html" %}
{% load i18n thumbnail static activemembers_cards %}
{% load i18n thumbnail static activemembers_cards alert %}
{% block title %}{% trans 'committees'|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans 'committees'|capfirst %} — {{ block.super }}{% endblock %}
......@@ -16,9 +16,8 @@
{% membergroup_card committee %}
</div>
{% empty %}
<div class="alert alert-danger col-10 offset-1">
{% trans 'There are no committees!' %}
</div>
{% trans 'There are no committees!' as no_committees %}
{% alert 'danger' no_committees extra_classes='col-10 offset-1' %}
{% endfor %}
</div>
</div>
......
{% extends "base.html" %}
{% load i18n static thumbnail bleach_tags activemembers_cards %}
{% load i18n static thumbnail bleach_tags activemembers_cards alert %}
{% block body %}
<section id="activemembers-membergroup" class="page-section">
......@@ -31,11 +31,9 @@
<div class="col-4 col-md-3 my-3">
{% membergroup_member_card member %}
</div>
{% empty %}
<div class="alert alert-danger col-10 offset-1">
{% trans "This group doesn't have any members?" %}
</div>
{% trans "This group doesn't have any members?" as empty %}
{% alert 'danger' empty extra_classes='col-10 offset-1' %}
{% endfor %}
</div>
</div>
......
{% extends "base.html" %}
{% load i18n thumbnail static activemembers_cards %}
{% load i18n thumbnail static activemembers_cards alert %}
{% block title %}{% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans 'societies'|capfirst %} — {{ block.super }}{% endblock %}
......@@ -16,9 +16,8 @@
{% membergroup_card society %}
</div>
{% empty %}
<div class="alert alert-danger col-10 offset-1">
{% trans 'There are no societies!' %}
</div>
{% trans 'There are no societies!' as no_societies %}
{% alert 'danger' no_societies extra_classes='col-10 offset-1' %}
{% endfor %}
</div>
</div>
......
{% extends 'education/base.html' %}
{% load i18n fieldtype bootstrap4 %}
{% load i18n fieldtype bootstrap4 alert %}
{% block title %}{% trans "Submit Exam" %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans "Submit Exam" %} —
......@@ -13,13 +13,8 @@
</h1>
{% if saved %}
<div class="alert alert-success alert-dismissible">
{% trans "Exam submitted successfully." %}
<button type="button" class="close" data-dismiss="alert"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans "Exam submitted successfully." as success_text %}
{% alert 'success' success_text dismissable=True %}
{% endif %}
<form method="post" enctype="multipart/form-data"
......
{% extends 'education/base.html' %}
{% load i18n fieldtype bootstrap4 %}
{% load i18n fieldtype bootstrap4 alert %}
{% block title %}{% trans "Submit Summary" %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans "Submit Summary" %} —
......@@ -13,13 +13,8 @@
</h1>
{% if saved %}
<div class="alert alert-success alert-dismissible">
{% trans "Summary submitted successfully." %}
<button type="button" class="close" data-dismiss="alert"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans "Summary submitted successfully." as success_text %}
{% alert 'success' success_text dismissable=True %}
{% endif %}
<form method="post" enctype="multipart/form-data"
......
{% extends "base.html" %}
{% load i18n static bleach_tags thumbnail member_card google_map_url grid_item %}
{% load i18n static bleach_tags thumbnail member_card google_map_url grid_item alert %}
{% block title %}{{ event.title }} — {% trans "Calendar"|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{{ event.title }} — {% trans "Calendar"|capfirst %} — {{ block.super }}{% endblock %}
......@@ -15,12 +15,7 @@
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissable">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% alert message.tags message dismissable=True %}
{% endfor %}
{% endif %}
......
{% extends "base.html" %}
{% load i18n static bootstrap4 %}
{% load i18n static bootstrap4 alert %}
{% block title %}{% trans "Registration" %} — {{ event.title }} — {% trans "Calendar" %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans "Registration" %} — {{ event.title }} — {% trans "Calendar" %} — {{ block.super }}{% endblock %}
......@@ -10,12 +10,7 @@
<h1 class="text-center section-title">{% blocktrans with title=event.title %}Registration for {{ title }}{% endblocktrans %}</h1>
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissable">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% alert message.tags message dismissable=True %}
{% endfor %}
{% endif %}
......
{% extends "base.html" %}
{% load static i18n fieldtype bootstrap4 %}
{% load static i18n fieldtype bootstrap4 alert %}
{% block title %}{% trans "edit profile"|capfirst %} — {% trans "members"|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans "edit profile"|capfirst %} — {% trans "members"|capfirst %} —
......@@ -12,21 +11,13 @@
<h1 class="text-center section-title">{% trans "edit profile"|capfirst %}</h1>
{% if saved %}
<div class="alert alert-success alert-dismissable">
{% trans "Your profile has been updated successfully." %}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans "Your profile has been updated successfully." as success_text %}
{% alert 'success' success_text dismissable=True %}
{% endif %}
{% if form.errors %}
<div class="alert alert-danger alert-dismissable">
{% trans "Please check your profile for errors." %}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans "Please check your profile for errors." as error_text %}
{% alert 'danger' error_text dismissable=True %}
{% endif %}
<form method="post" enctype="multipart/form-data" class="col-lg-8 offset-lg-2">
......
{% extends "base.html" %}
{% load static i18n thumbnail bootstrap4 member_card %}
{% load static i18n thumbnail bootstrap4 member_card alert %}
{% block title %}{% trans "members"|capfirst %} — {{ block.super }}{% endblock %}
{% block opengraph_title %}{% trans "members"|capfirst %} — {{ block.super }}{% endblock %}
......@@ -63,12 +63,8 @@
</ul>
{% if not members %}
<div class="alert alert-info alert-dismissable mt-4">
{% trans "No members found" %}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans 'No members found' as info_text %}
{% alert 'info' info_text dismissable=True %}
{% else %}
<div class="row mt-4">
{% for member in members %}
......
{% extends "base.html" %}
{% load i18n static %}
{% load i18n static alert %}
{% block title %}{% if event %}{{ event.title }}
— {% endif %}{% trans "pizzas"|capfirst %} —
......@@ -91,13 +91,11 @@
{% endif %}
{% if order %}
{% if order.paid %}
<div class="alert alert-success mt-3">
{% trans "The order has been paid for." %}
</div>
{% trans "The order has been paid for." as success_text %}
{% alert 'success' success_text extra_classes="mt-3" %}
{% else %}
<div class="alert alert-danger mt-3">
{% trans "The order has not yet been paid for." %}
</div>
{% trans "The order has not yet been paid for." as danger_text %}
{% alert 'danger' danger_text extra_classes="mt-3" %}
{% endif %}
<h4 class="text-center">{% trans "Current order" %}</h4>
<div class="table-responsive mt-3">
......
{% extends "base.html" %}
{% load i18n bootstrap4 %}
{% load i18n bootstrap4 alert %}
{% block title %}{% trans "renewal"|capfirst %} —
{{ block.super }}{% endblock %}
......@@ -130,11 +130,7 @@
{% else %}
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-error">
{{ message }}
<button type="button" class="close"><span
class="alert-icon-close"></span></button>
</div>
{% alert 'danger' message dismissable=True %}
{% endfor %}
{% endfor %}
<form method="post" enctype="multipart/form-data"
......
{% extends "base.html" %}
{% load i18n %}
{% load i18n alert %}
{% comment %}This page is automatically used by django.contrib.auth.views{% endcomment %}
......@@ -26,12 +26,8 @@
{% endif %}
{% if form.errors %}
<div class="alert alert-danger alert-dismissible">
{% trans "Invalid username or password." %}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% trans "Invalid username or password." as error_text %}
{% alert 'danger' error_text dismissable=True %}
{% endif %}
<form method="post" action="{% url 'login' %}" class="col-lg-6 offset-lg-3">
......
{% extends "base.html" %}
{% load i18n %}
{% load i18n alert %}
{% comment %}This page is automatically used by django.contrib.auth.views{% endcomment %}
......@@ -13,12 +13,7 @@
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-danger alert-dismissable">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% alert 'danger' message dismissable=True %}
{% endfor %}
{% endfor %}
......
{% extends "base.html" %}
{% load i18n %}
{% load i18n alert %}
{% comment %}This page is automatically used by django.contrib.auth.views{% endcomment %}
......@@ -15,12 +15,7 @@
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-error alert-dismissable">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% alert 'error' message dismissable=True %}
{% endfor %}
{% endfor %}
......
{% extends "base.html" %}
{% load i18n %}
{% load i18n alert %}
{% comment %}This page is automatically used by django.contrib.auth.views{% endcomment %}
......@@ -13,12 +13,7 @@
{% for error in form.errors.items %}
{% for message in error.1 %}
<div class="alert alert-danger alert-dismissible">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% alert 'danger' message dismissable=True %}
{% endfor %}
{% endfor %}
......
<div class="alert alert-{{ type }} {{ extra_classes }}">
{{ message }}
{% if dismissable %}
<button type="button" class="close" data-dismiss="alert"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{% endif %}
</div>
from django import template
register = template.Library()
@register.inclusion_tag('includes/alert.html')
def alert(type='info', message=None, dismissable=False, extra_classes=''):
if dismissable:
extra_classes += ' alert-dimissable'
return {
'type': type,
'message': message,
'dismissable': dismissable,
'extra_classes': extra_classes,
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment