Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qa/sept4 #41

Merged
merged 15 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG PYTHON_IMG_TAG=3.11
ARG NODE_IMG_TAG=20.5.1

FROM node:${NODE_IMG_TAG}-bookworm-slim as frontend-base

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY . ./app
WORKDIR /app/frontend
RUN mkdir -p ./node_modules
Expand All @@ -23,19 +23,19 @@
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
# Set locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8

Check warning on line 32 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LANGUAGE en_US:en

Check warning on line 33 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LC_ALL en_US.UTF-8

Check warning on line 34 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/


# Extract dependencies using poetry (to requirements.txt)
FROM base as extract-deps

Check warning on line 38 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
WORKDIR /opt/python
COPY pyproject.toml poetry.lock* /opt/python/
RUN pip install --no-cache-dir --upgrade pip \
Expand All @@ -61,6 +61,7 @@
"libwebp-dev" \
"nodejs" \
"npm" \
"libmagickwand-dev" \
&& rm -rf /var/lib/apt/lists/*
COPY --from=extract-deps \
/opt/python/requirements.txt /opt/python/
Expand All @@ -69,7 +70,7 @@
--no-cache-dir -r /opt/python/requirements.txt

# Define run stage
FROM base as runtime

Check warning on line 73 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
ARG PYTHON_IMG_TAG
ENV PORT=8000 \
PYTHONDONTWRITEBYTECODE=1 \
Expand All @@ -94,6 +95,7 @@
"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 Expand Up @@ -121,7 +123,7 @@


# Define dev-deps stage (install requirements-dev)
FROM runtime as dev-deps

Check warning on line 126 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY --from=extract-deps --chown=wagtail \
/opt/python/requirements-dev.txt /home/wagtail/
RUN pip install --user --no-warn-script-location \
Expand All @@ -130,7 +132,7 @@


# Define test (ci) stage
FROM dev-deps as test

Check warning on line 135 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
USER root
ARG PYTHON_IMG_TAG
# Copy packages from user to root dirs (run ci as root)
Expand All @@ -144,7 +146,7 @@


# Define debug (development) stage
FROM dev-deps as debug

Check warning on line 149 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
# Add Healthcheck
HEALTHCHECK --start-period=10s --interval=5s --retries=20 --timeout=5s \
CMD curl --fail http://localhost:8000 || exit 1
Expand All @@ -152,7 +154,7 @@


# Define prod stage
FROM runtime as prod

Check warning on line 157 in Dockerfile

View workflow job for this annotation

GitHub Actions / pytest / test-img-build / build-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
# Add Healthcheck
HEALTHCHECK --start-period=10s --interval=5s --retries=20 --timeout=5s \
CMD curl --fail http://localhost:8000 || exit 1
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
Loading