Skip to content

Commit

Permalink
Merge pull request #41 from hotosm/qa/sept4
Browse files Browse the repository at this point in the history
Qa/sept4
  • Loading branch information
luminaryFlowers authored Nov 12, 2024
2 parents 750ae29 + 26d0130 commit 4775b8c
Show file tree
Hide file tree
Showing 279 changed files with 7,616 additions and 1,493 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LABEL org.hotosm.fmtm.app-name="backend" \
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends "locales" "ca-certificates" "gettext" \
-y --no-install-recommends "locales" "ca-certificates" "gettext" "libmagickwand-dev" \
&& DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates
Expand Down Expand Up @@ -61,6 +61,7 @@ RUN set -ex \
"libwebp-dev" \
"nodejs" \
"npm" \
"libmagickwand-dev" \
&& rm -rf /var/lib/apt/lists/*
COPY --from=extract-deps \
/opt/python/requirements.txt /opt/python/
Expand Down Expand Up @@ -94,6 +95,7 @@ RUN set -ex \
"libwebp-dev" \
"nodejs" \
"npm" \
"libmagickwand-dev" \
&& rm -rf /var/lib/apt/lists/*
# Copy the entrypoint script into the Docker image
COPY --chown=wagtail:wagtail container-entrypoint.sh /
Expand Down
1 change: 1 addition & 0 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class LinkOrPageBlock(StreamBlock):
page = PageChooserBlock()
url = URLBlock()
document = DocumentChooserBlock()
other = CharBlock(help_text="Only use this option as a last resort. The other fields are preferred. In cases like email 'mailto' links, however, this field can be used. Ensure that your provided link will function as intended prior to publishing live.")

class Meta:
max_num = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.2.7 on 2024-09-18 19:59

from django.db import migrations, models
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('events', '0009_alter_eventownerpage_category_select_and_more'),
]

operations = [
migrations.RemoveField(
model_name='eventownerpage',
name='view_all_events_url',
),
migrations.AddField(
model_name='eventownerpage',
name='view_all_events_link',
field=wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock()), ('document', wagtail.documents.blocks.DocumentChooserBlock())], blank=True, use_json_field=True),
),
migrations.AlterField(
model_name='individualeventpage',
name='end_date_time',
field=models.DateTimeField(help_text='This datetime is in UTC.'),
),
migrations.AlterField(
model_name='individualeventpage',
name='start_date_time',
field=models.DateTimeField(help_text='This datetime is in UTC.'),
),
]
18 changes: 18 additions & 0 deletions app/events/migrations/0011_eventownerpage_remove_filters_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-10-03 22:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('events', '0010_remove_eventownerpage_view_all_events_url_and_more'),
]

operations = [
migrations.AddField(
model_name='eventownerpage',
name='remove_filters_text',
field=models.CharField(default='Remove All Filters'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.7 on 2024-10-10 17:41

from django.db import migrations
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('events', '0011_eventownerpage_remove_filters_text'),
]

operations = [
migrations.AlterField(
model_name='eventownerpage',
name='view_all_events_link',
field=wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock()), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('other', wagtail.blocks.CharBlock(help_text="Only use this option as a last resort. The other fields are preferred. In cases like email 'mailto' links, however, this field can be used. Ensure that your provided link will function as intended prior to publishing live."))], blank=True, use_json_field=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.7 on 2024-10-21 21:37

from django.db import migrations
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('events', '0012_alter_eventownerpage_view_all_events_link'),
]

operations = [
migrations.AlterField(
model_name='individualeventpage',
name='extended_description',
field=wagtail.fields.StreamField([('text_block', 0)], block_lookup={0: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'code', 'blockquote']})}, null=True),
),
]
18 changes: 18 additions & 0 deletions app/events/migrations/0014_eventownerpage_applied_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-10-24 18:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('events', '0013_alter_individualeventpage_extended_description'),
]

operations = [
migrations.AddField(
model_name='eventownerpage',
name='applied_text',
field=models.CharField(default='applied', help_text='This will be a suffix to a number, used to indicate how many filters are applied currently in some field.'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.7 on 2024-11-06 23:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('events', '0014_eventownerpage_applied_text'),
]

operations = [
migrations.AddField(
model_name='eventownerpage',
name='date_date_text',
field=models.CharField(default='date'),
),
migrations.AddField(
model_name='eventownerpage',
name='date_from_text',
field=models.CharField(default='From'),
),
migrations.AddField(
model_name='eventownerpage',
name='date_to_text',
field=models.CharField(default='To'),
),
]
18 changes: 18 additions & 0 deletions app/events/migrations/0016_alter_eventownerpage_date_date_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-11-07 17:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('events', '0015_eventownerpage_date_date_text_and_more'),
]

operations = [
migrations.AlterField(
model_name='eventownerpage',
name='date_date_text',
field=models.CharField(default='Filter by Date'),
),
]
37 changes: 28 additions & 9 deletions app/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from wagtail.snippets.models import register_snippet

from app.members.models import IndividualMappingHubPage
from app.core.models import LinkOrPageBlock

from datetime import datetime


class EventOwnerPage(Page):
Expand All @@ -27,24 +30,30 @@ def get_context(self, request, *args, **kwargs):
categories = EventCategory.objects.all()
query = Q()
for category in categories:
if request.GET.get(str(category), ''):
if request.GET.get("cat" + str(category), ''):
query = query | Q(event_categories=category)
events_list = events_list.filter(query)

# these queries and filters are done in seperate parts so that filtering is done as ANDs instead of ORs
event_host_types = EventHostType.objects.all()
query = Q()
for host_type in event_host_types:
if request.GET.get(str(host_type), ''):
if request.GET.get("htype" + str(host_type.id), ''):
query = query | Q(event_host_type=host_type)
events_list = events_list.filter(query)

hubs = IndividualMappingHubPage.objects.live().filter(locale=context['page'].locale)
query = Q()
for hub in hubs:
if request.GET.get(str(hub), ''):
if request.GET.get("hub" + str(hub.id), ''):
query = query | Q(event_region_hub=hub)
events_list = events_list.filter(query).distinct()

from_date = request.GET.get("fromdate")
from_date = datetime.strptime(from_date, "%Y-%m-%d") if from_date else datetime.min
to_date = request.GET.get("todate")
to_date = datetime.strptime(to_date, "%Y-%m-%d") if to_date else datetime.max
events_list = events_list.filter(Q(start_date_time__range=[from_date,to_date]) | Q(end_date_time__range=[from_date,to_date]))

match request.GET.get('sort', ''):
case 'sort.new':
Expand Down Expand Up @@ -88,9 +97,10 @@ def get_context(self, request, *args, **kwargs):
rsvp_button_text = models.CharField(default="RSVP")
more_events_title = models.CharField(default="More Events")
view_all_events_text = models.CharField(default="View all Events")
view_all_events_url = models.URLField(blank=True)
view_all_events_link = StreamField(LinkOrPageBlock(), use_json_field=True, blank=True)
event_read_more_text = models.CharField(default="Read more")

applied_text = models.CharField(default="applied", help_text="This will be a suffix to a number, used to indicate how many filters are applied currently in some field.")
keyword_search_hint = models.CharField(default="Search by keyword")
filter_by_country = models.CharField(default="Filter by Country")
host_type_select = models.CharField(default="Filter by Host Type")
Expand All @@ -99,11 +109,16 @@ def get_context(self, request, *args, **kwargs):
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")
date_date_text = models.CharField(default="Filter by Date")
date_from_text = models.CharField(default="From")
date_to_text = models.CharField(default="To")
search_button_text = models.CharField(default="Search")
remove_filters_text = models.CharField(default="Remove All Filters")
results_text = models.CharField(default="Results")

content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('applied_text'),
FieldPanel('keyword_search_hint'),
FieldPanel('filter_by_country'),
FieldPanel('host_type_select'),
Expand All @@ -112,7 +127,11 @@ def get_context(self, request, *args, **kwargs):
FieldPanel('sort_by_old'),
FieldPanel('sort_by_titlea'),
FieldPanel('sort_by_titlez'),
FieldPanel('date_from_text'),
FieldPanel('date_to_text'),
FieldPanel('date_date_text'),
FieldPanel('search_button_text'),
FieldPanel('remove_filters_text'),
FieldPanel('results_text'),
], heading="Event Search Page"),
MultiFieldPanel([
Expand All @@ -123,7 +142,7 @@ def get_context(self, request, *args, **kwargs):
FieldPanel('rsvp_button_text'),
FieldPanel('more_events_title'),
FieldPanel('view_all_events_text'),
FieldPanel('view_all_events_url'),
FieldPanel('view_all_events_link'),
FieldPanel('event_read_more_text'),
], heading="Individual Event Page"),
]
Expand Down Expand Up @@ -159,13 +178,13 @@ class Meta:
verbose_name_plural = "Event Categories"


class IndividualEventPage(Page):
class IndividualEventPage(Page):
parent_page_types = [
'events.EventOwnerPage'
]

start_date_time = models.DateTimeField()
end_date_time = models.DateTimeField()
start_date_time = models.DateTimeField(help_text="This datetime is in UTC.")
end_date_time = models.DateTimeField(help_text="This datetime is in UTC.")

image = models.ForeignKey(
"wagtailimages.Image",
Expand All @@ -178,7 +197,7 @@ class IndividualEventPage(Page):
intro = RichTextField(blank=True)
extended_description = StreamField([
('text_block', RichTextBlock(features=[
'h1', 'h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'code', 'blockquote'
'h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'code', 'blockquote'
]))
], use_json_field=True, null=True)

Expand Down
Loading

0 comments on commit 4775b8c

Please sign in to comment.