From 6fbea294da72e5a25c6c5869c2686f185949a957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Sun, 8 Jan 2023 19:06:38 +0100 Subject: [PATCH] Add more filters and search refactoring --- ram/metadata/models.py | 2 +- ram/portal/templates/base.html | 3 +- ram/portal/templates/cards.html | 6 +- ram/portal/templates/companies.html | 2 +- ram/portal/templates/filter.html | 41 +++++++ ram/portal/templates/includes/search.html | 8 +- ram/portal/templates/manufacturers.html | 2 +- ram/portal/templates/scales.html | 2 +- ram/portal/templates/search.html | 9 +- ram/portal/templates/types.html | 73 +++++++++++++ ram/portal/urls.py | 21 ++-- ram/portal/views.py | 125 +++++++++++++++++----- 12 files changed, 245 insertions(+), 49 deletions(-) create mode 100644 ram/portal/templates/filter.html create mode 100644 ram/portal/templates/types.html diff --git a/ram/metadata/models.py b/ram/metadata/models.py index 5c375ed..01b032c 100644 --- a/ram/metadata/models.py +++ b/ram/metadata/models.py @@ -114,7 +114,7 @@ class Tag(models.Model): @receiver(models.signals.pre_save, sender=Tag) -def tag_pre_save(sender, instance, **kwargs): +def slug_pre_save(sender, instance, **kwargs): instance.slug = slugify(instance.name) diff --git a/ram/portal/templates/base.html b/ram/portal/templates/base.html index fc7e3ef..bd4df4d 100644 --- a/ram/portal/templates/base.html +++ b/ram/portal/templates/base.html @@ -81,8 +81,9 @@ Roster diff --git a/ram/portal/templates/cards.html b/ram/portal/templates/cards.html index 6575f78..ad1aac1 100644 --- a/ram/portal/templates/cards.html +++ b/ram/portal/templates/cards.html @@ -38,7 +38,7 @@ Company - {{ d.rolling_class.company }} + {{ d.rolling_class.company }} @@ -56,12 +56,12 @@ Manufacturer {%if d.manufacturer %} - {{ d.manufacturer }}{% if d.manufacturer.website %} {% endif %} + {{ d.manufacturer }}{% if d.manufacturer.website %} {% endif %} {% endif %} Scale - {{ d.scale }} + {{ d.scale }} SKU diff --git a/ram/portal/templates/companies.html b/ram/portal/templates/companies.html index 4a260a0..61f83aa 100644 --- a/ram/portal/templates/companies.html +++ b/ram/portal/templates/companies.html @@ -42,7 +42,7 @@
- Show all rolling stock + Show all rolling stock {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/filter.html b/ram/portal/templates/filter.html new file mode 100644 index 0000000..27bbaa1 --- /dev/null +++ b/ram/portal/templates/filter.html @@ -0,0 +1,41 @@ +{% extends "cards.html" %} + + {% block pagination %} + {% if data.has_other_pages %} + + {% endif %} + {% endblock %} diff --git a/ram/portal/templates/includes/search.html b/ram/portal/templates/includes/search.html index 619c4e8..1b09ce9 100644 --- a/ram/portal/templates/includes/search.html +++ b/ram/portal/templates/includes/search.html @@ -1,6 +1,12 @@
- + + +
diff --git a/ram/portal/templates/manufacturers.html b/ram/portal/templates/manufacturers.html index dab3c8b..f4318f7 100644 --- a/ram/portal/templates/manufacturers.html +++ b/ram/portal/templates/manufacturers.html @@ -34,7 +34,7 @@
- Show all rolling stock + Show all rolling stock {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/scales.html b/ram/portal/templates/scales.html index 1efc89c..d47d2f5 100644 --- a/ram/portal/templates/scales.html +++ b/ram/portal/templates/scales.html @@ -32,7 +32,7 @@
- Show all rolling stock + Show all rolling stock {% if request.user.is_staff %}Edit{% endif %}
diff --git a/ram/portal/templates/search.html b/ram/portal/templates/search.html index 975ab0f..3c9aa02 100644 --- a/ram/portal/templates/search.html +++ b/ram/portal/templates/search.html @@ -1,15 +1,12 @@ {% extends "cards.html" %} - {% block header %} -

Results found: {{ matches }}

- {% endblock %} {% block pagination %} {% if data.has_other_pages %}