summaryrefslogtreecommitdiff
path: root/addons/website_event/controllers/main.py
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2017-09-27 19:23:05 +0200
committerJeremy Kersten <jke@odoo.com>2017-09-27 21:33:49 +0200
commit1b52b00d2aa96b9360d50a0f0960f1febb5e607e (patch)
tree2e098cf6268b0c2fe6d2844e94b45cc801ce4093 /addons/website_event/controllers/main.py
parent3d0d8b89d1e7a32a5ef8aa0f40d41a4fb5260c1c (diff)
[IMP] website*: clean sitemap + add method to declare sitemap function.
Don't add useless routes or route that will return 404. Improve generate function from ModelConverter to have a better management of query_string. Now we have an helper sitemap_qs2dom that will analyse the current route and check if query string is plausible and if yes, generate a domain, when the query_string don't seems to match the route, we return a Falsy domain. Before this commit, if qs was /product/ipad, enumerate_page check for each modelconverter of the route a name ilike '/product/ipad'. Now we check all routes that contains product and one converter that match ipad or routes that contains ipad and one converter that match product. This commit a new way to declare the sitemap for a route. def sitemap_xx(env, rule, query_string): yield {'loc': '/my_url'} @http.route(..., sitemap=sitemap_xx) In this case, only the loc returned by this function will be in the sitemap for all rules. You can pass sitempa=False, if you don't want that route are into the sitemap
Diffstat (limited to 'addons/website_event/controllers/main.py')
-rw-r--r--addons/website_event/controllers/main.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index ff1f9c00ce1..28ac0c17a8a 100644
--- a/addons/website_event/controllers/main.py
+++ b/addons/website_event/controllers/main.py
@@ -13,7 +13,11 @@ from odoo.http import request
class WebsiteEventController(http.Controller):
- @http.route(['/event', '/event/page/<int:page>', '/events', '/events/page/<int:page>'], type='http', auth="public", website=True)
+ def sitemap_event(env, rule, qs):
+ if not qs or qs.lower() in '/events':
+ yield {'loc': '/events'}
+
+ @http.route(['/event', '/event/page/<int:page>', '/events', '/events/page/<int:page>'], type='http', auth="public", website=True, sitemap=sitemap_event)
def events(self, page=1, **searches):
Event = request.env['event.event']
EventType = request.env['event.type']
@@ -133,7 +137,7 @@ class WebsiteEventController(http.Controller):
return request.render("website_event.index", values)
- @http.route(['/event/<model("event.event"):event>/page/<path:page>'], type='http', auth="public", website=True)
+ @http.route(['/event/<model("event.event"):event>/page/<path:page>'], type='http', auth="public", website=True, sitemap=False)
def event_page(self, event, page, **post):
values = {
'event': event,
@@ -163,7 +167,7 @@ class WebsiteEventController(http.Controller):
target_url += '?enable_editor=1'
return request.redirect(target_url)
- @http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True)
+ @http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True, sitemap=False)
def event_register(self, event, **post):
values = {
'event': event,