-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INTR-318 Event listing page updates and filtering (#753)
- Loading branch information
Showing
8 changed files
with
164 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import django_filters | ||
from django import forms | ||
|
||
from events import types | ||
from peoplefinder.services.uk_staff_locations import UkStaffLocationService | ||
|
||
|
||
EVENT_TYPE_ALL_VALUE = "" | ||
EVENT_TYPE_CHOICES = [ | ||
(EVENT_TYPE_ALL_VALUE, "All types"), | ||
(types.EventType.IN_PERSON, "In person"), | ||
(types.EventType.ONLINE, "Online"), | ||
] | ||
|
||
|
||
class EventsFilters(django_filters.FilterSet): | ||
event_type = django_filters.ChoiceFilter( | ||
method="event_format_filter", | ||
choices=EVENT_TYPE_CHOICES, | ||
widget=forms.widgets.RadioSelect, | ||
empty_label=None, | ||
) | ||
|
||
location = django_filters.ChoiceFilter( | ||
field_name="location__city", | ||
choices=[ | ||
(c, c) for c in UkStaffLocationService().get_uk_staff_location_cities() | ||
], | ||
lookup_expr="exact", | ||
widget=forms.widgets.Select, | ||
) | ||
|
||
def event_format_filter(self, queryset, name, value): | ||
if value == EVENT_TYPE_ALL_VALUE: | ||
return queryset | ||
|
||
event_types = [types.EventType.HYBRID] | ||
event_types.append(types.EventType(value)) | ||
|
||
return queryset.filter(event_type__in=event_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/events/templates/events/includes/event_listing_section.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% load wagtailcore_tags %} | ||
{% load wagtailimages_tags %} | ||
|
||
<ul> | ||
{% for event in events %} | ||
<li> | ||
<h2> | ||
<a href="{% pageurl event %}">{{ event.title }}</a> | ||
</h2> | ||
<p>{{ event.event_date }}</p> | ||
{% image event.preview_image width-540 %} | ||
<p>{{ event.description }}</p> | ||
</li> | ||
{% endfor %} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters