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

[16.0][ADD] website_event_filter_city #403

Open
wants to merge 27 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a17ddb9
[8.0][website_event_filter_selector] Filter events with selectors.
yajo Mar 23, 2016
fbe4dd1
[IMP] website_event_filter_selector
pedrobaeza Apr 28, 2016
338ce1a
[9.0][website_event_filter_selector] Migrate.
yajo Dec 19, 2016
cd631c1
[10.0][MIG][website_event_filter_selector]
yajo Jun 22, 2017
0eecdc3
[MIG] website_event_filter_selector: Migration to 11.0
tarteo May 30, 2018
3872138
[12.0][MIG] website_event_filter_selector
cristinamartinrod Mar 1, 2019
bec5c27
[FIX] website_event_filter_selector: Update tour
yajo Apr 16, 2019
c02c2c8
[UPD] Update website_event_filter_selector.pot
oca-travis Aug 20, 2019
c23d3dd
[IMP] website_event_filter_selector: simpler automatic width
Apr 23, 2020
f51a949
[IMP] website_event_filter_selector: make prettier
Apr 24, 2020
01bc8d9
[IMP] website_event_filter_selector: black, isort, prettier
victoralmau Feb 26, 2021
8c7a5a1
[MIG] website_event_filter_selector: Migration to 13.0
victoralmau Feb 26, 2021
1ed55a9
[FIX] website_event_filter_selector: ignore events from other websites
Aug 3, 2021
c922b8d
[IMP] website_event_filter_selector: maintain it
Aug 5, 2021
6aaeaa8
[IMP/FIX] website_event_filter_city: search input and refactor
chienandalu Mar 7, 2022
35a6398
[IMP] website_event_filter_city: black, isort, prettier
chienandalu Mar 14, 2023
1ee0d9f
[MIG] website_event_filter_city: Migration to 15.0
chienandalu Apr 3, 2023
83253dc
[UPD] Update website_event_filter_city.pot
Apr 5, 2023
ef8f274
[UPD] README.rst
OCA-git-bot Apr 5, 2023
f208015
Update translation files
weblate Apr 5, 2023
cc862ae
Added translation using Weblate (Italian)
mymage Jul 18, 2023
ce13762
Translated using Weblate (Italian)
mymage Jul 20, 2023
2a3e820
Translated using Weblate (Italian)
mymage Jul 28, 2023
cd1157f
[UPD] README.rst
OCA-git-bot Sep 3, 2023
49353cd
Update translation files
weblate Oct 9, 2023
0cc2c8b
Translated using Weblate (Spanish)
Ivorra78 Oct 29, 2023
a1a6b45
[IMP] website_event_filter_city: pre-commit stuff
enieber Sep 17, 2024
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
6 changes: 6 additions & 0 deletions setup/website_event_filter_city/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
110 changes: 110 additions & 0 deletions website_event_filter_city/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
=========================
Website Event Filter City
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dbdc08c4ea0aad7a845adfcd04595c64ac140f8c54158a88086484e2b9a18489
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github
:target: https://github.com/OCA/event/tree/16.0/website_event_filter_city
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-16-0/event-16-0-website_event_filter_city
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of the events website page to support
using filter events by city.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to `your website events page </event>`_.
#. Use the *Customize* menu to choose if you want to use the *Filter
by City*, and which if so.

Known issues / Roadmap
======================

* You cannot run the tests unless you are in a bare database with demo data.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/event/issues/new?body=module:%20website_event_filter_city%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Antiun Ingeniería S.L.
* Tecnativa
* Onestein

Contributors
~~~~~~~~~~~~

* Dennis Sluijk <[email protected]>
* Cristina Martin R.

* `Tecnativa <https://www.tecnativa.com>`_:

* Rafael Blasco
* Pedro Baeza
* Jairo Llopis
* Víctor Martínez
* David Vidal

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-Yajo| image:: https://github.com/Yajo.png?size=40px
:target: https://github.com/Yajo
:alt: Yajo

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Yajo|

This module is part of the `OCA/event <https://github.com/OCA/event/tree/16.0/website_event_filter_city>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions website_event_filter_city/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import controllers, models
29 changes: 29 additions & 0 deletions website_event_filter_city/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2016-2017 Tecnativa - Jairo Llopis
# Copyright 2019 Tecnativa - Cristina Martin R.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Website Event Filter City",
"summary": "Add a customizable top area to filter events with city",
"version": "16.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/event",
"author": "Antiun Ingeniería S.L., "
"Tecnativa, "
"Onestein, "
"Odoo Community Association (OCA)",
"maintainers": ["Yajo"],
"license": "LGPL-3",
"installable": True,
"depends": ["website_event"],
"data": ["templates/event.xml"],
"demo": ["demo/tour_data.xml"],
"images": [
"static/description/all.png",
"static/description/icon.png",
],
"assets": {
"web.assets_tests": [
"/website_event_filter_city/static/src/js/*.js",
]
},
}
3 changes: 3 additions & 0 deletions website_event_filter_city/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import main
70 changes: 70 additions & 0 deletions website_event_filter_city/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2016-2017 Tecnativa - Jairo Llopis
# Copyright 2023 Tecnativa - David Vidal
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import _
from odoo.http import request, route

from odoo.addons.website_event.controllers.main import WebsiteEventController


class WebsiteEvent(WebsiteEventController):
@route()
def events(self, page=1, **searches):
searches.setdefault("city", _("All Cities"))
# Inject our city in `_search_with_fuzzy` which ends up in `event.event`
# `_search_get_detail` override.
if searches["city"] != _("All Cities"):
request.website = request.website.with_context(
event_filter_city=searches["city"]
)
response = super().events(page, **searches)
# We can avoid ugly mokeypatching using the domains that we get in return from
# the qcontext values, that are already injected with our city filters. This
# way we can easily make city filter compatible with the other filters.
qcontext = response.qcontext
# We can rely in this domain by default
domain = next(
(
domain
for _, name, domain, _ in qcontext["dates"]
if name == qcontext["current_date"]
),
qcontext["dates"][0][2],
)
# This domain includes all the other filters
if qcontext["current_country"]:
domain = next(
country_domain["__domain"]
for country_domain in qcontext["countries"][1:]
if country_domain["country_id"]
and country_domain["country_id"][0] == qcontext["current_country"].id
)
# Otherwise, we can make some domain surgery to reuse the domain country for
# our own purposes.
elif len(qcontext["countries"]) > 1:
domain = qcontext["countries"][1]["__domain"]
countries_domain = [
"|",
("country_id", "=", False),
("country_id", "!=", False),
]
country_tuple_index = next(
i for i, x in enumerate(domain) if len(x) > 1 and x[0] == "country_id"
)
domain.pop(country_tuple_index)
domain[country_tuple_index : len(countries_domain)] = countries_domain
# Finally we can use the domain we obtained to filter the cities in the controls
cities = request.env["event.event"].read_group(
domain, ["city"], groupby="city", orderby="city"
)
cities.insert(
0,
{
"city_count": sum(x["city_count"] for x in cities),
"city": _("All Cities"),
},
)
qcontext["cities"] = cities
qcontext["current_city"] = searches["city"]
return response
90 changes: 90 additions & 0 deletions website_event_filter_city/demo/tour_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019 Tecnativa - Jairo Llopis
Copyright 2021 Tecnativa - Víctor Martínez
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
<!-- Data required to run the tour without depending on upstream demo data -->
<data>
<record id="partner_barcelona" model="res.partner">
<field name="city">Barcelona</field>
<field name="country_id" ref="base.es" />
<field name="email">[email protected]</field>
<field name="is_company" eval="True" />
<field name="name">Hotel Català</field>
<field name="street">Carrer Català</field>
</record>
<record id="partner_sevilla" model="res.partner">
<field name="city">Sevilla</field>
<field name="country_id" ref="base.es" />
<field name="email">[email protected]</field>
<field name="is_company" eval="True" />
<field name="name">Hotel Aceite de Jerez</field>
<field name="street">C/ Alquería</field>
</record>
<record id="event_type_code_sprint" model="event.tag">
<field name="name">Code Sprint</field>
<field name="sequence">30</field>
<field name="category_id" ref="event.event_tag_category_3" />
<field name="color">10</field>
</record>
<record id="event_type_breakfast" model="event.tag">
<field name="name">Breakfast</field>
<field name="sequence">40</field>
<field name="category_id" ref="event.event_tag_category_3" />
<field name="color">11</field>
</record>
<record id="event_barcelona" model="event.event">
<field name="address_id" ref="partner_barcelona" />
<field name="date_begin">2017-05-29 09:00:00</field>
<field name="date_end">2017-05-31 19:00:00</field>
<field
name="tag_ids"
eval="[(4, ref('website_event_filter_city.event_type_code_sprint'))]"
/>
<field name="name">Barcelona Days 2017</field>
<field name="seats_limited" eval="True" />
<field name="seats_max">500</field>
<field name="user_id" ref="base.user_admin" />
<field name="website_published" eval="True" />
</record>
<record id="event_sevilla_cs" model="event.event">
<field name="address_id" ref="partner_sevilla" />
<field name="date_begin">2018-06-11 09:00:00</field>
<field name="date_end">2018-06-13 19:00:00</field>
<field
name="tag_ids"
eval="[(4, ref('website_event_filter_city.event_type_code_sprint'))]"
/>
<field name="name">Sevilla Code Sprint 2018</field>
<field name="seats_limited" eval="True" />
<field name="seats_max">200</field>
<field name="user_id" ref="base.user_admin" />
<field name="website_published" eval="True" />
</record>
<record id="event_sevilla_bf" model="event.event">
<field name="address_id" ref="partner_sevilla" />
<field name="date_begin">2018-06-11 08:00:00</field>
<field name="date_end">2018-06-11 09:00:00</field>
<field
name="tag_ids"
eval="[(4, ref('website_event_filter_city.event_type_breakfast'))]"
/>
<field name="name">Sevilla Awesome Breakfast 2018</field>
<field name="seats_limited" eval="True" />
<field name="seats_max">10</field>
<field name="user_id" ref="base.user_admin" />
<field name="website_published" eval="True" />
</record>
<record id="event_online" model="event.event">
<field name="address_id" eval="False" />
<field name="date_begin">2018-04-18 09:00:00</field>
<field name="date_end">2018-04-20 19:00:00</field>
<field
name="tag_ids"
eval="[(4, ref('website_event_filter_city.event_type_breakfast'))]"
/>
<field name="name">Online Code Sprint 2018</field>
<field name="seats_limited" eval="False" />
<field name="user_id" ref="base.user_admin" />
<field name="website_published" eval="True" />
</record>
</data>
Loading
Loading