From 0716af392552696eb6f57792ff9108fb7f9d475a Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sun, 20 Dec 2020 12:00:09 +0100 Subject: [PATCH] Move common templates to shared folder --- elections/templates/elections/election.html | 2 +- .../templates/elections/election_admin.html | 10 +++--- .../templates/elections/election_create.html | 4 +-- .../templates/elections/election_list.html | 2 +- .../templates/elections/election_update.html | 4 +-- .../templates/elections/forms/field.html | 33 ------------------- .../templates/elections/option_update.html | 4 +-- .../templates/elections/question_update.html | 4 +-- elections/templates/elections/vote.html | 4 +-- kadenios/settings_base.py | 2 +- .../elections => shared/templates}/base.html | 0 .../templates}/forms/checkbox.html | 0 shared/templates/forms/field.html | 33 +++++++++++++++++++ .../templates}/forms/file.html | 2 +- .../templates}/forms/form.html | 2 +- .../templates}/forms/formset.html | 2 +- .../templates}/forms/input.html | 0 .../templates}/forms/other.html | 0 .../templates}/forms/radio.html | 0 .../templates}/forms/select.html | 0 .../templates}/forms/textarea.html | 0 21 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 elections/templates/elections/forms/field.html rename {elections/templates/elections => shared/templates}/base.html (100%) rename {elections/templates/elections => shared/templates}/forms/checkbox.html (100%) create mode 100644 shared/templates/forms/field.html rename {elections/templates/elections => shared/templates}/forms/file.html (94%) rename {elections/templates/elections => shared/templates}/forms/form.html (91%) rename {elections/templates/elections => shared/templates}/forms/formset.html (62%) rename {elections/templates/elections => shared/templates}/forms/input.html (100%) rename {elections/templates/elections => shared/templates}/forms/other.html (100%) rename {elections/templates/elections => shared/templates}/forms/radio.html (100%) rename {elections/templates/elections => shared/templates}/forms/select.html (100%) rename {elections/templates/elections => shared/templates}/forms/textarea.html (100%) diff --git a/elections/templates/elections/election.html b/elections/templates/elections/election.html index 4e45fd6..f4338da 100644 --- a/elections/templates/elections/election.html +++ b/elections/templates/elections/election.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n %} diff --git a/elections/templates/elections/election_admin.html b/elections/templates/elections/election_admin.html index 4fa7ef8..d5d668a 100644 --- a/elections/templates/elections/election_admin.html +++ b/elections/templates/elections/election_admin.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n %} @@ -106,18 +106,18 @@ {% for o in q.options.all %}
{% if election.start_date > current_time %} - + {% elif election.tallied %} diff --git a/elections/templates/elections/election_create.html b/elections/templates/elections/election_create.html index 84e165a..1c27f87 100644 --- a/elections/templates/elections/election_create.html +++ b/elections/templates/elections/election_create.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n static %} @@ -34,7 +34,7 @@
{% csrf_token %} - {% include "elections/forms/form.html" with errors=False %} + {% include "forms/form.html" with errors=False %}
diff --git a/elections/templates/elections/election_list.html b/elections/templates/elections/election_list.html index c92e956..7ed4c90 100644 --- a/elections/templates/elections/election_list.html +++ b/elections/templates/elections/election_list.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n %} diff --git a/elections/templates/elections/election_update.html b/elections/templates/elections/election_update.html index 85d5045..6753b95 100644 --- a/elections/templates/elections/election_update.html +++ b/elections/templates/elections/election_update.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n static %} @@ -34,7 +34,7 @@ {% csrf_token %} - {% include "elections/forms/form.html" with errors=False %} + {% include "forms/form.html" with errors=False %}
diff --git a/elections/templates/elections/forms/field.html b/elections/templates/elections/forms/field.html deleted file mode 100644 index 497ebf8..0000000 --- a/elections/templates/elections/forms/field.html +++ /dev/null @@ -1,33 +0,0 @@ -{% load bulma_utils %} - -
- {% if field|is_checkbox %} - - {% include "elections/forms/checkbox.html" with field=field %} - - {% elif field|is_radio %} - - {% include "elections/forms/radio.html" with field=field %} - - {% elif field|is_input %} - - {% include "elections/forms/input.html" with field=field %} - - {% elif field|is_textarea %} - - {% include "elections/forms/textarea.html" with field=field %} - - {% elif field|is_select %} - - {% include "elections/forms/select.html" with field=field %} - - {% elif field|is_file %} - - {% include "elections/forms/file.html" with field=field %} - - {% else %} - - {% include "elections/forms/other.html" with field=field %} - - {% endif %} -
diff --git a/elections/templates/elections/option_update.html b/elections/templates/elections/option_update.html index 0ade8f4..a7ebbb4 100644 --- a/elections/templates/elections/option_update.html +++ b/elections/templates/elections/option_update.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n static %} @@ -16,7 +16,7 @@ {% csrf_token %} - {% include "elections/forms/form.html" with errors=False %} + {% include "forms/form.html" with errors=False %}
diff --git a/elections/templates/elections/question_update.html b/elections/templates/elections/question_update.html index 139ae1a..265d416 100644 --- a/elections/templates/elections/question_update.html +++ b/elections/templates/elections/question_update.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n static %} @@ -16,7 +16,7 @@ {% csrf_token %} - {% include "elections/forms/form.html" with errors=False %} + {% include "forms/form.html" with errors=False %}
diff --git a/elections/templates/elections/vote.html b/elections/templates/elections/vote.html index 82b1fd3..c518bf7 100644 --- a/elections/templates/elections/vote.html +++ b/elections/templates/elections/vote.html @@ -1,4 +1,4 @@ -{% extends "elections/base.html" %} +{% extends "base.html" %} {% load i18n %} @@ -12,7 +12,7 @@ {% csrf_token %} - {% include "elections/forms/formset.html" %} + {% include "forms/formset.html" %}
diff --git a/kadenios/settings_base.py b/kadenios/settings_base.py index aca9dab..9e60711 100644 --- a/kadenios/settings_base.py +++ b/kadenios/settings_base.py @@ -52,7 +52,7 @@ ROOT_URLCONF = "kadenios.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [BASE_DIR + "/shared/templates"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ diff --git a/elections/templates/elections/base.html b/shared/templates/base.html similarity index 100% rename from elections/templates/elections/base.html rename to shared/templates/base.html diff --git a/elections/templates/elections/forms/checkbox.html b/shared/templates/forms/checkbox.html similarity index 100% rename from elections/templates/elections/forms/checkbox.html rename to shared/templates/forms/checkbox.html diff --git a/shared/templates/forms/field.html b/shared/templates/forms/field.html new file mode 100644 index 0000000..8c5ad14 --- /dev/null +++ b/shared/templates/forms/field.html @@ -0,0 +1,33 @@ +{% load bulma_utils %} + +
+ {% if field|is_checkbox %} + + {% include "forms/checkbox.html" %} + + {% elif field|is_radio %} + + {% include "forms/radio.html" %} + + {% elif field|is_input %} + + {% include "forms/input.html" %} + + {% elif field|is_textarea %} + + {% include "forms/textarea.html" %} + + {% elif field|is_select %} + + {% include "forms/select.html" %} + + {% elif field|is_file %} + + {% include "forms/file.html" %} + + {% else %} + + {% include "forms/other.html" %} + + {% endif %} +
diff --git a/elections/templates/elections/forms/file.html b/shared/templates/forms/file.html similarity index 94% rename from elections/templates/elections/forms/file.html rename to shared/templates/forms/file.html index 1bfd7bd..fbabfd5 100644 --- a/elections/templates/elections/forms/file.html +++ b/shared/templates/forms/file.html @@ -10,7 +10,7 @@ {{ field|bulmafy:'file-input' }} - + {% trans "Choisissez un fichier..." %} diff --git a/elections/templates/elections/forms/form.html b/shared/templates/forms/form.html similarity index 91% rename from elections/templates/elections/forms/form.html rename to shared/templates/forms/form.html index e8e3141..cc312aa 100644 --- a/elections/templates/elections/forms/form.html +++ b/shared/templates/forms/form.html @@ -18,5 +18,5 @@ {% endfor %} {% for field in form.visible_fields %} -{% include 'elections/forms/field.html' %} +{% include 'forms/field.html' %} {% endfor %} diff --git a/elections/templates/elections/forms/formset.html b/shared/templates/forms/formset.html similarity index 62% rename from elections/templates/elections/forms/formset.html rename to shared/templates/forms/formset.html index 0c7c2b3..79b261c 100644 --- a/elections/templates/elections/forms/formset.html +++ b/shared/templates/forms/formset.html @@ -1,4 +1,4 @@ {{ formset.management_form }} {% for form in formset %} -{% include "elections/forms/form.html" %} +{% include 'forms/form.html' %} {% endfor %} diff --git a/elections/templates/elections/forms/input.html b/shared/templates/forms/input.html similarity index 100% rename from elections/templates/elections/forms/input.html rename to shared/templates/forms/input.html diff --git a/elections/templates/elections/forms/other.html b/shared/templates/forms/other.html similarity index 100% rename from elections/templates/elections/forms/other.html rename to shared/templates/forms/other.html diff --git a/elections/templates/elections/forms/radio.html b/shared/templates/forms/radio.html similarity index 100% rename from elections/templates/elections/forms/radio.html rename to shared/templates/forms/radio.html diff --git a/elections/templates/elections/forms/select.html b/shared/templates/forms/select.html similarity index 100% rename from elections/templates/elections/forms/select.html rename to shared/templates/forms/select.html diff --git a/elections/templates/elections/forms/textarea.html b/shared/templates/forms/textarea.html similarity index 100% rename from elections/templates/elections/forms/textarea.html rename to shared/templates/forms/textarea.html