Skip to content
Snippets Groups Projects
Commit 9ab5a1d0 authored by cubicroot's avatar cubicroot Committed by weeman
Browse files

Räume zur Suche hinzufügen

parent d1f01ac0
No related branches found
No related tags found
No related merge requests found
......@@ -6,13 +6,14 @@ from django.contrib.postgres.search import SearchQuery
from .models.assemblies import Assembly
from .models.conference import Conference, ConferenceTrack
from .models.events import Event
from .models.rooms import Room
from .models.tags import ConferenceTag
from .models.users import PlatformUser
def search(
user: PlatformUser, conference: Conference, search_term: str, max_per_category: int = 10
) -> Iterator[ConferenceTag | ConferenceTrack | Assembly | Event]:
) -> Iterator[ConferenceTag | ConferenceTrack | Assembly | Event | Room]:
"""
Search assemblies, events, pages and tags for the search_term(s).
Matches on the name are ranked higher than those only in the description.
......@@ -65,6 +66,7 @@ def search(
# tracking which assemblies we've already seen so we don't return them twice
assemblies_seen = []
events_seen = []
rooms_seen = []
# name match on Assembly
assemblies = apply_terms_name(Assembly.objects.conference_accessible(conference=conference))[:max_per_category]
......@@ -78,6 +80,12 @@ def search(
events_seen.append(e.pk)
yield e
# name match on Room
rooms = apply_terms_name(Room.objects.conference_accessible(conference=conference))[:max_per_category]
for r in rooms:
rooms_seen.append(r.pk)
yield r
# description match on Assembly
if len(assemblies) < max_per_category:
description_matches = Assembly.objects.conference_accessible(conference=conference).exclude(pk__in=assemblies_seen)
......@@ -87,3 +95,8 @@ def search(
if len(events) < max_per_category:
description_matches = Event.objects.conference_accessible(conference=conference).exclude(pk__in=events_seen)
yield from apply_terms_description(description_matches)[: max_per_category - len(events)]
# description match on Room
if len(rooms) < max_per_category:
description_matches = Room.objects.conference_accessible(conference=conference).exclude(pk__in=rooms_seen)
yield from apply_terms_description(description_matches)[: max_per_category - len(rooms)]
......@@ -15,19 +15,19 @@
{%- for result in search_results %}
<div class="hub-list-item">
{% if result.type == 'Event' %}
{{ tagMacros.tag(result.type,
{{ tagMacros.tag(_('Event') ,
style='clear',
icon='calendar-week') }}
<a class="hub-text-list-item-title"
href="{{ url('plainui:event', event_slug=result.item.slug) }}">{{ result.item }}</a>
{% elif result.type == 'Assembly' %}
{{ tagMacros.tag(result.type,
{{ tagMacros.tag(_('Assembly') ,
style='clear',
icon='person-arms-up') }}
<a class="hub-text-list-item-title"
href="{{ url('plainui:assembly', assembly_slug=result.item.slug) }}">{{ result.item }}</a>
{% elif result.type == 'ConferenceTag' %}
{{ tagMacros.tag(result.type,
{{ tagMacros.tag(_('ConferenceTag') ,
style='clear',
icon='tag') }}
<a class="hub-text-list-item-title"
......@@ -35,11 +35,17 @@
{% elif result.type == 'ConferenceTrack' %}
{{ result.type }}: {{ result.item }}
{% elif result.type == 'StaticPage' %}
{{ tagMacros.tag('Page',
{{ tagMacros.tag(_('StaticPage') ,
style='clear',
icon='book') }}
<a class="hub-text-list-item-title"
href="{{ url('plainui:static_page', page_slug=result.item.slug) }}">{{ result.item }}</a>
{% elif result.type == 'Room' %}
{{ tagMacros.tag(_('Room') ,
style='clear',
icon='geo-alt-fill') }}
<a class="hub-text-list-item-title"
href="{{ url('plainui:room', slug=result.item.slug) }}">{{ result.item }}</a>
{% else %}
{{ result.type }}: {{ result.item }}
{% endif %}
......
......@@ -1059,6 +1059,12 @@ msgstr "Raum"
msgid "Rooms"
msgstr "Räume"
msgid "ConferenceTag"
msgstr ""
msgid "StaticPage"
msgstr "Wiki-Seite"
#, python-format
msgid "%(conf)s - Registration"
msgstr "%(conf)s - Registrierung"
......
......@@ -1059,6 +1059,12 @@ msgstr ""
msgid "Rooms"
msgstr ""
msgid "ConferenceTag"
msgstr ""
msgid "StaticPage"
msgstr "Wiki Page"
#, python-format
msgid "%(conf)s - Registration"
msgstr ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment