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