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 @@ +
+ + +
\ No newline at end of file diff --git a/app/events/templates/events/event_owner_page.html b/app/events/templates/events/event_owner_page.html new file mode 100644 index 0000000..6eddd92 --- /dev/null +++ b/app/events/templates/events/event_owner_page.html @@ -0,0 +1,96 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-eventownerpage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} +
+
+

{{page.title}}

+
+
+ {% comment %} KEYWORD SEARCH {% endcomment %} +
+ + {% include "ui/components/icon_svgs/SearchIcon.html" with class="text-hot-red mx-3" %} +
+ + {% comment %} SORT {% endcomment %} +
+
+

+ {{page.sort_by_new}} +

+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-90 text-hot-red" %} +
+
+
+ {% include "./components/EventsSortOption.html" with sort_by=page.sort_by_new sort_id="sort.new" %} + {% include "./components/EventsSortOption.html" with sort_by=page.sort_by_old sort_id="sort.old" %} + {% include "./components/EventsSortOption.html" with sort_by=page.sort_by_titlea sort_id="sort.titlea" %} + {% include "./components/EventsSortOption.html" with sort_by=page.sort_by_titlez sort_id="sort.titlez" %} +
+
+ +
+ +
+
+
+ +

{{events_paginator.count}} {{page.results_text}}

+
+ {% for event in events %} + {% include "ui/components/events/EventPreviewBlockEvent.html" with event=event showimage=True %} + {% endfor %} +
+ +
+ +

+ {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %} +

+
+
+ {% with ''|center:events_paginator.num_pages as range %} + {% for _ in range %} + {% if forloop.counter == 1 or forloop.counter == events_paginator.num_pages or forloop.counter == current_page or forloop.counter|add:1 == current_page or forloop.counter|add:'-1' == current_page %} + +

+ {{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" %} +

+
+
+
+
+{% endblock %} diff --git a/app/news/models.py b/app/news/models.py index 279dda1..a58a56d 100644 --- a/app/news/models.py +++ b/app/news/models.py @@ -32,20 +32,20 @@ def get_context(self, request, *args, **kwargs): query = query | Q(tags__name=tag) news_list = news_list.filter(query).distinct() + if keyword: + news_list = news_list.search(keyword).get_queryset() + match request.GET.get('sort', ''): case 'sort.new': - news_list = news_list.order_by('date') - case 'sort.old': news_list = news_list.order_by('-date') + case 'sort.old': + news_list = news_list.order_by('date') case 'sort.titlea': news_list = news_list.order_by('title') case 'sort.titlez': news_list = news_list.order_by('-title') case _: - news_list = news_list.order_by('date') - - if keyword: - news_list = news_list.search(keyword) + news_list = news_list.order_by('-date') page = request.GET.get('page', 1) paginator = Paginator(news_list, 6) # if you want more/less items per page (i.e., per load), change the number here to something else diff --git a/app/news/templates/news/components/NewsSortOption.html b/app/news/templates/news/components/NewsSortOption.html index 8b30d23..d364b07 100644 --- a/app/news/templates/news/components/NewsSortOption.html +++ b/app/news/templates/news/components/NewsSortOption.html @@ -1,4 +1,4 @@
- +
\ No newline at end of file diff --git a/app/news/templates/news/news_owner_page.html b/app/news/templates/news/news_owner_page.html index 90b6592..8a0280f 100644 --- a/app/news/templates/news/news_owner_page.html +++ b/app/news/templates/news/news_owner_page.html @@ -3,7 +3,7 @@ {% load wagtailcore_tags %} {% load wagtailimages_tags %} {% load compress %} -{% block body_class %}template-individualnewspage{% endblock %} +{% block body_class %}template-newsownerpage{% endblock %} {% block extra_css %} {% compress css %} {% endcompress css %} diff --git a/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html b/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html index b117e8b..433fe8c 100644 --- a/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html +++ b/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html @@ -1,4 +1,14 @@ +{% load wagtailimages_tags %} + +{% image event.image original as image_p %}
+ {% if showimage %} +
+
+
+
+ {% endif %} +
{% if event.start_date_time.date == event.end_date_time.date %}

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.title}}

+ {% comment %} EVENT ITEMS {% endcomment %}

{{events_paginator.count}} {{page.results_text}}

{% for event in events %} @@ -51,6 +52,7 @@

{{events_paginator.count}} {{page.results_tex {% endfor %}

+ {% comment %} PAGE NAVIGATION {% endcomment %}
-
+
{% for project in projects %} {% include "ui/components/projects/ProjectPreviewBlockNews.html" with project=project showimage=True %} {% endfor %} diff --git a/app/mapping_hubs/models.py b/app/mapping_hubs/models.py index b2e6256..b913f4f 100644 --- a/app/mapping_hubs/models.py +++ b/app/mapping_hubs/models.py @@ -33,7 +33,7 @@ class DogearBoxBlock(StreamBlock): class IndividualMappingHubPage(Page): def get_context(self, request): context = super().get_context(request) - projects = IndividualProjectPage.objects.filter(owner_region_hub=context['page'], locale=context['page'].locale) + projects = context['page'].get_children()[0].get_children().filter(locale=context['page'].locale) context['projects'] = projects other_hubs = IndividualMappingHubPage.objects.live().filter(locale=context['page'].locale) context['other_hubs'] = other_hubs diff --git a/app/mapping_hubs/templates/mapping_hubs/individual_mapping_hub_page.html b/app/mapping_hubs/templates/mapping_hubs/individual_mapping_hub_page.html index 833a3b1..7e20464 100644 --- a/app/mapping_hubs/templates/mapping_hubs/individual_mapping_hub_page.html +++ b/app/mapping_hubs/templates/mapping_hubs/individual_mapping_hub_page.html @@ -35,7 +35,7 @@
{% for project in projects %} - {% include "ui/components/projects/ProjectPreviewBlockMapHub.html" with project=project showimage="True" %} + {% include "ui/components/projects/ProjectPreviewBlockMapHub.html" with project=project.specific showimage="True" %} {% endfor %}
diff --git a/app/news/templates/news/individual_news_page.html b/app/news/templates/news/individual_news_page.html index 26b25ac..c91346e 100644 --- a/app/news/templates/news/individual_news_page.html +++ b/app/news/templates/news/individual_news_page.html @@ -17,7 +17,7 @@

{{ page.title }}

{{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 @@

{{ page.title }}

{% comment %} SIDEBAR {% endcomment %}
{% if page.related_projects%} -
-
-

- {{ page.get_parent.specific.related_projects_title }} -

-
- {% with projects=page.related_projects %} - {% for project in projects %} - {% include "ui/components/projects/ProjectPreviewBlockNews.html" with project=project.value %} - {% endfor %} - {% endwith %} +
+
+

+ {{ page.get_parent.specific.related_projects_title }} +

+
+ {% with projects=page.related_projects %} + {% for project in projects %} + {% include "ui/components/projects/ProjectPreviewBlockNews.html" with project=project.value %} + {% endfor %} + {% endwith %} +
-
{% endif %} {% if page.related_news %} -
-
-

- {{ page.get_parent.specific.related_news_title }} -

-
- {% include "ui/components/BaseLink.html" with linkurl="#" linktext=page.get_parent.specific.view_all_news_text %} -
-
- {% with allnews=page.related_news %} - {% for news in allnews %} - {% include "ui/components/news/NewsPreviewBlockNews.html" with news=news.value readmoretext=page.get_parent.specific.read_more_text %} - {% endfor %} - {% endwith %} +
+
+

+ {{ page.get_parent.specific.related_news_title }} +

+
+ {% include "ui/components/BaseLink.html" with linkurl="#" linktext=page.get_parent.specific.view_all_news_text %} +
+
+ {% with allnews=page.related_news %} + {% for news in allnews %} + {% include "ui/components/news/NewsPreviewBlockNews.html" with news=news.value readmoretext=page.get_parent.specific.read_more_text %} + {% endfor %} + {% endwith %} +
-
{% endif %} {% if page.categories.all %} -
-
-

- {{ page.get_parent.specific.categories_title }} -

-

- {% with categories=page.categories.all %} - {% for category in categories %} - {{ category.category_name }}{% if not forloop.last %}, {% endif %} - {% endfor %} - {% endwith %} -

-
+
+
+

+ {{ page.get_parent.specific.categories_title }} +

+

+ {% with categories=page.categories.all %} + {% for category in categories %} + {{ category.category_name }}{% if not forloop.last %}, {% endif %} + {% endfor %} + {% endwith %} +

+
{% endif %} {% if page.tags.all %} -
-
-

- {{ page.get_parent.specific.tags_title }} -

-

- {% with tags=page.tags.all %} - {% for tag in tags %} - {{ tag }}{% if not forloop.last %}, {% endif %} - {% endfor %} - {% endwith %} -

-
+
+
+

+ {{ page.get_parent.specific.tags_title }} +

+

+ {% with tags=page.tags.all %} + {% for tag in tags %} + {{ tag }}{% if not forloop.last %}, {% endif %} + {% endfor %} + {% endwith %} +

+
{% endif %}
diff --git a/app/news/templates/news/news_owner_page.html b/app/news/templates/news/news_owner_page.html index 8a0280f..13ac88f 100644 --- a/app/news/templates/news/news_owner_page.html +++ b/app/news/templates/news/news_owner_page.html @@ -94,6 +94,7 @@

{{page.title}}

+ {% comment %} NEWS ITEMS {% endcomment %}

{{news_paginator.count}} {{page.results_text}}

{% for article in news %} @@ -101,6 +102,7 @@

{{news_paginator.count}} {{page.results_text} {% endfor %}

+ {% comment %} PAGE NAVIGATION {% endcomment %}
HEADER @@ -103,14 +138,6 @@ class IndividualProjectPage(Page): # > SIDE BAR impact_area_list = StreamField([('impact_area', PageChooserBlock(page_type="impact_areas.IndividualImpactAreaPage"))], use_json_field=True, null=True, blank=True) - owner_region_hub = models.ForeignKey( - 'wagtailcore.Page', - null=True, - blank=True, - on_delete=models.SET_NULL, - related_name='+' - ) - duration = models.CharField(default="Ongoing", blank=True) partners_list = ParentalManyToManyField('core.Partner', blank=True) @@ -147,7 +174,6 @@ class IndividualProjectPage(Page): ], heading="Body"), MultiFieldPanel([ FieldPanel('impact_area_list'), - PageChooserPanel('owner_region_hub', 'mapping_hubs.IndividualMappingHubPage'), FieldPanel('duration'), FieldPanel('partners_list', widget=forms.CheckboxSelectMultiple), FieldPanel('tools'), diff --git a/app/projects/templates/projects/components/header.html b/app/projects/templates/projects/components/header.html new file mode 100644 index 0000000..72d8327 --- /dev/null +++ b/app/projects/templates/projects/components/header.html @@ -0,0 +1,25 @@ +{% comment %} +==> PARAMETERS +- body: The content of the header +- image: A Wagtail image +{% endcomment %} + +{% load wagtailimages_tags %} + +{% image page.get_parent.specific.header_image original as image_p %} +
+
+
+
+
+

+ {{ page.get_parent.specific.header_hub_text_white }} {{ page.get_parent.specific.header_hub_text_red }} +

+

+ {{ page.get_parent.specific.project_section_title }} +

+
+
+
+
+
diff --git a/app/projects/templates/projects/individual_project_page.html b/app/projects/templates/projects/individual_project_page.html index 630b04d..2cc3b2c 100644 --- a/app/projects/templates/projects/individual_project_page.html +++ b/app/projects/templates/projects/individual_project_page.html @@ -37,7 +37,7 @@

{{page.get_parent.specific.region_hub_title}}

-

{{page.owner_region_hub.title}}

+

{{page.get_parent.get_parent.title}}

{{page.get_parent.specific.duration_title}}

@@ -68,7 +68,7 @@

{% include "ui/components/BaseLink.html" with linkurl=page.get_parent.specific.view_all_news_url linktext=page.get_parent.specific.view_all_news_text %}
-
+
{% with allnews=page.related_news %} {% for news in allnews %} {% include "ui/components/news/NewsPreviewBlockProjects.html" with news=news.value %} diff --git a/app/projects/templates/projects/project_owner_page.html b/app/projects/templates/projects/project_owner_page.html new file mode 100644 index 0000000..0191b6e --- /dev/null +++ b/app/projects/templates/projects/project_owner_page.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-projectownerpage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "./components/header.html" %} +
+
+
+ {% for project in projects %} + {% include "ui/components/projects/ProjectPreviewBlockNews.html" with project=project.specific showimage=True %} + {% endfor %} +
+

+ {% if projects.has_next %} + {% comment %} {% endcomment %} + + {% endif %} +

+
+
+{% endblock %} diff --git a/app/ui/templates/ui/components/news/NewsPreviewBlockNews.html b/app/ui/templates/ui/components/news/NewsPreviewBlockNews.html index 075345d..f3aa44a 100644 --- a/app/ui/templates/ui/components/news/NewsPreviewBlockNews.html +++ b/app/ui/templates/ui/components/news/NewsPreviewBlockNews.html @@ -4,7 +4,7 @@ - readmoretext: a string; the text that should show for the "read more" button {% endcomment %} -
+

{{ 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 %} -

+ -
+
{% for article in news %}
+
\ No newline at end of file diff --git a/app/ui/templates/ui/components/projects/ProjectPreviewBlockNews.html b/app/ui/templates/ui/components/projects/ProjectPreviewBlockNews.html index 222ffed..1bb4cc9 100644 --- a/app/ui/templates/ui/components/projects/ProjectPreviewBlockNews.html +++ b/app/ui/templates/ui/components/projects/ProjectPreviewBlockNews.html @@ -7,7 +7,7 @@ {% load wagtailimages_tags %} {% image project.header_image original as image_p %} -
+ -
+
{% for project in projects %}
-
+
{% for news in page.displayed_news %}
{% include "ui/components/news/NewsPreviewBlockProjects.html" with news=news.value showimage=True %} From f18444a212919d68aa68690272ea1550baa2d02d Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:34:46 -0700 Subject: [PATCH 03/10] starting work on Who We Are, updated primary Impact Areas page --- .../impact_areas/impact_areas_page.html | 4 +-- .../impact_areas/ImpactAreaPreviewBlock.html | 26 +++++++++++++++++++ app/who_we_are/__init__.py | 0 app/who_we_are/admin.py | 3 +++ app/who_we_are/apps.py | 6 +++++ app/who_we_are/migrations/__init__.py | 0 app/who_we_are/models.py | 3 +++ app/who_we_are/tests.py | 3 +++ app/who_we_are/views.py | 3 +++ home/models.py | 17 +++++------- 10 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html create mode 100644 app/who_we_are/__init__.py create mode 100644 app/who_we_are/admin.py create mode 100644 app/who_we_are/apps.py create mode 100644 app/who_we_are/migrations/__init__.py create mode 100644 app/who_we_are/models.py create mode 100644 app/who_we_are/tests.py create mode 100644 app/who_we_are/views.py diff --git a/app/impact_areas/templates/impact_areas/impact_areas_page.html b/app/impact_areas/templates/impact_areas/impact_areas_page.html index c5867f9..b406d8e 100644 --- a/app/impact_areas/templates/impact_areas/impact_areas_page.html +++ b/app/impact_areas/templates/impact_areas/impact_areas_page.html @@ -13,8 +13,8 @@ {% include "ui/components/BasePageHeader.html" with title=page.title intro=page.intro image=page.image %}
- {% for block in page.impact_area_blocks %} - {% include "ui/components/LearnMoreAboutBlurbWithImage.html" with title=block.value.title description=block.value.description image=block.value.image link=block.value.link %} + {% for child in page.get_children %} + {% include "ui/components/impact_areas/ImpactAreaPreviewBlock.html" with ia=child.specific %} {% endfor %}
{% endblock %} \ No newline at end of file diff --git a/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html new file mode 100644 index 0000000..000b954 --- /dev/null +++ b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html @@ -0,0 +1,26 @@ +{% load wagtailimages_tags %} + +{% image ia.header_image original as image_p %} +
\ No newline at end of file diff --git a/app/who_we_are/__init__.py b/app/who_we_are/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/who_we_are/admin.py b/app/who_we_are/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/who_we_are/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/who_we_are/apps.py b/app/who_we_are/apps.py new file mode 100644 index 0000000..9f7e86b --- /dev/null +++ b/app/who_we_are/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WhoWeAreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'who_we_are' diff --git a/app/who_we_are/migrations/__init__.py b/app/who_we_are/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/who_we_are/models.py b/app/who_we_are/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/app/who_we_are/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/app/who_we_are/tests.py b/app/who_we_are/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/who_we_are/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/who_we_are/views.py b/app/who_we_are/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/who_we_are/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/home/models.py b/home/models.py index 21a59c0..d7580bd 100644 --- a/home/models.py +++ b/home/models.py @@ -210,16 +210,13 @@ def get_context(self, request, *args, **kwargs): FieldPanel('footer_bottom_copyright'), FieldPanel('footer_bottom_links'), ], heading="Navigation"), - MultiFieldPanel( - [ - FieldPanel("image"), - FieldPanel("hero_text"), - FieldPanel("hero_cta"), - FieldPanel("hero_cta_link"), - FieldPanel("carousel"), - ], - heading="Banner", - ), + MultiFieldPanel([ + FieldPanel("image"), + FieldPanel("hero_text"), + FieldPanel("hero_cta"), + FieldPanel("hero_cta_link"), + FieldPanel("carousel"), + ], heading="Banner"), MultiFieldPanel([ FieldPanel('our_work_background'), FieldPanel('our_work_title'), From e050f2f720dcd88f0c27801fcec97e29c3b0e996 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:36:18 -0700 Subject: [PATCH 04/10] impact areas + who we are pages done => impact areas only had a few little things to do so that's all good now => who we are done; takes the "opportunities" section from the home page --- ..._individualimpactareapage_external_icon.py | 20 +++ app/impact_areas/models.py | 2 +- .../components/dogear_boxes/DogearBlack.html | 2 +- .../dogear_boxes/DogearContent.html | 4 + .../ui/components/dogear_boxes/DogearRed.html | 2 +- .../impact_areas/ImpactAreaPreviewBlock.html | 3 +- .../sections/BaseSectionWithImage.html | 35 +++++ .../sections/GreyBackgroundWithImage.html | 5 + .../components/sections/LinkListSection.html | 14 ++ .../sections/NavyBackgroundWithImage.html | 5 + app/who_we_are/apps.py | 2 +- app/who_we_are/migrations/0001_initial.py | 61 ++++++++ .../0002_whowearepage_partners_and_more.py | 43 ++++++ ...earepage_black_box_description_and_more.py | 33 +++++ ...earepage_black_box_description_and_more.py | 24 +++ app/who_we_are/models.py | 140 +++++++++++++++++- .../templates/who_we_are/who_we_are_page.html | 108 ++++++++++++++ .../CheckOutOpportunitiesSection.html | 27 ++++ home/templates/home/home_page.html | 23 +-- hot_osm/settings/base.py | 1 + hot_osm/static/css/hot_osm.css | 4 + 21 files changed, 530 insertions(+), 28 deletions(-) create mode 100644 app/impact_areas/migrations/0015_alter_individualimpactareapage_external_icon.py create mode 100644 app/ui/templates/ui/components/sections/BaseSectionWithImage.html create mode 100644 app/ui/templates/ui/components/sections/GreyBackgroundWithImage.html create mode 100644 app/ui/templates/ui/components/sections/LinkListSection.html create mode 100644 app/ui/templates/ui/components/sections/NavyBackgroundWithImage.html create mode 100644 app/who_we_are/migrations/0001_initial.py create mode 100644 app/who_we_are/migrations/0002_whowearepage_partners_and_more.py create mode 100644 app/who_we_are/migrations/0003_whowearepage_black_box_description_and_more.py create mode 100644 app/who_we_are/migrations/0004_alter_whowearepage_black_box_description_and_more.py create mode 100644 app/who_we_are/templates/who_we_are/who_we_are_page.html create mode 100644 home/templates/home/components/CheckOutOpportunitiesSection.html diff --git a/app/impact_areas/migrations/0015_alter_individualimpactareapage_external_icon.py b/app/impact_areas/migrations/0015_alter_individualimpactareapage_external_icon.py new file mode 100644 index 0000000..1a9ed94 --- /dev/null +++ b/app/impact_areas/migrations/0015_alter_individualimpactareapage_external_icon.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-06-28 23:12 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('impact_areas', '0014_remove_individualimpactareapage_black_dogear_box_link_text_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='individualimpactareapage', + name='external_icon', + field=models.ForeignKey(blank=True, help_text='The icon representing this page which is shown for previews of this page on other pages. This should be a purely black image which is ideally as wide as it is tall.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + ] diff --git a/app/impact_areas/models.py b/app/impact_areas/models.py index d636be8..9e0e9f3 100644 --- a/app/impact_areas/models.py +++ b/app/impact_areas/models.py @@ -62,7 +62,7 @@ def get_context(self, request, *args, **kwargs): blank=True, on_delete=models.SET_NULL, related_name="+", - help_text="The icon representing this page which is shown for previews of this page on other pages." + help_text="The icon representing this page which is shown for previews of this page on other pages. This should be a purely black image which is ideally as wide as it is tall." ) intro_image = models.ForeignKey( "wagtailimages.Image", diff --git a/app/ui/templates/ui/components/dogear_boxes/DogearBlack.html b/app/ui/templates/ui/components/dogear_boxes/DogearBlack.html index dd7a5a2..6a3d2fe 100644 --- a/app/ui/templates/ui/components/dogear_boxes/DogearBlack.html +++ b/app/ui/templates/ui/components/dogear_boxes/DogearBlack.html @@ -5,6 +5,6 @@ - linktext: a string; the text that shows for the link {% endcomment %} -
+
{% include "./DogearContent.html" with color="var(--hot-red)" %}
\ No newline at end of file diff --git a/app/ui/templates/ui/components/dogear_boxes/DogearContent.html b/app/ui/templates/ui/components/dogear_boxes/DogearContent.html index 15e7663..ca842a1 100644 --- a/app/ui/templates/ui/components/dogear_boxes/DogearContent.html +++ b/app/ui/templates/ui/components/dogear_boxes/DogearContent.html @@ -1,6 +1,7 @@ {% comment %} ==> PARAMETERS - title: a string; the title of the box +- description: an html element; a description under the title (optional) - linkurl: a string; the link's url - linktext: a string; the text that shows for the link - color: a string; the color that the caret next to the link text should show as @@ -11,6 +12,9 @@

{{ title }}

+{% if description %} +

{{description|safe}}

+{% endif %}

{{ 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 %} -

+
{% include "./DogearContent.html" %}
\ No newline at end of file diff --git a/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html index 000b954..c96d3d8 100644 --- a/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html +++ b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html @@ -7,6 +7,7 @@

+ {% image ia.external_icon original class="black-image-redifier h-16 w-auto inline" %} {{ ia.title }}

@@ -14,7 +15,7 @@

{{ ia.intro|safe }}

-

+

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 %} + +

\ No newline at end of file diff --git a/app/ui/templates/ui/components/sections/GreyBackgroundWithImage.html b/app/ui/templates/ui/components/sections/GreyBackgroundWithImage.html new file mode 100644 index 0000000..f7fa3ad --- /dev/null +++ b/app/ui/templates/ui/components/sections/GreyBackgroundWithImage.html @@ -0,0 +1,5 @@ +{% load wagtailimages_tags %} + +
+ {% include "./BaseSectionWithImage.html" %} +
\ No newline at end of file diff --git a/app/ui/templates/ui/components/sections/LinkListSection.html b/app/ui/templates/ui/components/sections/LinkListSection.html new file mode 100644 index 0000000..64be542 --- /dev/null +++ b/app/ui/templates/ui/components/sections/LinkListSection.html @@ -0,0 +1,14 @@ +

{{title}}

+
+
+
+ {{description|safe}} +
+
+ {% for link in links %} +

+ {% include "ui/components/BaseLink.html" with linktext=link.value.text linkurl=link.value.link %} +

+ {% endfor %} +
+
\ No newline at end of file diff --git a/app/ui/templates/ui/components/sections/NavyBackgroundWithImage.html b/app/ui/templates/ui/components/sections/NavyBackgroundWithImage.html new file mode 100644 index 0000000..4b66272 --- /dev/null +++ b/app/ui/templates/ui/components/sections/NavyBackgroundWithImage.html @@ -0,0 +1,5 @@ +{% load wagtailimages_tags %} + +
+ {% include "./BaseSectionWithImage.html" %} +
\ No newline at end of file diff --git a/app/who_we_are/apps.py b/app/who_we_are/apps.py index 9f7e86b..3886c18 100644 --- a/app/who_we_are/apps.py +++ b/app/who_we_are/apps.py @@ -3,4 +3,4 @@ class WhoWeAreConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' - name = 'who_we_are' + name = 'app.who_we_are' diff --git a/app/who_we_are/migrations/0001_initial.py b/app/who_we_are/migrations/0001_initial.py new file mode 100644 index 0000000..24fa268 --- /dev/null +++ b/app/who_we_are/migrations/0001_initial.py @@ -0,0 +1,61 @@ +# Generated by Django 4.2.7 on 2024-06-28 19:58 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ] + + operations = [ + migrations.CreateModel( + name='WhoWeArePage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('intro', wagtail.fields.RichTextField(blank=True)), + ('learn_more_button_text', models.CharField(default='Learn More About Our Living Strategy')), + ('learn_more_button_url', models.URLField(blank=True)), + ('intro_info_blocks', wagtail.fields.StreamField([('info_block', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('title', wagtail.blocks.CharBlock(blank=True)), ('description', wagtail.blocks.CharBlock(blank=True))]))], null=True, use_json_field=True)), + ('our_approach_title', models.CharField(default='Our Approach')), + ('our_approach_description', models.CharField(blank=True)), + ('our_approach_button_url', models.URLField(blank=True)), + ('our_approach_button_text', models.CharField(default='Our Approach')), + ('our_people_title', models.CharField(default='Our People')), + ('our_people_description', wagtail.fields.RichTextField(blank=True)), + ('our_people_links', wagtail.fields.StreamField([('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock()), ('link', wagtail.blocks.URLBlock(blank=True))]))], null=True, use_json_field=True)), + ('other_page_preview_blocks', wagtail.fields.StreamField([('other_page_preview', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.blocks.PageChooserBlock())]))], null=True, use_json_field=True)), + ('partners_title', models.CharField(default='Meet Our Partners')), + ('partners_view_all_text', models.CharField(default='View All Partners')), + ('partners_view_all_url', models.URLField(blank=True)), + ('work_hot_title', models.CharField(default='Work for HOT')), + ('work_hot_description', wagtail.fields.RichTextField(blank=True)), + ('work_hot_button_text', models.CharField(default='View all Job Opportunities')), + ('work_hot_button_link', models.URLField(blank=True)), + ('our_policies_title', models.CharField(default='Our Policies')), + ('our_policies_description', wagtail.fields.RichTextField(blank=True)), + ('our_policies_links', wagtail.fields.StreamField([('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock()), ('link', wagtail.blocks.URLBlock(blank=True))]))], null=True, use_json_field=True)), + ('red_box_title', models.CharField(default='Annual Reports')), + ('red_box_link_text', models.CharField(default='Access our annual report archive.')), + ('red_box_link_url', models.URLField(blank=True, null=True)), + ('black_box_title', models.CharField(default='Our Financial Reports')), + ('black_box_link_text', models.CharField(default='Access older financial reports and organization bylaws in our archive.')), + ('black_box_link_url', models.URLField(blank=True, null=True)), + ('header_image', models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ('our_approach_image', models.ForeignKey(blank=True, help_text='Our approach image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ('work_hot_image', models.ForeignKey(blank=True, help_text='Work for HOT section image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/who_we_are/migrations/0002_whowearepage_partners_and_more.py b/app/who_we_are/migrations/0002_whowearepage_partners_and_more.py new file mode 100644 index 0000000..c43c3c2 --- /dev/null +++ b/app/who_we_are/migrations/0002_whowearepage_partners_and_more.py @@ -0,0 +1,43 @@ +# Generated by Django 4.2.7 on 2024-06-28 23:12 + +from django.db import migrations +import modelcluster.fields +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_alter_partner_partner_logo_alter_partner_partner_url'), + ('who_we_are', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='whowearepage', + name='partners', + field=modelcluster.fields.ParentalManyToManyField(blank=True, to='core.partner'), + ), + migrations.AlterField( + model_name='whowearepage', + name='intro_info_blocks', + field=wagtail.fields.StreamField([('info_block', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('title', wagtail.blocks.CharBlock(blank=True)), ('description', wagtail.blocks.RichTextBlock(blank=True, required=False))]))], blank=True, null=True, use_json_field=True), + ), + migrations.AlterField( + model_name='whowearepage', + name='other_page_preview_blocks', + field=wagtail.fields.StreamField([('other_page_preview', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.blocks.PageChooserBlock())]))], blank=True, null=True, use_json_field=True), + ), + migrations.AlterField( + model_name='whowearepage', + name='our_people_links', + field=wagtail.fields.StreamField([('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock()), ('link', wagtail.blocks.URLBlock(blank=True, required=False))]))], blank=True, null=True, use_json_field=True), + ), + migrations.AlterField( + model_name='whowearepage', + name='our_policies_links', + field=wagtail.fields.StreamField([('link_block', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock()), ('link', wagtail.blocks.URLBlock(blank=True, required=False))]))], blank=True, null=True, use_json_field=True), + ), + ] diff --git a/app/who_we_are/migrations/0003_whowearepage_black_box_description_and_more.py b/app/who_we_are/migrations/0003_whowearepage_black_box_description_and_more.py new file mode 100644 index 0000000..5e3cd78 --- /dev/null +++ b/app/who_we_are/migrations/0003_whowearepage_black_box_description_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.7 on 2024-07-02 17:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('who_we_are', '0002_whowearepage_partners_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='whowearepage', + name='black_box_description', + field=models.CharField(default='Access older financial reports and organization bylaws in our archive.'), + ), + migrations.AddField( + model_name='whowearepage', + name='red_box_description', + field=models.CharField(default='Access our annual report archive.'), + ), + migrations.AlterField( + model_name='whowearepage', + name='black_box_link_text', + field=models.CharField(default='Check all Financial Reports'), + ), + migrations.AlterField( + model_name='whowearepage', + name='red_box_link_text', + field=models.CharField(default='Check all Annual Reports'), + ), + ] diff --git a/app/who_we_are/migrations/0004_alter_whowearepage_black_box_description_and_more.py b/app/who_we_are/migrations/0004_alter_whowearepage_black_box_description_and_more.py new file mode 100644 index 0000000..d60c861 --- /dev/null +++ b/app/who_we_are/migrations/0004_alter_whowearepage_black_box_description_and_more.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.7 on 2024-07-02 17:17 + +from django.db import migrations +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('who_we_are', '0003_whowearepage_black_box_description_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='whowearepage', + name='black_box_description', + field=wagtail.fields.RichTextField(default='Access older financial reports and organization bylaws in our archive.'), + ), + migrations.AlterField( + model_name='whowearepage', + name='red_box_description', + field=wagtail.fields.RichTextField(default='Access our annual report archive.'), + ), + ] diff --git a/app/who_we_are/models.py b/app/who_we_are/models.py index 71a8362..721d86c 100644 --- a/app/who_we_are/models.py +++ b/app/who_we_are/models.py @@ -1,3 +1,141 @@ +from django import forms from django.db import models -# Create your models here. +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.images.blocks import ImageChooserBlock + + +class IntroInfoBlock(StructBlock): + image = ImageChooserBlock() + title = CharBlock(blank=True) + description = RichTextBlock(blank=True, required=False) + + +class TextAndLinkBlock(StructBlock): + text = CharBlock() + link = URLBlock(blank=True, required=False) + + +class OtherPagePreviewBlock(StructBlock): + image = ImageChooserBlock() + page = PageChooserBlock() + + +class WhoWeArePage(Page): + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + intro = RichTextField(blank=True) + learn_more_button_text = models.CharField(default="Learn More About Our Living Strategy") + learn_more_button_url = models.URLField(blank=True) + intro_info_blocks = StreamField([('info_block', IntroInfoBlock())], use_json_field=True, null=True, blank=True) + + our_approach_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Our approach image" + ) + our_approach_title = models.CharField(default="Our Approach") + our_approach_description = models.CharField(blank=True) + our_approach_button_url = models.URLField(blank=True) + our_approach_button_text = models.CharField(default="Our Approach") + + our_people_title = models.CharField(default="Our People") + our_people_description = RichTextField(blank=True) + our_people_links = StreamField([('link_block', TextAndLinkBlock())], use_json_field=True, null=True, blank=True) + + other_page_preview_blocks = StreamField([('other_page_preview', OtherPagePreviewBlock())], use_json_field=True, null=True, blank=True) + + partners_title = models.CharField(default="Meet Our Partners") + partners_view_all_text = models.CharField(default="View All Partners") + partners_view_all_url = models.URLField(blank=True) + partners = ParentalManyToManyField('core.Partner', blank=True) + + work_hot_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Work for HOT section image", + ) + work_hot_title = models.CharField(default="Work for HOT") + work_hot_description = RichTextField(blank=True) + work_hot_button_text = models.CharField(default="View all Job Opportunities") + work_hot_button_link = models.URLField(blank=True) + + our_policies_title = models.CharField(default="Our Policies") + our_policies_description = RichTextField(blank=True) + our_policies_links = StreamField([('link_block', TextAndLinkBlock())], use_json_field=True, null=True, blank=True) + + red_box_title = models.CharField(default="Annual Reports") + red_box_description = RichTextField(default="Access our annual report archive.") + red_box_link_text = models.CharField(default="Check all Annual Reports") + red_box_link_url = models.URLField(null=True, blank=True) + black_box_title = models.CharField(default="Our Financial Reports") + black_box_description = RichTextField(default="Access older financial reports and organization bylaws in our archive.") + black_box_link_text = models.CharField(default="Check all Financial Reports") + black_box_link_url = models.URLField(null=True, blank=True) + + content_panels = Page.content_panels + [ + MultiFieldPanel([ + FieldPanel('header_image'), + FieldPanel('intro'), + FieldPanel('learn_more_button_text'), + FieldPanel('learn_more_button_url'), + FieldPanel('intro_info_blocks'), + ], heading="Introduction"), + MultiFieldPanel([ + FieldPanel('our_approach_image'), + FieldPanel('our_approach_title'), + FieldPanel('our_approach_description'), + FieldPanel('our_approach_button_url'), + FieldPanel('our_approach_button_text'), + ], heading="Our Approach"), + MultiFieldPanel([ + FieldPanel('our_people_title'), + FieldPanel('our_people_description'), + FieldPanel('our_people_links'), + ], heading="Our People"), + FieldPanel('other_page_preview_blocks'), + MultiFieldPanel([ + FieldPanel('partners_title'), + FieldPanel('partners_view_all_text'), + FieldPanel('partners_view_all_url'), + FieldPanel('partners', widget=forms.CheckboxSelectMultiple), + ], heading="Partners"), + MultiFieldPanel([ + FieldPanel('work_hot_image'), + FieldPanel('work_hot_title'), + FieldPanel('work_hot_description'), + FieldPanel('work_hot_button_text'), + FieldPanel('work_hot_button_link'), + ], heading="Work for HOT"), + MultiFieldPanel([ + FieldPanel('our_policies_title'), + FieldPanel('our_policies_description'), + FieldPanel('our_policies_links'), + ], heading="Our Policies"), + MultiFieldPanel([ + FieldPanel('red_box_title'), + FieldPanel('red_box_description'), + FieldPanel('red_box_link_text'), + FieldPanel('red_box_link_url'), + FieldPanel('black_box_title'), + FieldPanel('black_box_description'), + FieldPanel('black_box_link_text'), + FieldPanel('black_box_link_url'), + ], heading="Dogear Boxes"), + ] diff --git a/app/who_we_are/templates/who_we_are/who_we_are_page.html b/app/who_we_are/templates/who_we_are/who_we_are_page.html new file mode 100644 index 0000000..0688dee --- /dev/null +++ b/app/who_we_are/templates/who_we_are/who_we_are_page.html @@ -0,0 +1,108 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-individualprojectpage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% comment %} INTRO {% endcomment %} + {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image %} +
+
+
+ + +
+ {% for block in page.intro_info_blocks %} +
+ {% image block.value.image original class="h-10 w-auto" %} +
+

{{block.value.title}}

+ {{block.value.description|safe}} +
+
+ {% endfor %} +
+
+
+
+ + {% comment %} OUR APPROACH {% endcomment %} + {% include "ui/components/sections/NavyBackgroundWithImage.html" with title=page.our_approach_title description=page.our_approach_description button_text=page.our_approach_button_text button_link=page.our_approach_button_url image=page.our_approach_image title_underline=True %} + + {% comment %} OUR PEOPLE {% endcomment %} +
+
+ {% include "ui/components/sections/LinkListSection.html" with title=page.our_people_title description=page.our_people_description links=page.our_people_links %} +
+
+ +
+
+ {% comment %} PAGE PREVIEWS {% endcomment %} +
+ {% for prev in page.other_page_preview_blocks %} + {% image prev.value.image original as previmg %} + +
+
+
+
+

+ {{prev.value.page.title}} +

+
+
+
+ {% endfor %} +
+ + {% comment %} PARTNERS {% endcomment %} +
+
+

+ {{ page.partners_title }} +

+
+
+ +
+ {% include "ui/components/BaseLink.html" with linkurl=page.partners_view_all_url linktext=page.partners_view_all_text %} +
+
+ {% include "ui/components/partners/PartnerViewBlock.html" with partners=page.partners.all %} +
+
+ + {% comment %} OPPORTUNITIES {% endcomment %} + {% include "home/components/CheckOutOpportunitiesSection.html" %} + {% comment %} WORK FOR HOT {% endcomment %} + {% include "ui/components/sections/GreyBackgroundWithImage.html" with image=page.work_hot_image title=page.work_hot_title description=page.work_hot_description button_text=page.work_hot_button_text button_link=page.work_hot_button_url red_button=True %} + +
+
+ {% include "ui/components/sections/LinkListSection.html" with title=page.our_policies_title description=page.our_policies_description links=page.our_policies_links %} +
+
+ +
+
+
+ {% include "ui/components/dogear_boxes/DogearRed.html" with title=page.red_box_title description=page.red_box_description linktext=page.red_box_link_text linkurl=page.red_box_link_url %} + {% include "ui/components/dogear_boxes/DogearBlack.html" with title=page.black_box_title description=page.black_box_description linktext=page.black_box_link_text linkurl=page.black_box_link_url %} +
+
+
+{% endblock %} diff --git a/home/templates/home/components/CheckOutOpportunitiesSection.html b/home/templates/home/components/CheckOutOpportunitiesSection.html new file mode 100644 index 0000000..5e10d54 --- /dev/null +++ b/home/templates/home/components/CheckOutOpportunitiesSection.html @@ -0,0 +1,27 @@ +{% load homepage_tags %} +{% get_home_page as home_page %} +{% load wagtailimages_tags %} + +{% comment %} OPPORTUNITIES {% endcomment %} +
+
+ {% image home_page.opportunities_image original as op_image %} +
+ +
+
diff --git a/home/templates/home/home_page.html b/home/templates/home/home_page.html index 8a5a899..60ed227 100644 --- a/home/templates/home/home_page.html +++ b/home/templates/home/home_page.html @@ -136,28 +136,7 @@

{% comment %} OPPORTUNITIES {% endcomment %} -
- -
+ {% include "home/components/CheckOutOpportunitiesSection.html" %}
{% comment %} NEWS {% endcomment %} diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 2a45387..c5b165c 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -44,6 +44,7 @@ "app.mapping_hubs", "app.members", "app.events", + "app.who_we_are", "search", "users", "utils", diff --git a/hot_osm/static/css/hot_osm.css b/hot_osm/static/css/hot_osm.css index dfc811e..430b76b 100644 --- a/hot_osm/static/css/hot_osm.css +++ b/hot_osm/static/css/hot_osm.css @@ -199,4 +199,8 @@ .bold-override b { font-weight: inherit; +} + +.black-image-redifier { + filter: invert(23%) sepia(93%) saturate(1690%) hue-rotate(340deg) brightness(110%) contrast(81%); } \ No newline at end of file From 8f2bb9b5456deadaeb6383bc5d353d113b3d4176 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:49:39 -0700 Subject: [PATCH 05/10] open mapping hubs page + misc => also restricted child pages of various owner pages --- app/events/models.py | 6 ++++- app/impact_areas/models.py | 4 +++ .../migrations/0009_openmappinghubspage.py | 27 +++++++++++++++++++ ...inghubspage_header_description_and_more.py | 25 +++++++++++++++++ ...1_openmappinghubspage_hub_text_and_more.py | 23 ++++++++++++++++ app/mapping_hubs/models.py | 27 +++++++++++++++++++ .../mapping_hubs/open_mapping_hubs_page.html | 26 ++++++++++++++++++ app/news/models.py | 4 +++ app/programs/models.py | 4 +++ .../ui/components/BasePageHeader.html | 4 +-- .../MappingHubPreviewExtendedBlock.html | 21 +++++++++++++++ app/who_we_are/models.py | 2 ++ home/models.py | 2 ++ 13 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 app/mapping_hubs/migrations/0009_openmappinghubspage.py create mode 100644 app/mapping_hubs/migrations/0010_rename_banner_description_openmappinghubspage_header_description_and_more.py create mode 100644 app/mapping_hubs/migrations/0011_openmappinghubspage_hub_text_and_more.py create mode 100644 app/mapping_hubs/templates/mapping_hubs/open_mapping_hubs_page.html create mode 100644 app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html diff --git a/app/events/models.py b/app/events/models.py index c486579..302fb90 100644 --- a/app/events/models.py +++ b/app/events/models.py @@ -47,6 +47,10 @@ def get_context(self, request, *args, **kwargs): max_count = 1 + subpage_types = [ + 'events.IndividualEventPage' + ] + event_location_title = models.CharField(default="Event Location") join_event_title = models.CharField(default="Join This Event") rsvp_button_text = models.CharField(default="RSVP") @@ -87,7 +91,7 @@ def get_context(self, request, *args, **kwargs): class IndividualEventPage(Page): parent_page_types = [ - 'projects.ProjectOwnerPage' + 'events.EventOwnerPage' ] start_date_time = models.DateTimeField() diff --git a/app/impact_areas/models.py b/app/impact_areas/models.py index 9e0e9f3..4410a28 100644 --- a/app/impact_areas/models.py +++ b/app/impact_areas/models.py @@ -108,6 +108,10 @@ class ImpactAreaBlock(StreamBlock): class ImpactAreasPage(Page): max_count = 1 + subpage_types = [ + 'impact_areas.IndividualImpactAreaPage' + ] + intro = RichTextField(blank=True) image = models.ForeignKey( diff --git a/app/mapping_hubs/migrations/0009_openmappinghubspage.py b/app/mapping_hubs/migrations/0009_openmappinghubspage.py new file mode 100644 index 0000000..0da2ebf --- /dev/null +++ b/app/mapping_hubs/migrations/0009_openmappinghubspage.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.7 on 2024-07-02 18:58 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('mapping_hubs', '0008_alter_individualmappinghubpage_dogear_boxes'), + ] + + operations = [ + migrations.CreateModel( + name='OpenMappingHubsPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('banner_description', wagtail.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/mapping_hubs/migrations/0010_rename_banner_description_openmappinghubspage_header_description_and_more.py b/app/mapping_hubs/migrations/0010_rename_banner_description_openmappinghubspage_header_description_and_more.py new file mode 100644 index 0000000..765e9f6 --- /dev/null +++ b/app/mapping_hubs/migrations/0010_rename_banner_description_openmappinghubspage_header_description_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.7 on 2024-07-02 19:10 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('mapping_hubs', '0009_openmappinghubspage'), + ] + + operations = [ + migrations.RenameField( + model_name='openmappinghubspage', + old_name='banner_description', + new_name='header_description', + ), + migrations.AddField( + model_name='openmappinghubspage', + name='header_image', + field=models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + ] diff --git a/app/mapping_hubs/migrations/0011_openmappinghubspage_hub_text_and_more.py b/app/mapping_hubs/migrations/0011_openmappinghubspage_hub_text_and_more.py new file mode 100644 index 0000000..d70c35b --- /dev/null +++ b/app/mapping_hubs/migrations/0011_openmappinghubspage_hub_text_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2024-07-02 21:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mapping_hubs', '0010_rename_banner_description_openmappinghubspage_header_description_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='openmappinghubspage', + name='hub_text', + field=models.CharField(default='Hub', help_text="The text following a hub's name; i.e., if this field is 'Hub', the title for 'Asia-Pacific' would become 'Asia-Pacific Hub'."), + ), + migrations.AddField( + model_name='openmappinghubspage', + name='learn_more_text', + field=models.CharField(default='Learn More about', help_text="The text preceeding the hub's name in the link text; i.e., if this field is 'Learn More about', the link text for 'Asia-Pacific Hub' would become 'Learn More about Asia-Pacific Hub'."), + ), + ] diff --git a/app/mapping_hubs/models.py b/app/mapping_hubs/models.py index b913f4f..cd7212d 100644 --- a/app/mapping_hubs/models.py +++ b/app/mapping_hubs/models.py @@ -30,6 +30,33 @@ class DogearBoxBlock(StreamBlock): blocks = DogearBoxStructBlock() +class OpenMappingHubsPage(Page): + max_count = 1 + + subpage_types = [ + 'mapping_hubs.IndividualMappingHubPage' + ] + + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image", + ) + header_description = RichTextField(blank=True) + hub_text = models.CharField(default="Hub", help_text="The text following a hub's name; i.e., if this field is 'Hub', the title for 'Asia-Pacific' would become 'Asia-Pacific Hub'.") + learn_more_text = models.CharField(default="Learn More about", help_text="The text preceeding the hub's name in the link text; i.e., if this field is 'Learn More about', the link text for 'Asia-Pacific Hub' would become 'Learn More about Asia-Pacific Hub'.") + + content_panels = Page.content_panels + [ + FieldPanel('header_image'), + FieldPanel('header_description'), + FieldPanel('hub_text'), + FieldPanel('learn_more_text'), + ] + + class IndividualMappingHubPage(Page): def get_context(self, request): context = super().get_context(request) diff --git a/app/mapping_hubs/templates/mapping_hubs/open_mapping_hubs_page.html b/app/mapping_hubs/templates/mapping_hubs/open_mapping_hubs_page.html new file mode 100644 index 0000000..42a07e1 --- /dev/null +++ b/app/mapping_hubs/templates/mapping_hubs/open_mapping_hubs_page.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-openmappinghubspage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image intro=page.header_description %} + +
+
+
+ {% for child in page.get_children %} + {% include "ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html" with hub=child.specific hub_text=page.hub_text learn_more_text=page.learn_more_text %} + {% endfor %} +
+
+
+ + {% include "home/components/CheckOutOpportunitiesSection.html" %} +{% endblock %} diff --git a/app/news/models.py b/app/news/models.py index a58a56d..1152c85 100644 --- a/app/news/models.py +++ b/app/news/models.py @@ -64,6 +64,10 @@ def get_context(self, request, *args, **kwargs): max_count = 1 + subpage_types = [ + 'news.IndividualNewsPage' + ] + authors_posted_by_text = models.CharField(default="Posted by", help_text="The text which appears prior to the authors names; with 'posted by', the text displays as 'posted by [author]'.") authors_posted_on_text = models.CharField(default="on", help_text="The text which appears prior to the date; with 'on', it would display as 'on [date]'.") related_projects_title = models.CharField(default="Related Projects") diff --git a/app/programs/models.py b/app/programs/models.py index 9e55079..a8f252c 100644 --- a/app/programs/models.py +++ b/app/programs/models.py @@ -35,6 +35,10 @@ class ProgramGoalBlock(StreamBlock): class ProgramOwnerPage(Page): max_count = 1 + + subpage_types = [ + 'programs.IndividualProgramPage' + ] stats_title = models.CharField(default="Stats") goals_title = models.CharField(default="Goals") diff --git a/app/ui/templates/ui/components/BasePageHeader.html b/app/ui/templates/ui/components/BasePageHeader.html index 174943a..b536ebf 100644 --- a/app/ui/templates/ui/components/BasePageHeader.html +++ b/app/ui/templates/ui/components/BasePageHeader.html @@ -13,12 +13,12 @@
-

+

{{ title }}

{% if intro %} -
+
{{ intro|safe }}
{% endif %} diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html new file mode 100644 index 0000000..a1e0451 --- /dev/null +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html @@ -0,0 +1,21 @@ +{% load wagtailimages_tags %} + +
+
+ {% image hub.header_image original class="col-start-1 row-start-1 aspect-[2/1] object-cover" %} +
+
+
+
+ {% image hub.main_icon original class="w-14 h-auto" %} +

+ {{hub.title}} {{hub_text}} +

+
+
+ {{hub.intro|safe}} +
+

+ {% include "ui/components/BaseLink.html" with linktext=learn_more_text|add:" "|add:hub.title|add:" "|add:hub_text linkurl=hub.url %} +

+
diff --git a/app/who_we_are/models.py b/app/who_we_are/models.py index 721d86c..f0f2029 100644 --- a/app/who_we_are/models.py +++ b/app/who_we_are/models.py @@ -26,6 +26,8 @@ class OtherPagePreviewBlock(StructBlock): class WhoWeArePage(Page): + max_count = 1 + header_image = models.ForeignKey( "wagtailimages.Image", null=True, diff --git a/home/models.py b/home/models.py index d7580bd..8b2da06 100644 --- a/home/models.py +++ b/home/models.py @@ -58,6 +58,8 @@ def get_context(self, request, *args, **kwargs): context['mapping_hubs'] = mapping_hubs return context + max_count = 1 + templates = "home/home_page.html" # Navigation From eed2dcb74d57de417259d03632a1d5ae2be88bb2 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:12:37 -0700 Subject: [PATCH 06/10] get involved page done => still needs links of course but besides that --- app/get_involved/__init__.py | 0 app/get_involved/admin.py | 3 + app/get_involved/apps.py | 6 + app/get_involved/migrations/0001_initial.py | 26 ++++ ...volvedpage_black_box_link_text_and_more.py | 133 ++++++++++++++++++ ...edpage_join_us_panel_read_more_and_more.py | 26 ++++ app/get_involved/migrations/__init__.py | 0 app/get_involved/models.py | 99 +++++++++++++ .../get_involved/get_involved_page.html | 62 ++++++++ app/get_involved/tests.py | 3 + app/get_involved/views.py | 3 + app/mapping_hubs/models.py | 3 +- .../ui/components/FlexTitleWithLink.html | 8 ++ .../ui/components/TitleWithUnderline.html | 4 + .../dogear_boxes/DogearAnyColourLong.html | 4 +- .../misc_panels/LinkBlockWithImage.html | 12 ++ .../misc_panels/PagePreviewBasic.html | 14 ++ .../PagePreviewWithTabletDescription.html | 24 ++++ .../templates/who_we_are/who_we_are_page.html | 13 +- hot_osm/settings/base.py | 1 + 20 files changed, 429 insertions(+), 15 deletions(-) create mode 100644 app/get_involved/__init__.py create mode 100644 app/get_involved/admin.py create mode 100644 app/get_involved/apps.py create mode 100644 app/get_involved/migrations/0001_initial.py create mode 100644 app/get_involved/migrations/0002_getinvolvedpage_black_box_link_text_and_more.py create mode 100644 app/get_involved/migrations/0003_getinvolvedpage_join_us_panel_read_more_and_more.py create mode 100644 app/get_involved/migrations/__init__.py create mode 100644 app/get_involved/models.py create mode 100644 app/get_involved/templates/get_involved/get_involved_page.html create mode 100644 app/get_involved/tests.py create mode 100644 app/get_involved/views.py create mode 100644 app/ui/templates/ui/components/FlexTitleWithLink.html create mode 100644 app/ui/templates/ui/components/TitleWithUnderline.html create mode 100644 app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html create mode 100644 app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html create mode 100644 app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html diff --git a/app/get_involved/__init__.py b/app/get_involved/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/get_involved/admin.py b/app/get_involved/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/get_involved/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/get_involved/apps.py b/app/get_involved/apps.py new file mode 100644 index 0000000..49f491e --- /dev/null +++ b/app/get_involved/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class GetInvolvedConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'app.get_involved' diff --git a/app/get_involved/migrations/0001_initial.py b/app/get_involved/migrations/0001_initial.py new file mode 100644 index 0000000..7a8ff1a --- /dev/null +++ b/app/get_involved/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.7 on 2024-07-03 18:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ] + + operations = [ + migrations.CreateModel( + name='GetInvolvedPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/get_involved/migrations/0002_getinvolvedpage_black_box_link_text_and_more.py b/app/get_involved/migrations/0002_getinvolvedpage_black_box_link_text_and_more.py new file mode 100644 index 0000000..b32523d --- /dev/null +++ b/app/get_involved/migrations/0002_getinvolvedpage_black_box_link_text_and_more.py @@ -0,0 +1,133 @@ +# Generated by Django 4.2.7 on 2024-07-03 19:30 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('get_involved', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='getinvolvedpage', + name='black_box_link_text', + field=models.CharField(default='Contact Us'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='black_box_link_url', + field=models.URLField(blank=True, null=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='black_box_title', + field=models.CharField(default='Stay in Touch'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='dogear_box_link_text', + field=models.CharField(default='Contact by Country'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='dogear_box_link_url', + field=models.URLField(blank=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='dogear_box_title', + field=models.CharField(default='Connect with our OSM community!'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='events', + field=wagtail.fields.StreamField([('event', wagtail.blocks.PageChooserBlock(page_type=['events.IndividualEventPage']))], blank=True, null=True, use_json_field=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='events_title', + field=models.CharField(default='Events'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='get_involved_community_title', + field=models.CharField(default='Get Involved in Our Community'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='get_involved_large_panels', + field=wagtail.fields.StreamField([('panel', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('title', wagtail.blocks.CharBlock()), ('description', wagtail.blocks.RichTextBlock()), ('link_text', wagtail.blocks.CharBlock()), ('link_url', wagtail.blocks.URLBlock(required=False))]))], blank=True, null=True, use_json_field=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='header_image', + field=models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='join_us_panels', + field=wagtail.fields.StreamField([('panel', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.blocks.PageChooserBlock())]))], blank=True, null=True, use_json_field=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='join_us_title', + field=models.CharField(default='Join Us'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='partner_with_us_button_link', + field=models.URLField(blank=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='partner_with_us_button_text', + field=models.CharField(default='Partner With Us'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='partner_with_us_description', + field=wagtail.fields.RichTextField(blank=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='partner_with_us_image', + field=models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='partner_with_us_title', + field=models.CharField(default='Partner With Us!'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='red_box_link_text', + field=models.CharField(default='Donate Today'), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='red_box_link_url', + field=models.URLField(blank=True, null=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='red_box_title', + field=models.CharField(default="Support HOT's work!"), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='view_all_events_link', + field=models.URLField(blank=True), + ), + migrations.AddField( + model_name='getinvolvedpage', + name='view_all_events_text', + field=models.CharField(default='View all Events'), + ), + ] diff --git a/app/get_involved/migrations/0003_getinvolvedpage_join_us_panel_read_more_and_more.py b/app/get_involved/migrations/0003_getinvolvedpage_join_us_panel_read_more_and_more.py new file mode 100644 index 0000000..f362606 --- /dev/null +++ b/app/get_involved/migrations/0003_getinvolvedpage_join_us_panel_read_more_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.7 on 2024-07-03 23:20 + +from django.db import migrations, models +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('get_involved', '0002_getinvolvedpage_black_box_link_text_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='getinvolvedpage', + name='join_us_panel_read_more', + field=models.CharField(default='Read More'), + ), + migrations.AlterField( + model_name='getinvolvedpage', + name='join_us_panels', + field=wagtail.fields.StreamField([('panel', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.blocks.PageChooserBlock()), ('tablet_description', wagtail.blocks.RichTextBlock(blank=True, required=False))]))], blank=True, null=True, use_json_field=True), + ), + ] diff --git a/app/get_involved/migrations/__init__.py b/app/get_involved/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/get_involved/models.py b/app/get_involved/models.py new file mode 100644 index 0000000..8ba7adc --- /dev/null +++ b/app/get_involved/models.py @@ -0,0 +1,99 @@ +from django.db import models + +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 wagtail.images.blocks import ImageChooserBlock +from modelcluster.fields import ParentalKey, ParentalManyToManyField + + +class GetInvolvedLargePanel(StructBlock): + image = ImageChooserBlock() + title = CharBlock() + description = RichTextBlock() + link_text = CharBlock() + link_url = URLBlock(required=False) + + +class JoinUsPanel(StructBlock): + image = ImageChooserBlock() + page = PageChooserBlock() + tablet_description = RichTextBlock(required=False, blank=True) + + +class GetInvolvedPage(Page): + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + + partner_with_us_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + partner_with_us_title = models.CharField(default="Partner With Us!") + partner_with_us_description = RichTextField(blank=True) + partner_with_us_button_text = models.CharField(default="Partner With Us") + partner_with_us_button_link = models.URLField(blank=True) + + get_involved_community_title = models.CharField(default="Get Involved in Our Community") + get_involved_large_panels = StreamField([('panel', GetInvolvedLargePanel())], use_json_field=True, blank=True, null=True) + dogear_box_title = models.CharField(default="Connect with our OSM community!") + dogear_box_link_text = models.CharField(default="Contact by Country") + dogear_box_link_url = models.URLField(blank=True) + events_title = models.CharField(default="Events") + view_all_events_text = models.CharField(default="View all Events") + view_all_events_link = models.URLField(blank=True) + events = StreamField([('event', PageChooserBlock(page_type="events.IndividualEventPage"))], use_json_field=True, null=True, blank=True, max_num=3) + + join_us_title = models.CharField(default="Join Us") + join_us_panels = StreamField([('panel', JoinUsPanel())], use_json_field=True, blank=True, null=True) + join_us_panel_read_more = models.CharField(default="Read More") + red_box_title = models.CharField(default="Support HOT's work!") + red_box_link_text = models.CharField(default="Donate Today") + red_box_link_url = models.URLField(null=True, blank=True) + black_box_title = models.CharField(default="Stay in Touch") + black_box_link_text = models.CharField(default="Contact Us") + black_box_link_url = models.URLField(null=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('header_image'), + MultiFieldPanel([ + FieldPanel('partner_with_us_image'), + FieldPanel('partner_with_us_title'), + FieldPanel('partner_with_us_description'), + FieldPanel('partner_with_us_button_text'), + FieldPanel('partner_with_us_button_link'), + ], heading="Partner With Us"), + MultiFieldPanel([ + FieldPanel('get_involved_community_title'), + FieldPanel('get_involved_large_panels'), + FieldPanel('dogear_box_title'), + FieldPanel('dogear_box_link_text'), + FieldPanel('dogear_box_link_url'), + FieldPanel('events_title'), + FieldPanel('view_all_events_text'), + FieldPanel('view_all_events_link'), + FieldPanel('events'), + ], heading="Get Involved in Our Community"), + MultiFieldPanel([ + FieldPanel('join_us_title'), + FieldPanel('join_us_panels'), + FieldPanel('join_us_panel_read_more'), + FieldPanel('red_box_title'), + FieldPanel('red_box_link_text'), + FieldPanel('red_box_link_url'), + FieldPanel('black_box_title'), + FieldPanel('black_box_link_text'), + FieldPanel('black_box_link_url'), + ], heading="Bottom Area"), + ] diff --git a/app/get_involved/templates/get_involved/get_involved_page.html b/app/get_involved/templates/get_involved/get_involved_page.html new file mode 100644 index 0000000..d23abf0 --- /dev/null +++ b/app/get_involved/templates/get_involved/get_involved_page.html @@ -0,0 +1,62 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-getinvolvedpage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image %} +
+ {% include "ui/components/sections/BaseSectionWithImage.html" with title=page.partner_with_us_title image=page.partner_with_us_image imageright=True title_underline=True red_button=True button_text=page.partner_with_us_button_text button_link=page.partner_with_us_button_link description=page.partner_with_us_description %} +
+ +
+
+
+ {% include "ui/components/TitleWithUnderline.html" with title=page.get_involved_community_title %} +
+ {% for panel in page.get_involved_large_panels %} + {% include "ui/components/misc_panels/LinkBlockWithImage.html" with title=panel.value.title image=panel.value.image description=panel.value.description linktext=panel.value.link_text linkurl=panel.value.link_url %} + {% endfor %} +
+ +
+ {% include "ui/components/dogear_boxes/DogearAnyColourLong.html" with title=page.dogear_box_title linktext=page.dogear_box_link_text linkurl=page.dogear_box_link_url textcolour="black" colour="var(--hot-light-grey)" arrowcolour="black" %} +
+ + {% include "ui/components/FlexTitleWithLink.html" with title=page.events_title linktext=page.view_all_events_text linkurl=page.view_all_events_link class="my-4" %} +
+ {% for event in page.events %} + {% include "ui/components/events/EventPreviewBlockEvent.html" with event=event.value showimage=True %} + {% endfor %} +
+
+
+
+ +
+
+ {% include "ui/components/TitleWithUnderline.html" with title=page.join_us_title %} + +
+ {% for panel in page.join_us_panels %} + {% include "ui/components/misc_panels/PagePreviewWithTabletDescription.html" with image=panel.value.image page=panel.value.page tablet_description=panel.value.tablet_description read_more_text=page.join_us_panel_read_more %} + {% endfor %} +
+ +
+
+ {% include "ui/components/dogear_boxes/DogearRed.html" with title=page.red_box_title linktext=page.red_box_link_text linkurl=page.red_box_link_url %} +
+
+ {% include "ui/components/dogear_boxes/DogearBlack.html" with title=page.black_box_title linktext=page.black_box_link_text linkurl=page.black_box_link_url %} +
+
+
+
+{% endblock %} diff --git a/app/get_involved/tests.py b/app/get_involved/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/get_involved/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/get_involved/views.py b/app/get_involved/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/get_involved/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/mapping_hubs/models.py b/app/mapping_hubs/models.py index cd7212d..3daabad 100644 --- a/app/mapping_hubs/models.py +++ b/app/mapping_hubs/models.py @@ -60,7 +60,8 @@ class OpenMappingHubsPage(Page): class IndividualMappingHubPage(Page): def get_context(self, request): context = super().get_context(request) - projects = context['page'].get_children()[0].get_children().filter(locale=context['page'].locale) + projects = context['page'].get_children() + projects = projects[0].get_children().filter(locale=context['page'].locale) if projects else None context['projects'] = projects other_hubs = IndividualMappingHubPage.objects.live().filter(locale=context['page'].locale) context['other_hubs'] = other_hubs diff --git a/app/ui/templates/ui/components/FlexTitleWithLink.html b/app/ui/templates/ui/components/FlexTitleWithLink.html new file mode 100644 index 0000000..0f23d2a --- /dev/null +++ b/app/ui/templates/ui/components/FlexTitleWithLink.html @@ -0,0 +1,8 @@ +
+

+ {{title}} +

+

+ {% include "ui/components/BaseLink.html" %} +

+
\ No newline at end of file diff --git a/app/ui/templates/ui/components/TitleWithUnderline.html b/app/ui/templates/ui/components/TitleWithUnderline.html new file mode 100644 index 0000000..065f351 --- /dev/null +++ b/app/ui/templates/ui/components/TitleWithUnderline.html @@ -0,0 +1,4 @@ +

+ {{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 %} + +
+ {% image image original class="aspect-[2/1] object-cover" %} +

{{title}}

+
+ {{description}} +
+

+ {% include "ui/components/BaseLink.html" %} +

+
\ No newline at end of file diff --git a/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html b/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html new file mode 100644 index 0000000..2bebce6 --- /dev/null +++ b/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html @@ -0,0 +1,14 @@ +{% load wagtailimages_tags %} + +{% image image original as previmg %} + +
+
+
+
+

+ {{page.title}} +

+
+
+
\ No newline at end of file diff --git a/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html b/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html new file mode 100644 index 0000000..01f4a60 --- /dev/null +++ b/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html @@ -0,0 +1,24 @@ +{% load wagtailimages_tags %} + +{% image image original as previmg %} + +
+
+
+ +
+
+

{{page.title}}

+
+ {{tablet_description}} +
+

+ {{read_more_text}} + {% include "ui/components/icon_svgs/LinkCaret.html" with class="ml-2" %} +

+
+
\ No newline at end of file diff --git a/app/who_we_are/templates/who_we_are/who_we_are_page.html b/app/who_we_are/templates/who_we_are/who_we_are_page.html index 0688dee..8acaf8d 100644 --- a/app/who_we_are/templates/who_we_are/who_we_are_page.html +++ b/app/who_we_are/templates/who_we_are/who_we_are_page.html @@ -54,18 +54,7 @@

{{block.value.title}}

{% comment %} PAGE PREVIEWS {% endcomment %}
{% for prev in page.other_page_preview_blocks %} - {% image prev.value.image original as previmg %} - -
-
-
-
-

- {{prev.value.page.title}} -

-
-
-
+ {% include "ui/components/misc_panels/PagePreviewBasic.html" with page=prev.value.page image=prev.value.image %} {% endfor %}
diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index c5b165c..5647702 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -45,6 +45,7 @@ "app.members", "app.events", "app.who_we_are", + "app.get_involved", "search", "users", "utils", From a0a2f43e44a539606a2e559c173c71a60ac1afb4 Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:00:52 -0700 Subject: [PATCH 07/10] tools and resources page done + projects misc => projects now can have multiple hubs attached, page structure changed once more --- app/get_involved/models.py | 2 + .../get_involved/get_involved_page.html | 2 +- .../migrations/0012_mappinghubprojectspage.py | 33 ++++++ ...ojectspage_black_box_link_text_and_more.py | 33 ++++++ app/mapping_hubs/models.py | 49 ++++++++- .../components/projects_header.html} | 0 .../mapping_hub_projects_page.html | 61 +++++++++++ ...4_individualprojectpage_region_hub_list.py | 20 ++++ .../0025_projectownerpage_header_image.py | 20 ++++ app/projects/models.py | 20 +++- .../projects/individual_project_page.html | 4 +- .../projects/project_owner_page.html | 2 +- app/tools_and_resources/__init__.py | 0 app/tools_and_resources/admin.py | 3 + app/tools_and_resources/apps.py | 6 ++ .../migrations/0001_initial.py | 52 +++++++++ ...resourcespage_get_connected_button_text.py | 18 ++++ .../migrations/__init__.py | 0 app/tools_and_resources/models.py | 100 ++++++++++++++++++ .../tools_and_resources_page.html | 67 ++++++++++++ app/tools_and_resources/tests.py | 3 + app/tools_and_resources/views.py | 3 + .../mapping_hub/MappingHubPreviewBlock.html | 8 +- .../MappingHubPreviewBlockBase.html | 14 +++ .../projects/ProjectPreviewBlockMapHub.html | 6 +- .../sections/BaseSectionWithImage.html | 2 +- hot_osm/settings/base.py | 1 + 27 files changed, 509 insertions(+), 20 deletions(-) create mode 100644 app/mapping_hubs/migrations/0012_mappinghubprojectspage.py create mode 100644 app/mapping_hubs/migrations/0013_alter_mappinghubprojectspage_black_box_link_text_and_more.py rename app/{projects/templates/projects/components/header.html => mapping_hubs/templates/mapping_hubs/components/projects_header.html} (100%) create mode 100644 app/mapping_hubs/templates/mapping_hubs/mapping_hub_projects_page.html create mode 100644 app/projects/migrations/0024_individualprojectpage_region_hub_list.py create mode 100644 app/projects/migrations/0025_projectownerpage_header_image.py create mode 100644 app/tools_and_resources/__init__.py create mode 100644 app/tools_and_resources/admin.py create mode 100644 app/tools_and_resources/apps.py create mode 100644 app/tools_and_resources/migrations/0001_initial.py create mode 100644 app/tools_and_resources/migrations/0002_alter_toolsandresourcespage_get_connected_button_text.py create mode 100644 app/tools_and_resources/migrations/__init__.py create mode 100644 app/tools_and_resources/models.py create mode 100644 app/tools_and_resources/templates/tools_and_resources/tools_and_resources_page.html create mode 100644 app/tools_and_resources/tests.py create mode 100644 app/tools_and_resources/views.py create mode 100644 app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html diff --git a/app/get_involved/models.py b/app/get_involved/models.py index 8ba7adc..2cb2356 100644 --- a/app/get_involved/models.py +++ b/app/get_involved/models.py @@ -23,6 +23,8 @@ class JoinUsPanel(StructBlock): class GetInvolvedPage(Page): + max_count = 1 + header_image = models.ForeignKey( "wagtailimages.Image", null=True, diff --git a/app/get_involved/templates/get_involved/get_involved_page.html b/app/get_involved/templates/get_involved/get_involved_page.html index d23abf0..7343149 100644 --- a/app/get_involved/templates/get_involved/get_involved_page.html +++ b/app/get_involved/templates/get_involved/get_involved_page.html @@ -12,7 +12,7 @@ {% block content %} {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image %}
- {% include "ui/components/sections/BaseSectionWithImage.html" with title=page.partner_with_us_title image=page.partner_with_us_image imageright=True title_underline=True red_button=True button_text=page.partner_with_us_button_text button_link=page.partner_with_us_button_link description=page.partner_with_us_description %} + {% include "ui/components/sections/BaseSectionWithImage.html" with title=page.partner_with_us_title image=page.partner_with_us_image imageright=True title_underline=True red_button=True button_text=page.partner_with_us_button_text button_link=page.partner_with_us_button_link description=page.partner_with_us_description imagenotwide=True imagebottom=True%}
diff --git a/app/mapping_hubs/migrations/0012_mappinghubprojectspage.py b/app/mapping_hubs/migrations/0012_mappinghubprojectspage.py new file mode 100644 index 0000000..fca3cc1 --- /dev/null +++ b/app/mapping_hubs/migrations/0012_mappinghubprojectspage.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.7 on 2024-07-04 22:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('mapping_hubs', '0011_openmappinghubspage_hub_text_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='MappingHubProjectsPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('load_more_projects_text', models.CharField(default='Load More Projects')), + ('projects_by_hub_title', models.CharField(default='See Projects by Open Mapping Hub')), + ('red_box_title', models.CharField(default='Start Mapping')), + ('red_box_link_text', models.CharField(default='Start Mapping')), + ('red_box_link_url', models.URLField(blank=True, null=True)), + ('black_box_title', models.CharField(default='Check many opportunities to get involved with HOT!')), + ('black_box_link_text', models.CharField(default='Get Involved with HOT')), + ('black_box_link_url', models.URLField(blank=True, null=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/mapping_hubs/migrations/0013_alter_mappinghubprojectspage_black_box_link_text_and_more.py b/app/mapping_hubs/migrations/0013_alter_mappinghubprojectspage_black_box_link_text_and_more.py new file mode 100644 index 0000000..929575f --- /dev/null +++ b/app/mapping_hubs/migrations/0013_alter_mappinghubprojectspage_black_box_link_text_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.7 on 2024-07-04 23:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mapping_hubs', '0012_mappinghubprojectspage'), + ] + + operations = [ + migrations.AlterField( + model_name='mappinghubprojectspage', + name='black_box_link_text', + field=models.CharField(default='Get involved'), + ), + migrations.AlterField( + model_name='mappinghubprojectspage', + name='black_box_title', + field=models.CharField(default='See the many ways to get involved with HOT and open mapping'), + ), + migrations.AlterField( + model_name='mappinghubprojectspage', + name='red_box_link_text', + field=models.CharField(default='Explore projects'), + ), + migrations.AlterField( + model_name='mappinghubprojectspage', + name='red_box_title', + field=models.CharField(default="See all of HOT's projects"), + ), + ] diff --git a/app/mapping_hubs/models.py b/app/mapping_hubs/models.py index 3daabad..1f79b86 100644 --- a/app/mapping_hubs/models.py +++ b/app/mapping_hubs/models.py @@ -1,5 +1,6 @@ from django import forms from django.db import models +from django.db.models import Q from wagtail.models import Page from wagtail.fields import RichTextField, StreamField @@ -30,6 +31,49 @@ class DogearBoxBlock(StreamBlock): blocks = DogearBoxStructBlock() +class MappingHubProjectsPage(Page): + def get_context(self, request): + context = super().get_context(request) + + parent_hub = context['page'].get_parent() + + projects = IndividualProjectPage.objects.live().filter( + Q(region_hub_list__contains=[{'type': 'region_hub', 'value': parent_hub.id}]) + ).filter(locale=context['page'].locale) + + other_hubs_projects = MappingHubProjectsPage.objects.live().filter(locale=context['page'].locale) + + context['projects'] = projects + context['other_hubs'] = other_hubs_projects + return context + + parent_page_types = [ + 'mapping_hubs.IndividualMappingHubPage' + ] + + load_more_projects_text = models.CharField(default="Load More Projects") + + projects_by_hub_title = models.CharField(default="See Projects by Open Mapping Hub") + + red_box_title = models.CharField(default="See all of HOT's projects") + red_box_link_text = models.CharField(default="Explore projects") + red_box_link_url = models.URLField(null=True, blank=True) + black_box_title = models.CharField(default="See the many ways to get involved with HOT and open mapping") + black_box_link_text = models.CharField(default="Get involved") + black_box_link_url = models.URLField(null=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('load_more_projects_text'), + FieldPanel('projects_by_hub_title'), + FieldPanel('red_box_title'), + FieldPanel('red_box_link_text'), + FieldPanel('red_box_link_url'), + FieldPanel('black_box_title'), + FieldPanel('black_box_link_text'), + FieldPanel('black_box_link_url'), + ] + + class OpenMappingHubsPage(Page): max_count = 1 @@ -60,8 +104,9 @@ class OpenMappingHubsPage(Page): class IndividualMappingHubPage(Page): def get_context(self, request): context = super().get_context(request) - projects = context['page'].get_children() - projects = projects[0].get_children().filter(locale=context['page'].locale) if projects else None + projects = IndividualProjectPage.objects.live().filter( + Q(region_hub_list__contains=[{'type': 'region_hub', 'value': context['page'].id}]) + ).filter(locale=context['page'].locale) context['projects'] = projects other_hubs = IndividualMappingHubPage.objects.live().filter(locale=context['page'].locale) context['other_hubs'] = other_hubs diff --git a/app/projects/templates/projects/components/header.html b/app/mapping_hubs/templates/mapping_hubs/components/projects_header.html similarity index 100% rename from app/projects/templates/projects/components/header.html rename to app/mapping_hubs/templates/mapping_hubs/components/projects_header.html diff --git a/app/mapping_hubs/templates/mapping_hubs/mapping_hub_projects_page.html b/app/mapping_hubs/templates/mapping_hubs/mapping_hub_projects_page.html new file mode 100644 index 0000000..40b6eba --- /dev/null +++ b/app/mapping_hubs/templates/mapping_hubs/mapping_hub_projects_page.html @@ -0,0 +1,61 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-mappinghubprojectspage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "./components/projects_header.html" %} +
+
+
+ {% for project in projects %} + {% include "ui/components/projects/ProjectPreviewBlockNews.html" with project=project.specific showimage=True %} + {% endfor %} +
+

+ {% if projects.has_next %} + {% comment %} {% endcomment %} + + {% endif %} +

+ +

+ {{page.projects_by_hub_title}} +

+
+ {% for hub in other_hubs %} + {% if hub != page %} + + {% include "ui/components/mapping_hub/MappingHubPreviewBlockBase.html" with hub=hub.get_parent.specific %} + + {% endif %} + {% endfor %} +
+ +
+
+ {% include "ui/components/dogear_boxes/DogearRed.html" with title=page.red_box_title linktext=page.red_box_link_text linkurl=page.red_box_link_url %} +
+
+ {% include "ui/components/dogear_boxes/DogearBlack.html" with title=page.black_box_title linktext=page.black_box_link_text linkurl=page.black_box_link_url %} +
+
+
+
+{% endblock %} diff --git a/app/projects/migrations/0024_individualprojectpage_region_hub_list.py b/app/projects/migrations/0024_individualprojectpage_region_hub_list.py new file mode 100644 index 0000000..e1e2261 --- /dev/null +++ b/app/projects/migrations/0024_individualprojectpage_region_hub_list.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-07-04 18:38 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0023_remove_individualprojectpage_owner_region_hub'), + ] + + operations = [ + migrations.AddField( + model_name='individualprojectpage', + name='region_hub_list', + field=wagtail.fields.StreamField([('region_hub', wagtail.blocks.PageChooserBlock(page_type=['mapping_hubs.IndividualMappingHubPage']))], blank=True, null=True, use_json_field=True), + ), + ] diff --git a/app/projects/migrations/0025_projectownerpage_header_image.py b/app/projects/migrations/0025_projectownerpage_header_image.py new file mode 100644 index 0000000..15e07d8 --- /dev/null +++ b/app/projects/migrations/0025_projectownerpage_header_image.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-07-04 23:02 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('projects', '0024_individualprojectpage_region_hub_list'), + ] + + operations = [ + migrations.AddField( + model_name='projectownerpage', + name='header_image', + field=models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + ] diff --git a/app/projects/models.py b/app/projects/models.py index 6a12032..a4f6209 100644 --- a/app/projects/models.py +++ b/app/projects/models.py @@ -31,14 +31,21 @@ def get_context(self, request, *args, **kwargs): context['projects'] = projects return context - parent_page_types = [ - 'mapping_hubs.IndividualMappingHubPage' - ] + max_count = 1 subpage_types = [ 'projects.IndividualProjectPage' ] + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + load_more_projects_text = models.CharField(default="Load More Projects") impact_areas_title = models.CharField(default="Impact Areas") @@ -64,8 +71,9 @@ def get_context(self, request, *args, **kwargs): content_panels = Page.content_panels + [ MultiFieldPanel([ + FieldPanel('header_image'), FieldPanel('load_more_projects_text'), - ], heading="Project Open Mapping Hub Page"), + ], heading="Project Page"), MultiFieldPanel([ MultiFieldPanel([ FieldPanel('impact_areas_title'), @@ -104,6 +112,7 @@ class IndividualProjectPage(Page): parent_page_types = [ 'projects.ProjectOwnerPage' ] + # > HEADER owner_program = models.ForeignKey( 'wagtailcore.Page', @@ -138,6 +147,8 @@ class IndividualProjectPage(Page): # > SIDE BAR impact_area_list = StreamField([('impact_area', PageChooserBlock(page_type="impact_areas.IndividualImpactAreaPage"))], use_json_field=True, null=True, blank=True) + region_hub_list = StreamField([('region_hub', PageChooserBlock(page_type="mapping_hubs.IndividualMappingHubPage"))], use_json_field=True, null=True, blank=True) + duration = models.CharField(default="Ongoing", blank=True) partners_list = ParentalManyToManyField('core.Partner', blank=True) @@ -174,6 +185,7 @@ class IndividualProjectPage(Page): ], heading="Body"), MultiFieldPanel([ FieldPanel('impact_area_list'), + FieldPanel('region_hub_list'), FieldPanel('duration'), FieldPanel('partners_list', widget=forms.CheckboxSelectMultiple), FieldPanel('tools'), diff --git a/app/projects/templates/projects/individual_project_page.html b/app/projects/templates/projects/individual_project_page.html index 2cc3b2c..1db1a43 100644 --- a/app/projects/templates/projects/individual_project_page.html +++ b/app/projects/templates/projects/individual_project_page.html @@ -37,7 +37,9 @@

{{page.get_parent.specific.region_hub_title}}

-

{{page.get_parent.get_parent.title}}

+ {% for hub in page.region_hub_list %} +

{{hub.value.title}}

+ {% endfor %}

{{page.get_parent.specific.duration_title}}

diff --git a/app/projects/templates/projects/project_owner_page.html b/app/projects/templates/projects/project_owner_page.html index 0191b6e..f110ee2 100644 --- a/app/projects/templates/projects/project_owner_page.html +++ b/app/projects/templates/projects/project_owner_page.html @@ -10,7 +10,7 @@ {% endblock extra_css %} {% block content %} - {% include "./components/header.html" %} + {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image %}
diff --git a/app/tools_and_resources/__init__.py b/app/tools_and_resources/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/tools_and_resources/admin.py b/app/tools_and_resources/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/tools_and_resources/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/tools_and_resources/apps.py b/app/tools_and_resources/apps.py new file mode 100644 index 0000000..236d5fe --- /dev/null +++ b/app/tools_and_resources/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ToolsAndResourcesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'app.tools_and_resources' diff --git a/app/tools_and_resources/migrations/0001_initial.py b/app/tools_and_resources/migrations/0001_initial.py new file mode 100644 index 0000000..ba742b4 --- /dev/null +++ b/app/tools_and_resources/migrations/0001_initial.py @@ -0,0 +1,52 @@ +# Generated by Django 4.2.7 on 2024-07-04 17:17 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ] + + operations = [ + migrations.CreateModel( + name='ToolsAndResourcesPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('intro_header', models.CharField(blank=True)), + ('intro', wagtail.fields.RichTextField(blank=True)), + ('description', wagtail.fields.RichTextField(blank=True)), + ('learn_more_data_principles_text', models.CharField(default='Learn about our Data & Principles')), + ('learn_more_data_principles_link', models.URLField(blank=True)), + ('large_panels', wagtail.fields.StreamField([('panel', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('title', wagtail.blocks.CharBlock()), ('description', wagtail.blocks.RichTextBlock()), ('link_text', wagtail.blocks.CharBlock()), ('link_url', wagtail.blocks.URLBlock(required=False))]))], blank=True, null=True, use_json_field=True)), + ('resource_learning_title', models.CharField(default='Resource and Learning Centre')), + ('resource_learning_description', wagtail.fields.RichTextField(blank=True)), + ('get_connected_button_text', models.CharField(default='Get connect now')), + ('get_connected_button_link', models.URLField(blank=True)), + ('dogear_tech_news_title', models.CharField(blank=True)), + ('dogear_tech_news_link_text', models.CharField(default='View our Tech News')), + ('dogear_tech_news_link_url', models.URLField(blank=True)), + ('red_box_title', models.CharField(default='Start Mapping')), + ('red_box_link_text', models.CharField(default='Start Mapping')), + ('red_box_link_url', models.URLField(blank=True, null=True)), + ('black_box_title', models.CharField(default='Check many opportunities to get involved with HOT!')), + ('black_box_link_text', models.CharField(default='Get Involved with HOT')), + ('black_box_link_url', models.URLField(blank=True, null=True)), + ('header_image', models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ('intro_image', models.ForeignKey(blank=True, help_text='Intro image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ('resource_learning_image', models.ForeignKey(blank=True, help_text='Resource and Learning Centre image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/tools_and_resources/migrations/0002_alter_toolsandresourcespage_get_connected_button_text.py b/app/tools_and_resources/migrations/0002_alter_toolsandresourcespage_get_connected_button_text.py new file mode 100644 index 0000000..c974feb --- /dev/null +++ b/app/tools_and_resources/migrations/0002_alter_toolsandresourcespage_get_connected_button_text.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-07-04 18:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tools_and_resources', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='toolsandresourcespage', + name='get_connected_button_text', + field=models.CharField(default='Get connected now'), + ), + ] diff --git a/app/tools_and_resources/migrations/__init__.py b/app/tools_and_resources/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/tools_and_resources/models.py b/app/tools_and_resources/models.py new file mode 100644 index 0000000..75db779 --- /dev/null +++ b/app/tools_and_resources/models.py @@ -0,0 +1,100 @@ +from django.db import models + +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 wagtail.images.blocks import ImageChooserBlock +from modelcluster.fields import ParentalKey, ParentalManyToManyField + + +class LargePanel(StructBlock): + image = ImageChooserBlock() + title = CharBlock() + description = RichTextBlock() + link_text = CharBlock() + link_url = URLBlock(required=False) + + +class ToolsAndResourcesPage(Page): + max_count = 1 + + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + + intro_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Intro image" + ) + intro_header = models.CharField(blank=True) + intro = RichTextField(blank=True) + description = RichTextField(blank=True) + learn_more_data_principles_text = models.CharField(default="Learn about our Data & Principles") + learn_more_data_principles_link = models.URLField(blank=True) + + large_panels = StreamField([('panel', LargePanel())], use_json_field=True, null=True, blank=True) + + resource_learning_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Resource and Learning Centre image" + ) + resource_learning_title = models.CharField(default="Resource and Learning Centre") + resource_learning_description = RichTextField(blank=True) + get_connected_button_text = models.CharField(default="Get connected now") + get_connected_button_link = models.URLField(blank=True) + + dogear_tech_news_title = models.CharField(blank=True) + dogear_tech_news_link_text = models.CharField(default="View our Tech News") + dogear_tech_news_link_url = models.URLField(blank=True) + + red_box_title = models.CharField(default="Start Mapping") + red_box_link_text = models.CharField(default="Start Mapping") + red_box_link_url = models.URLField(null=True, blank=True) + black_box_title = models.CharField(default="Check many opportunities to get involved with HOT!") + black_box_link_text = models.CharField(default="Get Involved with HOT") + black_box_link_url = models.URLField(null=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('header_image'), + MultiFieldPanel([ + FieldPanel('intro_image'), + FieldPanel('intro_header'), + FieldPanel('intro'), + FieldPanel('description'), + FieldPanel('learn_more_data_principles_text'), + FieldPanel('learn_more_data_principles_link'), + ], heading="Intro"), + FieldPanel('large_panels'), + MultiFieldPanel([ + FieldPanel('resource_learning_image'), + FieldPanel('resource_learning_title'), + FieldPanel('resource_learning_description'), + FieldPanel('get_connected_button_text'), + FieldPanel('get_connected_button_link'), + ], heading="Resource and Learning Centre"), + MultiFieldPanel([ + FieldPanel('dogear_tech_news_title'), + FieldPanel('dogear_tech_news_link_text'), + FieldPanel('dogear_tech_news_link_url'), + FieldPanel('red_box_title'), + FieldPanel('red_box_link_text'), + FieldPanel('red_box_link_url'), + FieldPanel('black_box_title'), + FieldPanel('black_box_link_text'), + FieldPanel('black_box_link_url'), + ], heading="Dogear Boxes"), + ] diff --git a/app/tools_and_resources/templates/tools_and_resources/tools_and_resources_page.html b/app/tools_and_resources/templates/tools_and_resources/tools_and_resources_page.html new file mode 100644 index 0000000..4eff124 --- /dev/null +++ b/app/tools_and_resources/templates/tools_and_resources/tools_and_resources_page.html @@ -0,0 +1,67 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-toolsandresourcespage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "ui/components/BasePageHeader.html" with title=page.title image=page.header_image %} + +
+
+
+
+

{{page.intro_header}}

+ +
+ {{page.intro|safe}} +
+ +
+ {{page.description|safe}} +
+ + +

+ {{page.learn_more_data_principles_text}} + {% include "ui/components/icon_svgs/LinkCaret.html" with class="ml-4" %} +

+
+
+ {% image page.intro_image original %} +
+ +
+ {% for panel in page.large_panels %} + {% include "ui/components/misc_panels/LinkBlockWithImage.html" with title=panel.value.title image=panel.value.image description=panel.value.description linktext=panel.value.link_text linkurl=panel.value.link_url %} + {% endfor %} +
+
+
+ +
+ {% include "ui/components/sections/BaseSectionWithImage.html" with title=page.resource_learning_title image=page.resource_learning_image imageright=True red_button=True button_text=page.get_connected_button_text button_link=page.get_connected_button_link description=page.resource_learning_description imagenotwide=True %} +
+ +
+
+
+ {% include "ui/components/dogear_boxes/DogearAnyColourLong.html" with title=page.dogear_tech_news_title linktext=page.dogear_tech_news_link_text linkurl=page.dogear_tech_news_link_url textcolour="black" colour="var(--hot-off-white)" arrowcolour="black" %} +
+ +
+
+ {% include "ui/components/dogear_boxes/DogearRed.html" with title=page.red_box_title linktext=page.red_box_link_text linkurl=page.red_box_link_url %} +
+
+ {% include "ui/components/dogear_boxes/DogearBlack.html" with title=page.black_box_title linktext=page.black_box_link_text linkurl=page.black_box_link_url %} +
+
+
+
+{% endblock %} diff --git a/app/tools_and_resources/tests.py b/app/tools_and_resources/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/tools_and_resources/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/tools_and_resources/views.py b/app/tools_and_resources/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/tools_and_resources/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html index f20bfad..dba7278 100644 --- a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html @@ -6,11 +6,5 @@ {% load wagtailimages_tags %} -
- {% image hub.main_external_hub_image fill-600x300 %} - -

- {{ hub.title }} -

-
+ {% include "./MappingHubPreviewBlockBase.html" %}
diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html new file mode 100644 index 0000000..516b30b --- /dev/null +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html @@ -0,0 +1,14 @@ +{% comment %} +==> PARAMETERS +- hub: An IndividualMappingHubPage object; the mapping hub page to be previewed +{% endcomment %} + +{% load wagtailimages_tags %} + +
+ {% image hub.main_external_hub_image fill-600x300 %} + +

+ {{ hub.title }} +

+
diff --git a/app/ui/templates/ui/components/projects/ProjectPreviewBlockMapHub.html b/app/ui/templates/ui/components/projects/ProjectPreviewBlockMapHub.html index 6ce46cc..6993601 100644 --- a/app/ui/templates/ui/components/projects/ProjectPreviewBlockMapHub.html +++ b/app/ui/templates/ui/components/projects/ProjectPreviewBlockMapHub.html @@ -30,8 +30,8 @@

- - {{ project.get_parent.get_parent.title }} - + {% for hub in project.region_hub_list %} + {{ hub.value.title }}{% if not forloop.last %},{% endif %} + {% endfor %}

\ No newline at end of file diff --git a/app/ui/templates/ui/components/sections/BaseSectionWithImage.html b/app/ui/templates/ui/components/sections/BaseSectionWithImage.html index 97eb495..b268022 100644 --- a/app/ui/templates/ui/components/sections/BaseSectionWithImage.html +++ b/app/ui/templates/ui/components/sections/BaseSectionWithImage.html @@ -2,7 +2,7 @@
{% image image original as image_p %} -
+
{{title|safe}} diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index 5647702..b53f485 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -46,6 +46,7 @@ "app.events", "app.who_we_are", "app.get_involved", + "app.tools_and_resources", "search", "users", "utils", From ffe023482ff588673f739e7615e73666ec583ddb Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:56:39 -0700 Subject: [PATCH 08/10] search functionality and page --- app/core/migrations/0003_hotsearchablepage.py | 27 +++++++++ app/core/migrations/0004_testpagepage.py | 24 ++++++++ ...earchablepage_intro_delete_testpagepage.py | 20 +++++++ app/core/models.py | 6 ++ app/events/models.py | 1 + .../templates/events/event_owner_page.html | 43 +------------ ...introduction_individualmemberpage_intro.py | 18 ++++++ app/members/models.py | 12 +++- app/news/models.py | 1 + app/news/templates/news/news_owner_page.html | 43 +------------ app/programs/models.py | 7 +++ ...0026_remove_individualprojectpage_intro.py | 17 ++++++ .../0027_individualprojectpage_intro.py | 19 ++++++ app/projects/models.py | 8 +++ app/search_page/__init__.py | 0 app/search_page/admin.py | 3 + app/search_page/apps.py | 6 ++ app/search_page/migrations/0001_initial.py | 26 ++++++++ ..._searchpage_search_text_midfix_and_more.py | 28 +++++++++ .../0003_searchpage_no_results_text.py | 18 ++++++ .../0004_searchpage_no_results_go_back.py | 18 ++++++ app/search_page/migrations/__init__.py | 0 app/search_page/models.py | 58 ++++++++++++++++++ .../templates/search_page/search_page.html | 60 +++++++++++++++++++ app/search_page/tests.py | 3 + app/search_page/views.py | 3 + .../ui/components/icon_svgs/SearchIcon.html | 2 +- .../components/navigation/HeaderNavbar.html | 1 + .../ui/components/navigation/SearchForm.html | 16 +++++ .../ui/components/navigation/SearchModal.html | 16 +++++ .../utilities/PaginatorNavigation.html | 47 +++++++++++++++ hot_osm/settings/base.py | 1 + hot_osm/templates/base.html | 1 + .../components/nav/secondary_desktop_nav.html | 13 ++-- 34 files changed, 475 insertions(+), 91 deletions(-) create mode 100644 app/core/migrations/0003_hotsearchablepage.py create mode 100644 app/core/migrations/0004_testpagepage.py create mode 100644 app/core/migrations/0005_remove_hotsearchablepage_intro_delete_testpagepage.py create mode 100644 app/members/migrations/0003_rename_introduction_individualmemberpage_intro.py create mode 100644 app/projects/migrations/0026_remove_individualprojectpage_intro.py create mode 100644 app/projects/migrations/0027_individualprojectpage_intro.py create mode 100644 app/search_page/__init__.py create mode 100644 app/search_page/admin.py create mode 100644 app/search_page/apps.py create mode 100644 app/search_page/migrations/0001_initial.py create mode 100644 app/search_page/migrations/0002_searchpage_search_text_midfix_and_more.py create mode 100644 app/search_page/migrations/0003_searchpage_no_results_text.py create mode 100644 app/search_page/migrations/0004_searchpage_no_results_go_back.py create mode 100644 app/search_page/migrations/__init__.py create mode 100644 app/search_page/models.py create mode 100644 app/search_page/templates/search_page/search_page.html create mode 100644 app/search_page/tests.py create mode 100644 app/search_page/views.py create mode 100644 app/ui/templates/ui/components/navigation/SearchForm.html create mode 100644 app/ui/templates/ui/components/navigation/SearchModal.html create mode 100644 app/ui/templates/ui/components/utilities/PaginatorNavigation.html diff --git a/app/core/migrations/0003_hotsearchablepage.py b/app/core/migrations/0003_hotsearchablepage.py new file mode 100644 index 0000000..bbe934b --- /dev/null +++ b/app/core/migrations/0003_hotsearchablepage.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.7 on 2024-07-08 21:16 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('core', '0002_alter_partner_partner_logo_alter_partner_partner_url'), + ] + + operations = [ + migrations.CreateModel( + name='HOTSearchablePage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ('intro', wagtail.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/core/migrations/0004_testpagepage.py b/app/core/migrations/0004_testpagepage.py new file mode 100644 index 0000000..dd1b55a --- /dev/null +++ b/app/core/migrations/0004_testpagepage.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.7 on 2024-07-08 21:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_hotsearchablepage'), + ] + + operations = [ + migrations.CreateModel( + name='TestPagePage', + fields=[ + ('hotsearchablepage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.hotsearchablepage')), + ], + options={ + 'abstract': False, + }, + bases=('core.hotsearchablepage',), + ), + ] diff --git a/app/core/migrations/0005_remove_hotsearchablepage_intro_delete_testpagepage.py b/app/core/migrations/0005_remove_hotsearchablepage_intro_delete_testpagepage.py new file mode 100644 index 0000000..ee4161d --- /dev/null +++ b/app/core/migrations/0005_remove_hotsearchablepage_intro_delete_testpagepage.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-07-08 21:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_testpagepage'), + ] + + operations = [ + migrations.RemoveField( + model_name='hotsearchablepage', + name='intro', + ), + migrations.DeleteModel( + name='TestPagePage', + ), + ] diff --git a/app/core/models.py b/app/core/models.py index dc01482..f5bc52c 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -1,4 +1,6 @@ from django.db import models +from wagtail.models import Page +from wagtail.fields import RichTextField from wagtail.snippets.models import register_snippet from wagtail.admin.panels import FieldPanel, MultiFieldPanel, InlinePanel @@ -27,3 +29,7 @@ def __str__(self): class Meta: verbose_name_plural = "Partners" + + +class HotSearchablePage(Page): + pass diff --git a/app/events/models.py b/app/events/models.py index 302fb90..7acc034 100644 --- a/app/events/models.py +++ b/app/events/models.py @@ -123,6 +123,7 @@ class IndividualEventPage(Page): search_fields = Page.search_fields + [ index.SearchField('title'), index.SearchField('intro'), + index.SearchField('search_description'), ] content_panels = Page.content_panels + [ diff --git a/app/events/templates/events/event_owner_page.html b/app/events/templates/events/event_owner_page.html index 073f462..1d067b5 100644 --- a/app/events/templates/events/event_owner_page.html +++ b/app/events/templates/events/event_owner_page.html @@ -46,53 +46,14 @@

{{page.title}}

{% comment %} EVENT ITEMS {% endcomment %}

{{events_paginator.count}} {{page.results_text}}

-
+
{% for event in events %} {% include "ui/components/events/EventPreviewBlockEvent.html" with event=event showimage=True %} {% endfor %}
{% comment %} PAGE NAVIGATION {% endcomment %} -
- -

- {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %} -

-
-
- {% with ''|center:events_paginator.num_pages as range %} - {% for _ in range %} - {% if forloop.counter == 1 or forloop.counter == events_paginator.num_pages or forloop.counter == current_page or forloop.counter|add:1 == current_page or forloop.counter|add:'-1' == current_page %} - -

- {{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" %} -

-
-
+ {% include "ui/components/utilities/PaginatorNavigation.html" with paginator=events_paginator current_page=current_page %}
{% endblock %} diff --git a/app/members/migrations/0003_rename_introduction_individualmemberpage_intro.py b/app/members/migrations/0003_rename_introduction_individualmemberpage_intro.py new file mode 100644 index 0000000..3dc041a --- /dev/null +++ b/app/members/migrations/0003_rename_introduction_individualmemberpage_intro.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-07-08 23:24 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('members', '0002_remove_individualmemberpage_location_and_more'), + ] + + operations = [ + migrations.RenameField( + model_name='individualmemberpage', + old_name='introduction', + new_name='intro', + ), + ] diff --git a/app/members/models.py b/app/members/models.py index 00e53fe..58047ab 100644 --- a/app/members/models.py +++ b/app/members/models.py @@ -6,6 +6,7 @@ from django.db.models import Q from app.projects.models import IndividualProjectPage from app.news.models import IndividualNewsPage +from wagtail.search import index class WebLinkStructBlock(StructBlock): link_text = CharBlock(required=True) @@ -70,13 +71,20 @@ def get_context(self, request, *args, **kwargs): on_delete=models.SET_NULL, related_name='+' ) - introduction = RichTextField() + intro = RichTextField() on_the_web_links = StreamField(WebLinkBlock(), blank=True, use_json_field=True) + + search_fields = Page.search_fields + [ + index.SearchField('title'), + index.SearchField('search_description'), + index.SearchField('intro'), + ] + content_panels = Page.content_panels + [ FieldPanel('image'), FieldPanel('position'), FieldPanel('location_hub'), - FieldPanel('introduction'), + FieldPanel('intro'), FieldPanel('on_the_web_links'), ] diff --git a/app/news/models.py b/app/news/models.py index 1152c85..4b65d47 100644 --- a/app/news/models.py +++ b/app/news/models.py @@ -186,6 +186,7 @@ class IndividualNewsPage(Page): index.SearchField('intro'), index.FilterField('newscategory_id'), # the console warns you about this but if you don't have this then category search doesn't work index.FilterField('name'), + index.SearchField('search_description'), ] content_panels = Page.content_panels + [ diff --git a/app/news/templates/news/news_owner_page.html b/app/news/templates/news/news_owner_page.html index 13ac88f..e1e4d9d 100644 --- a/app/news/templates/news/news_owner_page.html +++ b/app/news/templates/news/news_owner_page.html @@ -96,53 +96,14 @@

{{page.title}}

{% comment %} NEWS ITEMS {% endcomment %}

{{news_paginator.count}} {{page.results_text}}

-
+
{% for article in news %} {% include "ui/components/news/NewsPreviewBlockProjects.html" with news=article showimage=True class="[&_.image-hide-small]:hidden md:[&_.image-hide-small]:block" %} {% endfor %}
{% comment %} PAGE NAVIGATION {% endcomment %} -
- -

- {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %} -

-
-
- {% with ''|center:news_paginator.num_pages as range %} - {% for _ in range %} - {% if forloop.counter == 1 or forloop.counter == news_paginator.num_pages or forloop.counter == current_page or forloop.counter|add:1 == current_page or forloop.counter|add:'-1' == current_page %} - -

- {{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" %} -

-
-
+ {% include "ui/components/utilities/PaginatorNavigation.html" with paginator=news_paginator current_page=current_page %}
{% endblock %} diff --git a/app/programs/models.py b/app/programs/models.py index a8f252c..701c7f5 100644 --- a/app/programs/models.py +++ b/app/programs/models.py @@ -8,6 +8,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register +from wagtail.search import index from app.projects.models import IndividualProjectPage @@ -122,6 +123,12 @@ def get_context(self, request): ('program_page', PageChooserBlock(page_type="programs.IndividualProgramPage")) ], use_json_field=True, null=True, blank=True) + search_fields = Page.search_fields + [ + index.SearchField('title'), + index.SearchField('search_description'), + index.SearchField('intro'), + ] + content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel("subtitle"), diff --git a/app/projects/migrations/0026_remove_individualprojectpage_intro.py b/app/projects/migrations/0026_remove_individualprojectpage_intro.py new file mode 100644 index 0000000..3b3452b --- /dev/null +++ b/app/projects/migrations/0026_remove_individualprojectpage_intro.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.7 on 2024-07-08 21:32 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0025_projectownerpage_header_image'), + ] + + operations = [ + migrations.RemoveField( + model_name='individualprojectpage', + name='intro', + ), + ] diff --git a/app/projects/migrations/0027_individualprojectpage_intro.py b/app/projects/migrations/0027_individualprojectpage_intro.py new file mode 100644 index 0000000..aa40dcd --- /dev/null +++ b/app/projects/migrations/0027_individualprojectpage_intro.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.7 on 2024-07-08 21:32 + +from django.db import migrations +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0026_remove_individualprojectpage_intro'), + ] + + operations = [ + migrations.AddField( + model_name='individualprojectpage', + name='intro', + field=wagtail.fields.RichTextField(blank=True), + ), + ] diff --git a/app/projects/models.py b/app/projects/models.py index a4f6209..8ab849b 100644 --- a/app/projects/models.py +++ b/app/projects/models.py @@ -7,7 +7,9 @@ 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 wagtail.search import index from modelcluster.fields import ParentalKey, ParentalManyToManyField +from app.core.models import HotSearchablePage """ @@ -167,6 +169,12 @@ class IndividualProjectPage(Page): project_contributors = StreamField([('contributor', PageChooserBlock(page_type="members.IndividualMemberPage"))], use_json_field=True, null=True, blank=True) + search_fields = Page.search_fields + [ + index.SearchField('title'), + index.SearchField('search_description'), + index.SearchField('intro'), + ] + content_panels = Page.content_panels + [ MultiFieldPanel([ PageChooserPanel('owner_program', 'programs.IndividualProgramPage'), diff --git a/app/search_page/__init__.py b/app/search_page/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/search_page/admin.py b/app/search_page/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/search_page/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/search_page/apps.py b/app/search_page/apps.py new file mode 100644 index 0000000..6d87f0a --- /dev/null +++ b/app/search_page/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SearchPageConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'app.search_page' diff --git a/app/search_page/migrations/0001_initial.py b/app/search_page/migrations/0001_initial.py new file mode 100644 index 0000000..3089437 --- /dev/null +++ b/app/search_page/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.7 on 2024-07-08 19:38 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ] + + operations = [ + migrations.CreateModel( + name='SearchPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/search_page/migrations/0002_searchpage_search_text_midfix_and_more.py b/app/search_page/migrations/0002_searchpage_search_text_midfix_and_more.py new file mode 100644 index 0000000..e60451b --- /dev/null +++ b/app/search_page/migrations/0002_searchpage_search_text_midfix_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.7 on 2024-07-08 20:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('search_page', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='searchpage', + name='search_text_midfix', + field=models.CharField(default='returns'), + ), + migrations.AddField( + model_name='searchpage', + name='search_text_postfix', + field=models.CharField(default='results'), + ), + migrations.AddField( + model_name='searchpage', + name='search_text_prefix', + field=models.CharField(default='Your search for'), + ), + ] diff --git a/app/search_page/migrations/0003_searchpage_no_results_text.py b/app/search_page/migrations/0003_searchpage_no_results_text.py new file mode 100644 index 0000000..5885853 --- /dev/null +++ b/app/search_page/migrations/0003_searchpage_no_results_text.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-07-08 23:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('search_page', '0002_searchpage_search_text_midfix_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='searchpage', + name='no_results_text', + field=models.CharField(default='No matching search results for', help_text='This field is a prefix to the current search result in the event no results are found; i.e., if the search keyword was \'Hello\' and this field is \'No matching result for\', the no-result page would show "No matching result for "Hello""'), + ), + ] diff --git a/app/search_page/migrations/0004_searchpage_no_results_go_back.py b/app/search_page/migrations/0004_searchpage_no_results_go_back.py new file mode 100644 index 0000000..82a570c --- /dev/null +++ b/app/search_page/migrations/0004_searchpage_no_results_go_back.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-07-08 23:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('search_page', '0003_searchpage_no_results_text'), + ] + + operations = [ + migrations.AddField( + model_name='searchpage', + name='no_results_go_back', + field=models.CharField(default='Go Back'), + ), + ] diff --git a/app/search_page/migrations/__init__.py b/app/search_page/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/search_page/models.py b/app/search_page/models.py new file mode 100644 index 0000000..e9ecbbb --- /dev/null +++ b/app/search_page/models.py @@ -0,0 +1,58 @@ +from django.db import models +from django.db.models import Q +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 + + +class SearchPage(Page): + def get_context(self, request, *args, **kwargs): + context = super().get_context(request, *args, **kwargs) + + keyword = request.GET.get('keyword', '') + results_list = Page.objects.live().filter(locale=context['page'].locale) + + if keyword: + results_list = results_list.search(keyword).get_queryset() + + results_list = results_list.exclude(id__in=[1, 2]) + + page = request.GET.get('page', 1) + paginator = Paginator(results_list, 6) # if you want more/less items per page (i.e., per load), change the number here to something else + try: + results = paginator.page(page) + except PageNotAnInteger: + results = paginator.page(1) + except EmptyPage: + results = paginator.page(paginator.num_pages) + + context['results'] = results + context['results_paginator'] = paginator + context['current_page'] = int(page) + context['keyword'] = keyword + return context + + page_description = "Search results will, by default, attempt to pull from an 'intro' field for the page description; otherwise, it will grab the page's meta search description." + + max_count = 1 + + search_text_prefix = models.CharField(default="Your search for") + search_text_midfix = models.CharField(default="returns") + search_text_postfix = models.CharField(default="results") + + no_results_text = models.CharField(default="No matching search results for", help_text="This field is a prefix to the current search result in the event no results are found; i.e., if the search keyword was 'Hello' and this field is 'No matching result for', the no-result page would show \"No matching result for \"Hello\"\"") + no_results_go_back = models.CharField(default="Go Back") + + content_panels = Page.content_panels + [ + MultiFieldPanel([ + FieldPanel("search_text_prefix"), + FieldPanel("search_text_midfix"), + FieldPanel("search_text_postfix"), + ], heading="Search Result Text", help_text="These combine to make the search result text; i.e., if prefix is 'Your search for', midfix is 'returns', and postfix is 'results', the search result text will be \"Your search for \"example\" returns \"x\" results\""), + FieldPanel('no_results_text'), + FieldPanel('no_results_go_back'), + ] diff --git a/app/search_page/templates/search_page/search_page.html b/app/search_page/templates/search_page/search_page.html new file mode 100644 index 0000000..508ed0e --- /dev/null +++ b/app/search_page/templates/search_page/search_page.html @@ -0,0 +1,60 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} +{% block body_class %} + template-searchpage +{% endblock body_class %} +{% block content %} +
+
+
+

+ {% 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 %} +

+
+ {% include "ui/components/navigation/SearchForm.html" %} +
+
+ {% if results %} +
+ {% for result in results %} +
+

{{result.title}}

+ {% if result.get_ancestors|length > 2 %} +

+ {% for ancestor in result.get_ancestors|slice:"2:" %} + {{ancestor.title}} + {% if not forloop.last %} > {% endif %} + {% endfor %} +

+ {% endif %} + + {% if result.specific.intro %} +
+ {{result.specific.intro|safe}} +
+ {% else %} + {% if result.search_description %} +

{{result.search_description}}

+ {% endif %} + {% endif %} + +

+ {{result.full_url}} +

+
+ {% endfor %} +
+ {% include "ui/components/utilities/PaginatorNavigation.html" with paginator=results_paginator current_page=current_page %} + + {% else %} +

+ {% include "ui/components/BaseLink.html" with linktext=page.no_results_go_back linkurl="javascript:history.back()" %} +

+ {% endif %} +
+
+{% endblock content %} diff --git a/app/search_page/tests.py b/app/search_page/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/search_page/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/search_page/views.py b/app/search_page/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/search_page/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/ui/templates/ui/components/icon_svgs/SearchIcon.html b/app/ui/templates/ui/components/icon_svgs/SearchIcon.html index 1f594b4..fa049a1 100644 --- a/app/ui/templates/ui/components/icon_svgs/SearchIcon.html +++ b/app/ui/templates/ui/components/icon_svgs/SearchIcon.html @@ -1,3 +1,3 @@ - + diff --git a/app/ui/templates/ui/components/navigation/HeaderNavbar.html b/app/ui/templates/ui/components/navigation/HeaderNavbar.html index 3bfe9fc..1345f36 100644 --- a/app/ui/templates/ui/components/navigation/HeaderNavbar.html +++ b/app/ui/templates/ui/components/navigation/HeaderNavbar.html @@ -50,6 +50,7 @@ {% comment %} MOBILE EXPANDED LIST {% endcomment %}
    +
  • {% include "ui/components/navigation/SearchForm.html" %}
  • {% for item in navigation %}
  • {% include "ui/components/navigation/HeaderNavbarItem.html" with item=item.value %} diff --git a/app/ui/templates/ui/components/navigation/SearchForm.html b/app/ui/templates/ui/components/navigation/SearchForm.html new file mode 100644 index 0000000..7cdf10d --- /dev/null +++ b/app/ui/templates/ui/components/navigation/SearchForm.html @@ -0,0 +1,16 @@ +
    + + +
    \ No newline at end of file diff --git a/app/ui/templates/ui/components/navigation/SearchModal.html b/app/ui/templates/ui/components/navigation/SearchModal.html new file mode 100644 index 0000000..5e4b952 --- /dev/null +++ b/app/ui/templates/ui/components/navigation/SearchModal.html @@ -0,0 +1,16 @@ + diff --git a/app/ui/templates/ui/components/utilities/PaginatorNavigation.html b/app/ui/templates/ui/components/utilities/PaginatorNavigation.html new file mode 100644 index 0000000..e2ed781 --- /dev/null +++ b/app/ui/templates/ui/components/utilities/PaginatorNavigation.html @@ -0,0 +1,47 @@ +{% comment %} +PARAMETERS: +=> paginator: a paginator object +=> current_page: an integer, the current page +{% endcomment %} +
    +
    + +

    + {% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %} +

    +
    +
    + {% with ''|center:paginator.num_pages as range %} + {% for _ in range %} + {% if forloop.counter == 1 or forloop.counter == paginator.num_pages or forloop.counter == current_page or forloop.counter|add:1 == current_page or forloop.counter|add:'-1' == current_page %} + +

    + {{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" %} +

    +
    +
    +
    diff --git a/hot_osm/settings/base.py b/hot_osm/settings/base.py index b53f485..725d67c 100644 --- a/hot_osm/settings/base.py +++ b/hot_osm/settings/base.py @@ -47,6 +47,7 @@ "app.who_we_are", "app.get_involved", "app.tools_and_resources", + "app.search_page", "search", "users", "utils", diff --git a/hot_osm/templates/base.html b/hot_osm/templates/base.html index 96a4c26..790dad1 100644 --- a/hot_osm/templates/base.html +++ b/hot_osm/templates/base.html @@ -49,6 +49,7 @@ {% include "components/nav/secondary_desktop_nav.html" %}
    {% comment %} {% include "components/header/header.html" %} {% endcomment %} + {% include "ui/components/navigation/SearchModal.html" %} {% include "ui/components/navigation/HeaderNavbar.html" %} {% block content %} {% endblock content %} diff --git a/hot_osm/templates/components/nav/secondary_desktop_nav.html b/hot_osm/templates/components/nav/secondary_desktop_nav.html index f61c929..916387b 100644 --- a/hot_osm/templates/components/nav/secondary_desktop_nav.html +++ b/hot_osm/templates/components/nav/secondary_desktop_nav.html @@ -1,6 +1,6 @@ {% load i18n %} -
From 2e39194e7521bebffad42aa27c366a71dc573d1a Mon Sep 17 00:00:00 2001 From: luminaryFlowers <71102109+luminaryFlowers@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:43:50 -0700 Subject: [PATCH 09/10] catching up on component documentation --- .../templates/ui/components/BasePageHeader.html | 12 +++++++----- .../ui/components/CTABodyPanelBase.html | 7 +++++++ .../ui/components/FlexTitleWithLink.html | 8 ++++++++ .../ui/components/PageHeaderWithBlur.html | 1 + .../components/SectionHeadingWithUnderline.html | 5 +++++ .../ui/components/ThreeElementCarousel.html | 10 ++++++++++ .../ui/components/TitleWithUnderline.html | 4 ++++ .../dogear_boxes/DogearAnyColourLong.html | 1 + .../events/EventPreviewBlockEvent.html | 4 ++++ .../ui/components/icon_svgs/RefreshIcon.html | 4 ++++ .../ui/components/icon_svgs/SearchIcon.html | 4 ++++ .../impact_areas/ImpactAreaPreviewBlock.html | 4 ++++ .../mapping_hub/MappingHubPreviewBlock.html | 1 - .../mapping_hub/MappingHubPreviewBlockBase.html | 1 - .../MappingHubPreviewExtendedBlock.html | 4 ++++ .../misc_panels/LinkBlockWithImage.html | 7 +++++++ .../misc_panels/PagePreviewBasic.html | 5 +++++ .../PagePreviewWithTabletDescription.html | 7 +++++++ .../components/navigation/FooterNavigation.html | 3 +++ .../ui/components/navigation/HeaderNavbar.html | 3 +++ .../navigation/HeaderNavbarButton.html | 4 ++++ .../components/navigation/HeaderNavbarItem.html | 5 +++++ .../ui/components/navigation/SearchForm.html | 5 +++++ .../ui/components/navigation/SearchModal.html | 3 +++ .../news/NewsPreviewBlockProjects.html | 2 +- .../ui/components/news/NewsPreviewCarousel.html | 5 +++++ .../components/partners/PartnerViewBlock.html | 3 --- .../programs/ProgramCarouselBlock.html | 4 ++++ .../projects/ProjectPreviewBlockMapHub.html | 2 +- .../projects/ProjectPreviewBlockNews.html | 2 +- .../projects/ProjectPreviewCarousel.html | 5 +++++ .../sections/BaseSectionWithImage.html | 17 +++++++++++++++++ .../sections/GreyBackgroundWithImage.html | 16 ++++++++++++++++ .../ui/components/sections/LinkListSection.html | 8 +++++++- .../sections/NavyBackgroundWithImage.html | 16 ++++++++++++++++ .../ui/components/sharers/ShareSection.html | 5 +++++ 36 files changed, 183 insertions(+), 14 deletions(-) diff --git a/app/ui/templates/ui/components/BasePageHeader.html b/app/ui/templates/ui/components/BasePageHeader.html index b536ebf..cce8bb9 100644 --- a/app/ui/templates/ui/components/BasePageHeader.html +++ b/app/ui/templates/ui/components/BasePageHeader.html @@ -2,9 +2,11 @@ ==> PARAMETERS - title: A string, the title shown in the header - intro: An HTML element (regular usage would be a

with some text in it) +- subtitle: An HTML element - image: A Wagtail image -{% endcomment %} +Only one of either intro or subtitle should be present; you probably would not want both. +{% endcomment %} {% load wagtailimages_tags %} {% image image original as image_p %} @@ -23,11 +25,11 @@

{% endif %}
-
- {% if subtitle %} + {% if subtitle %} +
{{ subtitle|safe }} - {% endif %} -
+
+ {% endif %}
\ No newline at end of file diff --git a/app/ui/templates/ui/components/CTABodyPanelBase.html b/app/ui/templates/ui/components/CTABodyPanelBase.html index 7136626..7d6e8df 100644 --- a/app/ui/templates/ui/components/CTABodyPanelBase.html +++ b/app/ui/templates/ui/components/CTABodyPanelBase.html @@ -1,3 +1,10 @@ +{% comment %} +==> PARAMETERS +- title: string; the title for the panel +- text: html element; the description for the panel +- linktext: string; the text shown for the link +- linkurl: string; the url for the link +{% endcomment %}

{{ 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

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 %} +

{{ 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 %}
diff --git a/app/ui/templates/ui/components/TitleWithUnderline.html b/app/ui/templates/ui/components/TitleWithUnderline.html index 065f351..af7adc9 100644 --- a/app/ui/templates/ui/components/TitleWithUnderline.html +++ b/app/ui/templates/ui/components/TitleWithUnderline.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- title: string; the title +{% 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 %}
diff --git a/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html b/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html index 433fe8c..31f2099 100644 --- a/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html +++ b/app/ui/templates/ui/components/events/EventPreviewBlockEvent.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- event: an IndividualEventPage object; should be passed directly here +{% endcomment %} {% load wagtailimages_tags %} {% image event.image original as image_p %} diff --git a/app/ui/templates/ui/components/icon_svgs/RefreshIcon.html b/app/ui/templates/ui/components/icon_svgs/RefreshIcon.html index 404ea7b..d3b9f21 100644 --- a/app/ui/templates/ui/components/icon_svgs/RefreshIcon.html +++ b/app/ui/templates/ui/components/icon_svgs/RefreshIcon.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- class: string; the classes you want for this icon +{% endcomment %} \ No newline at end of file diff --git a/app/ui/templates/ui/components/icon_svgs/SearchIcon.html b/app/ui/templates/ui/components/icon_svgs/SearchIcon.html index fa049a1..27f916a 100644 --- a/app/ui/templates/ui/components/icon_svgs/SearchIcon.html +++ b/app/ui/templates/ui/components/icon_svgs/SearchIcon.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- class: string; the classes you want for this icon +{% endcomment %} diff --git a/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html index c96d3d8..67edbec 100644 --- a/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html +++ b/app/ui/templates/ui/components/impact_areas/ImpactAreaPreviewBlock.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- ia: an IndividualImpactAreaPage; should be passed directly here +{% endcomment %} {% load wagtailimages_tags %} {% image ia.header_image original as image_p %} diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html index dba7278..affd498 100644 --- a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlock.html @@ -2,7 +2,6 @@ ==> PARAMETERS - hub: An IndividualMappingHubPage object; the mapping hub page to be previewed {% endcomment %} - {% load wagtailimages_tags %} diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html index 516b30b..a6c44fd 100644 --- a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewBlockBase.html @@ -2,7 +2,6 @@ ==> PARAMETERS - hub: An IndividualMappingHubPage object; the mapping hub page to be previewed {% endcomment %} - {% load wagtailimages_tags %}
diff --git a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html index a1e0451..851522d 100644 --- a/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html +++ b/app/ui/templates/ui/components/mapping_hub/MappingHubPreviewExtendedBlock.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- hub: An IndividualMappingHubPage object; the mapping hub page to be previewed +{% endcomment %} {% load wagtailimages_tags %}
diff --git a/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html b/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html index a61d172..3eadf13 100644 --- a/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html +++ b/app/ui/templates/ui/components/misc_panels/LinkBlockWithImage.html @@ -1,3 +1,10 @@ +{% comment %} +==> PARAMETERS +- title: string; the title +- description: html element; the description of the block +- linktext: string; the text to show for the link +- linkurl: string; the desired url +{% endcomment %} {% load wagtailimages_tags %}
diff --git a/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html b/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html index 2bebce6..3c6429a 100644 --- a/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html +++ b/app/ui/templates/ui/components/misc_panels/PagePreviewBasic.html @@ -1,3 +1,8 @@ +{% comment %} +==> PARAMETERS +- page: Page object; its link and title is used here +- previmg: image object; the image for the preview +{% endcomment %} {% load wagtailimages_tags %} {% image image original as previmg %} diff --git a/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html b/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html index 01f4a60..eb1db9d 100644 --- a/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html +++ b/app/ui/templates/ui/components/misc_panels/PagePreviewWithTabletDescription.html @@ -1,3 +1,10 @@ +{% comment %} +==> PARAMETERS +- page: Page object; its link and title is used here +- previmg: image object; the image for the preview +- tablet_description: html element; the description of the block, which only shows on tablet sizes and smaller +- read_more_text: string; the text to show for "read more" +{% endcomment %} {% load wagtailimages_tags %} {% image image original as previmg %} diff --git a/app/ui/templates/ui/components/navigation/FooterNavigation.html b/app/ui/templates/ui/components/navigation/FooterNavigation.html index 38f5427..2aa3619 100644 --- a/app/ui/templates/ui/components/navigation/FooterNavigation.html +++ b/app/ui/templates/ui/components/navigation/FooterNavigation.html @@ -1,3 +1,6 @@ +{% comment %} +No parameters; it grabs directly from the home page (for the correct locale). +{% endcomment %} {% load homepage_tags %} {% get_home_page as home_page %} {% get_navigation as navigation %} diff --git a/app/ui/templates/ui/components/navigation/HeaderNavbar.html b/app/ui/templates/ui/components/navigation/HeaderNavbar.html index 1345f36..2a49392 100644 --- a/app/ui/templates/ui/components/navigation/HeaderNavbar.html +++ b/app/ui/templates/ui/components/navigation/HeaderNavbar.html @@ -1,3 +1,6 @@ +{% comment %} +No parameters; it grabs directly from the home page (for the correct locale). +{% endcomment %} {% load homepage_tags %} {% get_navigation as navigation %} {% get_home_page as home_page %} diff --git a/app/ui/templates/ui/components/navigation/HeaderNavbarButton.html b/app/ui/templates/ui/components/navigation/HeaderNavbarButton.html index 22f0dd0..39a73a2 100644 --- a/app/ui/templates/ui/components/navigation/HeaderNavbarButton.html +++ b/app/ui/templates/ui/components/navigation/HeaderNavbarButton.html @@ -1,3 +1,7 @@ +{% comment %} +==> PARAMETERS +- item: a navigation item; has a title and a link_page OR link_url +{% 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 %}

diff --git a/app/ui/templates/ui/components/navigation/SearchForm.html b/app/ui/templates/ui/components/navigation/SearchForm.html index 7cdf10d..f10fa9a 100644 --- a/app/ui/templates/ui/components/navigation/SearchForm.html +++ b/app/ui/templates/ui/components/navigation/SearchForm.html @@ -1,3 +1,8 @@ +{% comment %} +==> PARAMETERS +- has_ref: optional; if Truthy, this will have an x-ref + - means that this form can be focused via alpinejs; if multiple have this ref it obviously won't work for all of them +{% endcomment %}

+ {% endif %} +

+ + {% comment %} BOTTOM AREA {% endcomment %} +
+ {% for group in groups %} + {% if forloop.counter0|divisibleby:2 %} +
+ {% include "ui/components/dogear_boxes/DogearRed.html" with title=group.title linktext=page.get_parent.specific.view_all_text|add:' '|add:group.title linkurl=group.url %} +
+ {% else %} +
+ {% include "ui/components/dogear_boxes/DogearBlack.html" with title=group.title linktext=page.get_parent.specific.view_all_text|add:' '|add:group.title linkurl=group.url %} +
+ {% endif %} + {% endfor %} +
+
+ {% include "ui/components/FooterBannerWithTextAndLink.html" with text=page.get_parent.specific.footer_box_title url=page.get_parent.specific.footer_box_button_link buttontext=page.get_parent.specific.footer_box_button_text description=page.get_parent.specific.footer_box_description %} +
+
+{% endblock %} diff --git a/app/news/models.py b/app/news/models.py index 4b65d47..c0887ae 100644 --- a/app/news/models.py +++ b/app/news/models.py @@ -21,6 +21,9 @@ def get_context(self, request, *args, **kwargs): keyword = request.GET.get('keyword', '') news_list = IndividualNewsPage.objects.live().filter(locale=context['page'].locale) + + if keyword: + news_list = news_list.search(keyword).get_queryset() categories = NewsCategory.objects.all() tags = [x[4:] for x in request.GET.keys() if x.startswith("tag.")] @@ -28,13 +31,13 @@ def get_context(self, request, *args, **kwargs): for category in categories: if request.GET.get(str(category), ''): query = query | Q(categories=category) + news_list = news_list.filter(query).distinct() + + query = Q() for tag in tags: query = query | Q(tags__name=tag) news_list = news_list.filter(query).distinct() - if keyword: - news_list = news_list.search(keyword).get_queryset() - match request.GET.get('sort', ''): case 'sort.new': news_list = news_list.order_by('-date') @@ -184,8 +187,8 @@ class IndividualNewsPage(Page): search_fields = Page.search_fields + [ index.SearchField('title'), index.SearchField('intro'), - index.FilterField('newscategory_id'), # the console warns you about this but if you don't have this then category search doesn't work - index.FilterField('name'), + # index.FilterField('newscategory_id'), # the console warns you about this but if you don't have this then category search doesn't work + # index.FilterField('name'), index.SearchField('search_description'), ] diff --git a/app/projects/models.py b/app/projects/models.py index 8ab849b..ea22cf0 100644 --- a/app/projects/models.py +++ b/app/projects/models.py @@ -9,7 +9,6 @@ from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock from wagtail.search import index from modelcluster.fields import ParentalKey, ParentalManyToManyField -from app.core.models import HotSearchablePage """ diff --git a/app/ui/templates/ui/components/FooterBannerWithTextAndLink.html b/app/ui/templates/ui/components/FooterBannerWithTextAndLink.html index b93d3e9..7b9cdf1 100644 --- a/app/ui/templates/ui/components/FooterBannerWithTextAndLink.html +++ b/app/ui/templates/ui/components/FooterBannerWithTextAndLink.html @@ -10,6 +10,11 @@

{{ text }}

+ {% if description %} +
+ {{description|safe}} +
+ {% endif %} {% include "components/branded_elements/button.html" with text=buttontext %} diff --git a/app/ui/templates/ui/components/members/MemberPreviewBlock.html b/app/ui/templates/ui/components/members/MemberPreviewBlock.html new file mode 100644 index 0000000..a1a5bbd --- /dev/null +++ b/app/ui/templates/ui/components/members/MemberPreviewBlock.html @@ -0,0 +1,24 @@ +{% load wagtailimages_tags %} + + \ No newline at end of file