Skip to content
Extraits de code Groupes Projets
Valider 93f2dd7d rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[ADD]Add tag on search calendar

parent f4d999fe
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -178,19 +178,41 @@ class WebsiteEventController(WebsiteEventController):
sitemap=False,
)
def event_agenda_session(self, event, tag=None, **post):
post.setdefault("tags", "")
event = event.with_context(tz=event.date_tz or "UTC")
tag_categories = request.env["event.tag.category"].search(
[("is_published", "=", True)]
)
search_domain_items = []
# search on tags
search_tags = self._get_search_tags(post["tags"])
if not search_tags and tag:
search_tags = tag
if search_tags:
grouped_tags = dict()
for search_tag in search_tags:
grouped_tags.setdefault(search_tag.category_id, list()).append(
search_tag
)
search_domain_items = [
[("tag_ids", "in", [tag.id for tag in grouped_tags[group]])]
for group in grouped_tags
]
vals = {
"search_tags": search_tags,
"tag_categories": tag_categories,
"event": event,
"main_object": event,
"tag": tag,
"is_event_user": request.env.user.has_group("event.group_event_user"),
}
vals.update(self._prepare_calendar_values(event))
vals.update(self._prepare_calendar_values(event, search_domain_items))
return request.render("cgscop_website_event.agenda_online", vals)
def _prepare_calendar_values(self, event):
def _prepare_calendar_values(self, event, search_domain_items=False):
"""This methods slit the day (max end time - min start time) into
15 minutes time slots. For each time slot, we assign the sessions that
start at this specific time slot, and we add the number of time slot
......@@ -208,6 +230,9 @@ class WebsiteEventController(WebsiteEventController):
[("date_begin", "!=", False)],
]
)
if search_domain_items:
base_session_domain = expression.AND([base_session_domain, *search_domain_items])
sessions_sudo = request.env["event.session"].sudo().search(base_session_domain)
# First split day by day (based on start time)
......
......@@ -66,45 +66,45 @@
</template>
<!-- Option: Topbar: optional tags filters-->
<!--<template-->
<!-- id="agenda_session_topbar_tag"-->
<!-- inherit_id="cgscop_website_event.agenda_topbar"-->
<!-- name="Filtrer par Tags"-->
<!-- active="True"-->
<!-- >-->
<!-- <xpath expr="//ul[hasclass('o_weagenda_topbar_filters')]" position="inside">-->
<!-- <t t-foreach="tag_categories" t-as="tag_category">-->
<!-- <li-->
<!-- t-if="tag_category.tag_ids and any(tag.color for tag in tag_category.tag_ids)"-->
<!-- class="nav-item dropdown me-2 my-1"-->
<!-- >-->
<!-- <a-->
<!-- href="#"-->
<!-- role="button"-->
<!-- class="btn dropdown-toggle"-->
<!-- data-bs-toggle="dropdown"-->
<!-- >-->
<!-- <i class="fa fa-folder-open" />-->
<!-- <t t-out="tag_category.name" />-->
<!-- </a>-->
<!-- <div class="dropdown-menu">-->
<!-- <t t-foreach="tag_category.tag_ids" t-as="tag">-->
<!-- <a-->
<!-- t-att-href="'/event/%s/session?%s' % (-->
<!-- slug(event),-->
<!-- keep_query('*', tags=str((search_tags - tag).ids if tag in search_tags else (tag | search_tags).ids))-->
<!-- )"-->
<!-- t-if="tag.color"-->
<!-- t-attf-class="dropdown-item d-flex align-items-center justify-content-between #{'active' if tag in search_tags else ''}"-->
<!-- >-->
<!-- <t t-out="tag.name" />-->
<!-- </a>-->
<!-- </t>-->
<!-- </div>-->
<!-- </li>-->
<!-- </t>-->
<!-- </xpath>-->
<!--</template>-->
<template
id="agenda_session_topbar_tag"
inherit_id="cgscop_website_event.agenda_topbar"
name="Filtrer par Tags"
active="True"
>
<xpath expr="//ul[hasclass('o_weagenda_topbar_filters')]" position="inside">
<t t-foreach="tag_categories" t-as="tag_category">
<li
t-if="tag_category.tag_ids and any(tag.color for tag in tag_category.tag_ids)"
class="nav-item dropdown me-2 my-1"
>
<a
href="#"
role="button"
class="btn dropdown-toggle"
data-bs-toggle="dropdown"
>
<i class="fa fa-folder-open" />
<t t-out="tag_category.name" />
</a>
<div class="dropdown-menu">
<t t-foreach="tag_category.tag_ids" t-as="tag">
<a
t-att-href="'/event/%s/agenda-sessions?%s' % (
slug(event),
keep_query('*', tags=str((search_tags - tag).ids if tag in search_tags else (tag | search_tags).ids))
)"
t-if="tag.color"
t-attf-class="dropdown-item d-flex align-items-center justify-content-between #{'active' if tag in search_tags else ''}"
>
<t t-out="tag.name" />
</a>
</t>
</div>
</li>
</t>
</xpath>
</template>
<!-- ============================================================ -->
<!-- CONTENT: MAIN TEMPLATES -->
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter