summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-12 12:26:38 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-12 12:26:38 +0200
commitb199c46d6c26f8918d0de5589031b575c9521016 (patch)
tree79c1007d33e7a54c62e6408ecc2768ad5bcda8d9
parent9e4d5ae38fe310ea4748b7b3e94b8967b995269e (diff)
downloadChimère-b199c46d6c26f8918d0de5589031b575c9521016.tar.bz2
Chimère-b199c46d6c26f8918d0de5589031b575c9521016.zip
Bootstrap templatetag for modal
-rw-r--r--chimere/templates/blocks/bootstrap-modal.html14
-rw-r--r--chimere/templatetags/bootstrap.py17
2 files changed, 25 insertions, 6 deletions
diff --git a/chimere/templates/blocks/bootstrap-modal.html b/chimere/templates/blocks/bootstrap-modal.html
index d476d5b..e800ec9 100644
--- a/chimere/templates/blocks/bootstrap-modal.html
+++ b/chimere/templates/blocks/bootstrap-modal.html
@@ -1,14 +1,22 @@
-<div class="modal fade" id="{{id}}" tabindex="-1" role="dialog"
+{% load i18n %}<div class="modal fade" id="{{id}}" tabindex="-1" role="dialog"
aria-labelledby="{{id}}-label" aria-hidden="true">
- <div class="modal-dialog{% ifequal size 'large'%} modal-lg{% endifequal %}">
+ <div role="document" class="modal-dialog{% ifequal size 'small'%} modal-sm{% endifequal %}{% ifequal size 'large'%} modal-lg{% endifequal %}">
<div class="modal-content">
<div class="modal-header">
+ {% if title %}<h5 class="modal-title" id="{{id}}-label"> {{title}}</h5>{% endif %}
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- {% if title %}<h4 class="modal-title" id="{{id}}-label">{{title}}</h4>{% endif %}
</div>
<div class="modal-body">
{{content}}
</div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">
+ {% trans "Close" %}
+ </button>
+ {% if edit %}<button type="button" class="btn btn-primary">
+ {% trans "Edit" %}
+ </button>{% endif %}
+ </div>
</div>
</div>
</div>
diff --git a/chimere/templatetags/bootstrap.py b/chimere/templatetags/bootstrap.py
index ea1cb6d..1960355 100644
--- a/chimere/templatetags/bootstrap.py
+++ b/chimere/templatetags/bootstrap.py
@@ -4,20 +4,31 @@
from logging import getLogger
from django import template
+from django.utils.translation import ugettext
log = getLogger(__name__)
register = template.Library()
+@register.filter(name='translate')
+def translate(text):
+ try:
+ return ugettext(text)
+ except:
+ return ""
+
+
+
@register.inclusion_tag('blocks/bootstrap-modal.html')
-def bootstrap_modal(context, winid, title="", content="", size=""):
- if size not in ['large']:
+def bootstrap_modal(winid, title="", content="", size="", edit=False):
+ if size not in ['large', 'small']:
size = ""
context_data = {
"id": winid,
"title": title,
"content": content,
- "size": size
+ "size": size,
+ "edit": edit
}
return context_data