From f27987070e40fcf4b017f91c23c4747373e85c9d Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 15 Apr 2019 14:56:50 +0100 Subject: Images sidebar work, and allow fields to be rendered without labels --- pydis_site/apps/home/templatetags/wiki_extra.py | 4 +- .../templates/wiki/forms/fields/boolean.html | 29 ++++--- pydis_site/templates/wiki/forms/fields/char.html | 2 +- pydis_site/templates/wiki/forms/fields/image.html | 26 ++++--- .../wiki/forms/fields/in_place_render.html | 26 ++++--- .../templates/wiki/forms/fields/model_choice.html | 26 ++++--- .../wiki/forms/fields/wiki_slug_render.html | 26 ++++--- pydis_site/templates/wiki/includes/formfield.html | 2 +- .../templates/wiki/plugins/images/sidebar.html | 88 ++++++++-------------- .../wiki/plugins/macros/article_list.html | 14 ---- .../templates/wiki/plugins/macros/sidebar.html | 20 ----- 11 files changed, 111 insertions(+), 152 deletions(-) delete mode 100644 pydis_site/templates/wiki/plugins/macros/article_list.html delete mode 100644 pydis_site/templates/wiki/plugins/macros/sidebar.html diff --git a/pydis_site/apps/home/templatetags/wiki_extra.py b/pydis_site/apps/home/templatetags/wiki_extra.py index ae168ae3..d4e9b266 100644 --- a/pydis_site/apps/home/templatetags/wiki_extra.py +++ b/pydis_site/apps/home/templatetags/wiki_extra.py @@ -62,7 +62,7 @@ def get_unbound_field(field: BoundField): @register.simple_tag -def render_field(field: Field): +def render_field(field: Field, render_labels: bool = True): if isinstance(field, BoundField): unbound_field = get_unbound_field(field) else: @@ -75,7 +75,7 @@ def render_field(field: Field): raise NotImplementedError(f"Unknown field type: {unbound_field.__class__}") template_obj: Template = get_template(template_path) - context = {"field": field, "is_markitup": is_markitup} + context = {"field": field, "is_markitup": is_markitup, "render_labels": render_labels} return mark_safe(template_obj.render(context)) diff --git a/pydis_site/templates/wiki/forms/fields/boolean.html b/pydis_site/templates/wiki/forms/fields/boolean.html index 9d054083..9a8470be 100644 --- a/pydis_site/templates/wiki/forms/fields/boolean.html +++ b/pydis_site/templates/wiki/forms/fields/boolean.html @@ -1,15 +1,17 @@
-
- + {% if render_labels %} +
+ - {% if field.help_text %} -

- {{ field.help_text|safe }} -

- {% endif %} -
+ {% if field.help_text %} +

+ {{ field.help_text|safe }} +

+ {% endif %} +
+ {% endif %}
@@ -25,8 +27,13 @@ {% if field.min_length %}minlength="{{ field.min_length }}"{% endif %} {% if field.empty_value %}placeholder="{{ field.empty_value }}"{% endif %} /> +
diff --git a/pydis_site/templates/wiki/forms/fields/char.html b/pydis_site/templates/wiki/forms/fields/char.html index 4c48d300..83600dae 100644 --- a/pydis_site/templates/wiki/forms/fields/char.html +++ b/pydis_site/templates/wiki/forms/fields/char.html @@ -1,5 +1,5 @@
- {% if not is_markitup %} + {% if render_labels and not is_markitup %}
{% if field.label %}