From b6dc236d6e6af274c5bc5b6fac0cd64c281ede75 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:43:18 -0700 Subject: [PATCH 01/10] events page basic search functionality => only has title/intro search, filters are pending until i know what's wanted for that wrt mockup and what filters should be available --- ...townerpage_keyword_search_hint_and_more.py | 48 ++++++++++ app/events/models.py | 75 +++++++++++++-- .../events/components/EventsSortOption.html | 4 + .../templates/events/event_owner_page.html | 96 +++++++++++++++++++ app/news/models.py | 12 +-- .../news/components/NewsSortOption.html | 2 +- app/news/templates/news/news_owner_page.html | 2 +- .../events/EventPreviewBlockEvent.html | 10 ++ 8 files changed, 234 insertions(+), 15 deletions(-) create mode 100644 app/events/migrations/0004_eventownerpage_keyword_search_hint_and_more.py create mode 100644 app/events/templates/events/components/EventsSortOption.html create mode 100644 app/events/templates/events/event_owner_page.html diff --git a/app/events/migrations/0004_eventownerpage_keyword_search_hint_and_more.py b/app/events/migrations/0004_eventownerpage_keyword_search_hint_and_more.py new file mode 100644 index 0000000..634a82e --- /dev/null +++ b/app/events/migrations/0004_eventownerpage_keyword_search_hint_and_more.py @@ -0,0 +1,48 @@ +# Generated by Django 4.2.7 on 2024-06-27 18:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0003_eventownerpage_event_read_more_text_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='eventownerpage', + name='keyword_search_hint', + field=models.CharField(default='Search by keyword'), + ), + migrations.AddField( + model_name='eventownerpage', + name='results_text', + field=models.CharField(default='Results'), + ), + migrations.AddField( + model_name='eventownerpage', + name='search_button_text', + field=models.CharField(default='Search'), + ), + migrations.AddField( + model_name='eventownerpage', + name='sort_by_new', + field=models.CharField(default='Sort by New'), + ), + migrations.AddField( + model_name='eventownerpage', + name='sort_by_old', + field=models.CharField(default='Sort by Old'), + ), + migrations.AddField( + model_name='eventownerpage', + name='sort_by_titlea', + field=models.CharField(default='Sort by Title Alphabetical'), + ), + migrations.AddField( + model_name='eventownerpage', + name='sort_by_titlez', + field=models.CharField(default='Sort by Title Reverse Alphabetical'), + ), + ] diff --git a/app/events/models.py b/app/events/models.py index 47a1d1c..de5f9ab 100644 --- a/app/events/models.py +++ b/app/events/models.py @@ -1,13 +1,50 @@ from django.db import models +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from wagtail.models import Page from wagtail.fields import RichTextField, StreamField from wagtail.admin.panels import FieldPanel, MultiFieldPanel, PageChooserPanel from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock from modelcluster.fields import ParentalKey, ParentalManyToManyField +from wagtail.search import index class EventOwnerPage(Page): + def get_context(self, request, *args, **kwargs): + context = super().get_context(request, *args, **kwargs) + + keyword = request.GET.get('keyword', '') + events_list = IndividualEventPage.objects.live().filter(locale=context['page'].locale) + + if keyword: + events_list = events_list.search(keyword).get_queryset() + + match request.GET.get('sort', ''): + case 'sort.new': + events_list = events_list.order_by('-start_date_time') + case 'sort.old': + events_list = events_list.order_by('start_date_time') + case 'sort.titlea': + events_list = events_list.order_by('title') + case 'sort.titlez': + events_list = events_list.order_by('-title') + case _: + events_list = events_list.order_by('-start_date_time') + + page = request.GET.get('page', 1) + paginator = Paginator(events_list, 6) # if you want more/less items per page (i.e., per load), change the number here to something else + try: + events = paginator.page(page) + except PageNotAnInteger: + events = paginator.page(1) + except EmptyPage: + events = paginator.page(paginator.num_pages) + + context['events'] = events + context['events_paginator'] = paginator + context['current_page'] = int(page) + return context + max_count = 1 event_location_title = models.CharField(default="Event Location") @@ -18,14 +55,33 @@ class EventOwnerPage(Page): view_all_events_url = models.URLField(blank=True) event_read_more_text = models.CharField(default="Read more") + keyword_search_hint = models.CharField(default="Search by keyword") + sort_by_new = models.CharField(default="Sort by New") + sort_by_old = models.CharField(default="Sort by Old") + sort_by_titlea = models.CharField(default="Sort by Title Alphabetical") + sort_by_titlez = models.CharField(default="Sort by Title Reverse Alphabetical") + search_button_text = models.CharField(default="Search") + results_text = models.CharField(default="Results") + content_panels = Page.content_panels + [ - FieldPanel('event_location_title'), - FieldPanel('join_event_title'), - FieldPanel('rsvp_button_text'), - FieldPanel('more_events_title'), - FieldPanel('view_all_events_text'), - FieldPanel('view_all_events_url'), - FieldPanel('event_read_more_text'), + MultiFieldPanel([ + FieldPanel('keyword_search_hint'), + FieldPanel('sort_by_new'), + FieldPanel('sort_by_old'), + FieldPanel('sort_by_titlea'), + FieldPanel('sort_by_titlez'), + FieldPanel('search_button_text'), + FieldPanel('results_text'), + ], heading="Event Search Page"), + MultiFieldPanel([ + FieldPanel('event_location_title'), + FieldPanel('join_event_title'), + FieldPanel('rsvp_button_text'), + FieldPanel('more_events_title'), + FieldPanel('view_all_events_text'), + FieldPanel('view_all_events_url'), + FieldPanel('event_read_more_text'), + ], heading="Individual Event Page"), ] @@ -60,6 +116,11 @@ class IndividualEventPage(Page): ('event', PageChooserBlock(page_type="events.IndividualEventPage")) ], use_json_field=True, null=True, blank=True) + search_fields = Page.search_fields + [ + index.SearchField('title'), + index.SearchField('intro'), + ] + content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('start_date_time'), diff --git a/app/events/templates/events/components/EventsSortOption.html b/app/events/templates/events/components/EventsSortOption.html new file mode 100644 index 0000000..d364b07 --- /dev/null +++ b/app/events/templates/events/components/EventsSortOption.html @@ -0,0 +1,4 @@ +
+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %} +
+ ++ {{forloop.counter}} +
+ + {% endif %} + {% if forloop.counter|add:2 == current_page or forloop.counter|add:'-2' == current_page and not forloop.last %} + {% comment %} + for reasons that i can't begin to comprehend, the if statement + below CANNOT be part of the if statement above. it just does + not work + {% endcomment %} + {% if not forloop.first %} +...
+ {% endif %} + {% endif %} + {% endfor %} + {% endwith %} ++ {% include "ui/components/icon_svgs/LinkCaret.html" %} +
+ +From 497c57e41c1a0cf66c1e14e16a5ef359b4f657e3 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:58:15 -0700 Subject: [PATCH 02/10] project - open mapping hub page done => worked on this while waiting for the event page stuff! => structure changed; project owner page is now made to be the child of a mapping hub, so projects are connected to a mapping hub via grandparentage => i had mistyped "parent_page_type" in multiple pages' models when it should have been "parent_page_types" so that's fixed --- app/events/models.py | 2 +- .../templates/events/event_owner_page.html | 2 + app/impact_areas/models.py | 2 +- .../individual_impact_area_page.html | 2 +- app/mapping_hubs/models.py | 2 +- .../individual_mapping_hub_page.html | 2 +- .../templates/news/individual_news_page.html | 108 +++++++++--------- app/news/templates/news/news_owner_page.html | 2 + ...rojectownerpage_load_more_projects_text.py | 18 +++ ..._individualprojectpage_owner_region_hub.py | 17 +++ app/projects/models.py | 92 +++++++++------ .../templates/projects/components/header.html | 25 ++++ .../projects/individual_project_page.html | 4 +- .../projects/project_owner_page.html | 39 +++++++ .../components/news/NewsPreviewBlockNews.html | 2 +- .../news/NewsPreviewBlockProjects.html | 2 +- .../components/news/NewsPreviewCarousel.html | 2 +- .../projects/ProjectPreviewBlockMapHub.html | 6 +- .../projects/ProjectPreviewBlockNews.html | 2 +- .../projects/ProjectPreviewCarousel.html | 2 +- home/templates/home/home_page.html | 2 +- 21 files changed, 232 insertions(+), 103 deletions(-) create mode 100644 app/projects/migrations/0022_projectownerpage_load_more_projects_text.py create mode 100644 app/projects/migrations/0023_remove_individualprojectpage_owner_region_hub.py create mode 100644 app/projects/templates/projects/components/header.html create mode 100644 app/projects/templates/projects/project_owner_page.html diff --git a/app/events/models.py b/app/events/models.py index de5f9ab..c486579 100644 --- a/app/events/models.py +++ b/app/events/models.py @@ -86,7 +86,7 @@ def get_context(self, request, *args, **kwargs): class IndividualEventPage(Page): - parent_page_type = [ + parent_page_types = [ 'projects.ProjectOwnerPage' ] diff --git a/app/events/templates/events/event_owner_page.html b/app/events/templates/events/event_owner_page.html index 6eddd92..073f462 100644 --- a/app/events/templates/events/event_owner_page.html +++ b/app/events/templates/events/event_owner_page.html @@ -44,6 +44,7 @@
{{page.get_parent.specific.authors_posted_by_text}} {% for author in page.authors %} - {{author.value.title}} + {{author.value.title}} {% if not forloop.last %} , {% endif %} @@ -41,70 +41,70 @@
- {% with categories=page.categories.all %} - {% for category in categories %} - {{ category.category_name }}{% if not forloop.last %}, {% endif %} - {% endfor %} - {% endwith %} -
-+ {% with categories=page.categories.all %} + {% for category in categories %} + {{ category.category_name }}{% if not forloop.last %}, {% endif %} + {% endfor %} + {% endwith %} +
+- {% with tags=page.tags.all %} - {% for tag in tags %} - {{ tag }}{% if not forloop.last %}, {% endif %} - {% endfor %} - {% endwith %} -
-+ {% with tags=page.tags.all %} + {% for tag in tags %} + {{ tag }}{% if not forloop.last %}, {% endif %} + {% endfor %} + {% endwith %} +
++ {{ page.get_parent.specific.header_hub_text_white }} {{ page.get_parent.specific.header_hub_text_red }} +
+{{page.get_parent.specific.region_hub_title}}
- +{{page.get_parent.specific.duration_title}}
@@ -68,7 +68,7 @@
{{ news.date }}
diff --git a/app/ui/templates/ui/components/news/NewsPreviewBlockProjects.html b/app/ui/templates/ui/components/news/NewsPreviewBlockProjects.html
index 263fa54..6f8ed31 100644
--- a/app/ui/templates/ui/components/news/NewsPreviewBlockProjects.html
+++ b/app/ui/templates/ui/components/news/NewsPreviewBlockProjects.html
@@ -6,7 +6,7 @@
{% load wagtailimages_tags %}
{% image news.image original as image_p %}
-
-
- {{ project.owner_region_hub.title }}
+
+ {{ project.get_parent.get_parent.title }}
{{description|safe}}
{{ linktext }}
diff --git a/app/ui/templates/ui/components/dogear_boxes/DogearRed.html b/app/ui/templates/ui/components/dogear_boxes/DogearRed.html
index 3c30e75..384f924 100644
--- a/app/ui/templates/ui/components/dogear_boxes/DogearRed.html
+++ b/app/ui/templates/ui/components/dogear_boxes/DogearRed.html
@@ -5,6 +5,6 @@
- linktext: a string; the text that shows for the link
{% endcomment %}
-
+
Learn More about {{ ia.title }}
diff --git a/app/ui/templates/ui/components/sections/BaseSectionWithImage.html b/app/ui/templates/ui/components/sections/BaseSectionWithImage.html
new file mode 100644
index 0000000..97eb495
--- /dev/null
+++ b/app/ui/templates/ui/components/sections/BaseSectionWithImage.html
@@ -0,0 +1,35 @@
+{% load wagtailimages_tags %}
+
+
+ {% include "ui/components/BaseLink.html" with linktext=link.value.text linkurl=link.value.link %}
+
+ {% include "ui/components/BaseLink.html" with linktext=learn_more_text|add:" "|add:hub.title|add:" "|add:hub_text linkurl=hub.url %}
+
+ {% include "ui/components/BaseLink.html" %}
+
+ {% include "ui/components/BaseLink.html" %}
+
+ {{read_more_text}}
+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="ml-2" %}
+
+ {% if projects.has_next %}
+ {% comment %} {% endcomment %}
+
+ {% endif %}
+ {{page.get_parent.specific.region_hub_title}} {{page.get_parent.specific.duration_title}}
+ {{page.learn_more_data_principles_text}}
+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="ml-4" %}
+
- {{ hub.title }}
-
+ {{ hub.title }}
+
-
- {{ project.get_parent.get_parent.title }}
-
+ {% for hub in project.region_hub_list %}
+ {{ hub.value.title }}{% if not forloop.last %},{% endif %}
+ {% endfor %}
- {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %}
-
- {{forloop.counter}}
- ...
- {% include "ui/components/icon_svgs/LinkCaret.html" %}
-
- {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %}
-
- {{forloop.counter}}
- ...
- {% include "ui/components/icon_svgs/LinkCaret.html" %}
-
+ {% for ancestor in result.get_ancestors|slice:"2:" %}
+ {{ancestor.title}}
+ {% if not forloop.last %} > {% endif %}
+ {% endfor %}
+ {{result.search_description}}
+ {% include "ui/components/BaseLink.html" with linktext=page.no_results_go_back linkurl="javascript:history.back()" %}
+
+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %}
+
+ {{forloop.counter}}
+ ...
+ {% include "ui/components/icon_svgs/LinkCaret.html" %}
+ with some text in it)
- image: A Wagtail image
+- full_length: If falsey/null, the content will not be entirely full length in the header; otherwise, it will be full length
{% endcomment %}
{% load wagtailimages_tags %}
diff --git a/app/ui/templates/ui/components/SectionHeadingWithUnderline.html b/app/ui/templates/ui/components/SectionHeadingWithUnderline.html
index a1b5a00..cd31bca 100644
--- a/app/ui/templates/ui/components/SectionHeadingWithUnderline.html
+++ b/app/ui/templates/ui/components/SectionHeadingWithUnderline.html
@@ -1,3 +1,8 @@
+{% comment %}
+==> PARAMETERS
+- title: string; the title
+{% endcomment %}
+
diff --git a/app/ui/templates/ui/components/navigation/HeaderNavbarItem.html b/app/ui/templates/ui/components/navigation/HeaderNavbarItem.html
index 764ac4b..3a9d72d 100644
--- a/app/ui/templates/ui/components/navigation/HeaderNavbarItem.html
+++ b/app/ui/templates/ui/components/navigation/HeaderNavbarItem.html
@@ -1,3 +1,8 @@
+{% comment %}
+==> PARAMETERS
+- item: a navigation item; has a title and a link_page OR link_url, as well as potentially children
+ - these children will have the same parameters, and those children's children will have the same except they cannot have children
+{% endcomment %}
+ {{ ia.title }}
+
+
+
{{ title }}
+{% if description %}
+
+ {% image ia.external_icon original class="black-image-redifier h-16 w-auto inline" %}
{{ ia.title }}
@@ -14,7 +15,7 @@
{{ ia.intro|safe }}
+ {% endif %}
+ {{title}}
+
+{{block.value.title}}
+ {{block.value.description|safe}}
+
+ {{prev.value.page.title}}
+
+
+ {{ page.partners_title }}
+
+
+
+
{{ title }}
+ {{hub.title}} {{hub_text}}
+
+
+ {{title}}
+
+
+ {{title}}
+
+
diff --git a/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html b/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
index 3b0288b..de6d026 100644
--- a/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
+++ b/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
@@ -6,13 +6,13 @@
- colour: a string; the colour that the box should be (can be hex code or any other CSS compatible colour thing)
{% endcomment %}
-
{{ title }}
{{ linktext }}
-
+
{% include "ui/components/icon_svgs/LinkCaret.html" %}
diff --git a/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html b/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html
new file mode 100644
index 0000000..a61d172
--- /dev/null
+++ b/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html
@@ -0,0 +1,12 @@
+{% load wagtailimages_tags %}
+
+{{title}}
+
+ {{page.title}}
+
+
+ {{page.title}}
+
+ {{page.title}}
+ {{block.value.title}}
{% comment %} PAGE PREVIEWS {% endcomment %}
- {{prev.value.page.title}}
-
-
+ {{page.projects_by_hub_title}}
+
+ {{page.intro_header}}
+
+ {{page.title}}
{% comment %} EVENT ITEMS {% endcomment %}
{{events_paginator.count}} {{page.results_text}}
- {{page.title}}
{% comment %} NEWS ITEMS {% endcomment %}
{{news_paginator.count}} {{page.results_text}}
-
+ {% if results %}
+ {{page.search_text_prefix}} "{{keyword}}" {{page.search_text_midfix}} {{results_paginator.count}} {{page.search_text_postfix}}
+ {% else %}
+ {{page.no_results_text}} "{{keyword}}"
+ {% endif %}
+
+ {{result.title}}
+ {% if result.get_ancestors|length > 2 %}
+
+
{{ title }}
diff --git a/app/ui/templates/ui/components/FlexTitleWithLink.html b/app/ui/templates/ui/components/FlexTitleWithLink.html
index 0f23d2a..ecf2dc6 100644
--- a/app/ui/templates/ui/components/FlexTitleWithLink.html
+++ b/app/ui/templates/ui/components/FlexTitleWithLink.html
@@ -1,3 +1,11 @@
+{% comment %}
+==> PARAMETERS
+- title: string; the title
+- class: string; the classes for the containing div
+- titleclass: string; the classes for the title specifically. If no class is provided, the title will be h3 title size
+- linktext: string; the text to be shown for the link
+- linkurl: string; the url for the link
+{% endcomment %}
{{title}}
diff --git a/app/ui/templates/ui/components/PageHeaderWithBlur.html b/app/ui/templates/ui/components/PageHeaderWithBlur.html
index 3aa41e6..e67f2ed 100644
--- a/app/ui/templates/ui/components/PageHeaderWithBlur.html
+++ b/app/ui/templates/ui/components/PageHeaderWithBlur.html
@@ -3,6 +3,7 @@
- title: A string, the title shown in the header
- subtitle: An HTML element (regular usage would be a
{{ title }}
diff --git a/app/ui/templates/ui/components/ThreeElementCarousel.html b/app/ui/templates/ui/components/ThreeElementCarousel.html
index 0e3fed9..00ff572 100644
--- a/app/ui/templates/ui/components/ThreeElementCarousel.html
+++ b/app/ui/templates/ui/components/ThreeElementCarousel.html
@@ -1,3 +1,13 @@
+{% comment %}
+==> PARAMETERS
+- carousel: list of blocks; each block should have a .value, which should have:
+ - .header: string
+ - .body: string
+ - .action_button.text: string
+ - .action_button.link: string
+
+If you'd like, refer to app.ui.models to see the specifics of what makes up a carousel block.
+{% endcomment %}
{{title}}
diff --git a/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html b/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
index de6d026..b1f5fdd 100644
--- a/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
+++ b/app/ui/templates/ui/components/dogear_boxes/DogearAnyColourLong.html
@@ -4,6 +4,7 @@
- linkurl: a string; the link's url
- linktext: a string; the text that shows for the link
- colour: a string; the colour that the box should be (can be hex code or any other CSS compatible colour thing)
+- arrowcolour: a string; the colour the arrow should be
{% endcomment %}