summaryrefslogtreecommitdiff
path: root/addons/website_event/controllers/main.py
diff options
context:
space:
mode:
authorqmo-odoo <qmo@odoo.com>2020-01-17 10:22:08 +0000
committerThibault Delavallée <tde@odoo.com>2020-02-18 09:24:26 +0000
commitb8e33b24391dff076c21b53d85abb4f2c9692828 (patch)
treeb21e9a99cd79e7033b9955267af226b36586e00c /addons/website_event/controllers/main.py
parentf652912398c2ff1ca174f47f30f7bef73605caec (diff)
[IMP] website_event: improve front-end display
This commit makes a few design improvements in the Event list in front-end after some feedback about its usability - Make the 'configure your registration' alter not editable (for studio) - Display the "is online" through a "tag" design, not just text - Remove remaining seats count - Some display cleaning and improvements (design) - Put the event date just below event title on event frontend list - apply some minor design improvements in the /register page. - Filter by month instead of weeks : This commit changes the date filtering in website_event. Before this commit, users could filter events by weeks. After this commit, users will be able to filter by months and will be able to filter events up to two months in the future. LINKS TaskID 2162438 Community PR odoo/odoo#44476 Co-Authored-By: David Beguin <dbe@odoo.com> Co-Authored-By: Quentin Mourier <qmo@odoo.com>
Diffstat (limited to 'addons/website_event/controllers/main.py')
-rw-r--r--addons/website_event/controllers/main.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index dfb66f7f834..5733639002f 100644
--- a/addons/website_event/controllers/main.py
+++ b/addons/website_event/controllers/main.py
@@ -12,7 +12,7 @@ from odoo import fields, http, _
from odoo.addons.http_routing.models.ir_http import slug
from odoo.addons.website.controllers.main import QueryURL
from odoo.http import request
-from odoo.tools.misc import get_lang
+from odoo.tools.misc import get_lang, format_date
class WebsiteEventController(http.Controller):
@@ -32,37 +32,35 @@ class WebsiteEventController(http.Controller):
searches.setdefault('country', 'all')
website = request.website
+ today = datetime.today()
def sdn(date):
return fields.Datetime.to_string(date.replace(hour=23, minute=59, second=59))
def sd(date):
return fields.Datetime.to_string(date)
- today = datetime.today()
+
+ def get_month_filter_domain(filter_name, months_delta):
+ first_day_of_the_month = today.replace(day=1)
+ filter_string = _('This month') if months_delta == 0 \
+ else format_date(request.env, value=today + relativedelta(months=months_delta),
+ date_format='LLLL', lang_code=get_lang(request.env).code).capitalize()
+ return [filter_name, filter_string, [
+ ("date_end", ">=", sd(first_day_of_the_month + relativedelta(months=months_delta))),
+ ("date_begin", "<", sd(first_day_of_the_month + relativedelta(months=months_delta+1)))],
+ 0]
+
dates = [
- ['all', _('Next Events'), [("date_end", ">", sd(today))], 0],
+ ['all', _('Upcoming Events'), [("date_end", ">", sd(today))], 0],
['today', _('Today'), [
("date_end", ">", sd(today)),
("date_begin", "<", sdn(today))],
0],
- ['week', _('This Week'), [
- ("date_end", ">=", sd(today + relativedelta(days=-today.weekday()))),
- ("date_begin", "<", sdn(today + relativedelta(days=6-today.weekday())))],
- 0],
- ['nextweek', _('Next Week'), [
- ("date_end", ">=", sd(today + relativedelta(days=7-today.weekday()))),
- ("date_begin", "<", sdn(today + relativedelta(days=13-today.weekday())))],
- 0],
- ['month', _('This month'), [
- ("date_end", ">=", sd(today.replace(day=1))),
- ("date_begin", "<", (today.replace(day=1) + relativedelta(months=1)).strftime('%Y-%m-%d 00:00:00'))],
- 0],
- ['nextmonth', _('Next month'), [
- ("date_end", ">=", sd(today.replace(day=1) + relativedelta(months=1))),
- ("date_begin", "<", (today.replace(day=1) + relativedelta(months=2)).strftime('%Y-%m-%d 00:00:00'))],
- 0],
+ get_month_filter_domain('month', 0),
+ get_month_filter_domain('nextmonth1', 1),
+ get_month_filter_domain('nextmonth2', 2),
['old', _('Past Events'), [
- ("date_end", "<", today.strftime('%Y-%m-%d 00:00:00'))],
+ ("date_end", "<", sd(today))],
0],
]