summaryrefslogtreecommitdiffstats
path: root/bitvend/templates/_helpers.html
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-04-07 17:34:09 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-04-07 17:34:09 +0200
commit23370b41d9abd22ba82028f2b3a3832593e71acd (patch)
treeda2c9f646f0c93fc552d409b614d7b20b7b5f483 /bitvend/templates/_helpers.html
parent30b8bfbadae4dde9e3f6101ecc74dabe335c19d5 (diff)
downloadbitvend-23370b41d9abd22ba82028f2b3a3832593e71acd.tar.gz
bitvend-23370b41d9abd22ba82028f2b3a3832593e71acd.tar.bz2
bitvend-23370b41d9abd22ba82028f2b3a3832593e71acd.tar.xz
bitvend-23370b41d9abd22ba82028f2b3a3832593e71acd.zip
Templates cleanup, pagination, transactions list, hallofshame
Diffstat (limited to 'bitvend/templates/_helpers.html')
-rw-r--r--bitvend/templates/_helpers.html99
1 files changed, 99 insertions, 0 deletions
diff --git a/bitvend/templates/_helpers.html b/bitvend/templates/_helpers.html
new file mode 100644
index 0000000..d0f7bcb
--- /dev/null
+++ b/bitvend/templates/_helpers.html
@@ -0,0 +1,99 @@
+{% macro format_currency(amount, color=True, precision=2) -%}
+{%- if amount == None -%}
+None
+{%- else -%}
+<span class="amount{% if amount < 0 and color %} amount-negative{% endif %}" data-original="{{ amount }}">
+ {{ format_currency_raw(amount, precision) }}
+</span>
+{%- endif %}
+{%- endmacro %}
+
+{% macro format_currency_raw(amount, precision=0) -%}
+{{ ("%%.%sf" | format(precision) | format(amount/100)) }}SOG
+{%- endmacro %}
+{% macro render_field(field, prefix=None, suffix=None, layout=True, label=True) %}
+ {% if field.type == 'HiddenField' %}
+ {{ field(**kwargs) }}
+ {% else %}
+ {% if layout %}
+ <div class="form-group{% if field.errors %} has-error{% endif %}">
+ {% if field.type == 'BooleanField' %}
+ <div class="col-xs-3"></div>
+ {% elif label %}
+ {{ field.label(class_='col-xs-3 control-label') }}
+ {% endif %}
+ <div class="col-xs-9">
+ {% endif %}
+
+ {{ render_field_inner(field, prefix, suffix, label=label, **kwargs) }}
+
+ {% if layout %}
+ </div>
+ </div>
+ {% endif %}
+ {% endif %}
+{% endmacro %}
+
+{% macro render_field_inner(field, prefix=None, suffix=None, label=True, input_group_class='') %}
+ {% if field.type == 'BooleanField' %}<div class="checkbox"><label for="{{ field.id }}">{% endif %}
+ {% if prefix or suffix %}<div class="input-group {{ input_group_class }}">{% endif %}
+ {% if prefix %}<span class="input-group-addon">{{ prefix }}</span>{% endif %}
+ {% if field.type == 'BooleanField' %}
+ {{ field(**kwargs) }} {% if label %}{{ field.label.text }}{% endif %}
+ {% elif field.type == 'RadioField' %}
+ {{ field(**kwargs) }}
+ {% else %}
+ {{ field(class_='form-control '+kwargs.pop('class_', ''), **kwargs) }}
+ {% endif %}
+ {% if suffix %}<span class="input-group-addon">{{ suffix }}</span>{% endif %}
+ {% if prefix or suffix %}</div>{% endif %}
+ {% if field.description and label %}
+ <span class="help-block">{{ field.description }}</span>
+ {% endif %}
+ {% if field.errors %}
+ {% for error in field.errors %}
+ <span class="help-block">{{ error }}</span>
+ {% endfor %}
+ {% endif %}
+ {% if field.type == 'BooleanField' %}</label></div>{% endif %}
+{% endmacro %}
+
+{% macro render_submit(label='Submit', class_='btn btn-primary', layout=True) %}
+{% if layout %}
+<div class="form-group">
+ <div class="col-xs-9 col-xs-offset-3">
+{% endif %}
+ <button type="submit" class="{{ class_ }}">{{ label }}</button>
+{% if layout %}
+ </div>
+</div>
+{% endif %}
+{% endmacro %}
+
+{% macro render_pagination(pagination) %}
+ <ul class="pagination text-center">
+ {% if pagination.has_prev %}
+ <li><a href="{{ url_for_other_page(pagination.page - 1) }}">&laquo;</a></li>
+ {% else %}
+ <li class="disabled"><a>&laquo;</a></li>
+ {% endif %}
+
+ {%- for page in pagination.iter_pages() %}
+ {% if page %}
+ {% if page != pagination.page %}
+ <li><a href="{{ url_for_other_page(page) }}">{{ page }}</a></li>
+ {% else %}
+ <li class="active"><a href="{{ url_for_other_page(page) }}">{{ page }}</a></li>
+ {% endif %}
+ {% else %}
+ <li class="disabled"><a>…</a></li>
+ {% endif %}
+ {%- endfor %}
+
+ {% if pagination.has_next %}
+ <li><a href="{{ url_for_other_page(pagination.page + 1) }}">&raquo;</a></li>
+ {% else %}
+ <li class="disabled"><a>&raquo;</a></li>
+ {% endif %}
+ </ul>
+{% endmacro %}