From 95e7c0f61c8ef042845150888a89f9c3902b9264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 24 Sep 2013 12:52:06 +0200 Subject: [IMP] website_event: use website_mail follow template and controller instead of redefining it bzr revid: tde@openerp.com-20130924105206-9fhzpd3f3os1eyar --- addons/website_event/controllers/main.py | 70 +++++++++----------------------- 1 file changed, 20 insertions(+), 50 deletions(-) (limited to 'addons/website_event/controllers/main.py') diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index 0b61534a84b..aef99fa0ac1 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -1,4 +1,23 @@ # -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP SA (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## from openerp import SUPERUSER_ID from openerp.addons.web import http @@ -126,11 +145,9 @@ class website_event(http.Controller): values = { 'event_id': event_obj.browse(request.cr, request.uid, event_id, dict(request.context, show_address=1)), - 'message_ids': event_obj.browse(request.cr, request.uid, event_id, request.context).message_ids, - 'subscribe': post.get('subscribe'), 'range': range } - return request.website.render("website_event.detail", values) + return request.website.render("website_event.event_description_full", values) @website.route(['/event//add_cart'], type='http', auth="public") def add_cart(self, event_id=None, **post): @@ -182,50 +199,3 @@ class website_event(http.Controller): if not _values: return werkzeug.utils.redirect("/event/%s/" % event_id) return werkzeug.utils.redirect("/shop/checkout") - - @website.route(['/event//subscribe'], type='http', auth="public") - def subscribe(self, event_id=None, **post): - partner_obj = request.registry['res.partner'] - event_obj = request.registry['event.event'] - user_obj = request.registry['res.users'] - - if event_id and 'subscribe' in post and (post.get('email') or not request.context['is_public_user']): - if request.context['is_public_user']: - partner_ids = partner_obj.search( - request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))], - context=request.context) - if not partner_ids: - partner_data = { - "email": post.get('email'), - "name": "Subscribe: %s" % post.get('email') - } - partner_ids = [partner_obj.create( - request.cr, SUPERUSER_ID, partner_data, context=request.context)] - else: - partner_ids = [user_obj.browse( - request.cr, request.uid, request.uid, - context=request.context).partner_id.id] - event_obj.check_access_rule(request.cr, request.uid, [event_id], - 'read', request.context) - event_obj.message_subscribe(request.cr, SUPERUSER_ID, [event_id], - partner_ids, request.context) - - return self.event(event_id=event_id, subscribe=post.get('email')) - - @website.route(['/event//unsubscribe'], type='http', auth="public") - def unsubscribe(self, event_id=None, **post): - partner_obj = request.registry['res.partner'] - event_obj = request.registry['event.event'] - user_obj = request.registry['res.users'] - - if event_id and 'unsubscribe' in post and (post.get('email') or not request.context['is_public_user']): - if request.context['is_public_user']: - partner_ids = partner_obj.search( - request.cr, SUPERUSER_ID, [("email", "=", post.get('email'))], - context=request.context) - else: - partner_ids = [user_obj.browse(request.cr, request.uid, request.uid, request.context).partner_id.id] - event_obj.check_access_rule(request.cr, request.uid, [event_id], 'read', request.context) - event_obj.message_unsubscribe(request.cr, SUPERUSER_ID, [event_id], partner_ids, request.context) - - return self.event(event_id=event_id, subscribe=None) -- cgit v1.2.3 From 6a3939f9325f94284d56b54c62f4f362a4c8b08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 24 Sep 2013 13:19:57 +0200 Subject: [IMP] website_event: title of the main events page summarises the search bzr revid: tde@openerp.com-20130924111957-mzxnibdgbb8d09zo --- addons/website_event/controllers/main.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'addons/website_event/controllers/main.py') diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index aef99fa0ac1..7843df406e5 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -37,7 +37,10 @@ class website_event(http.Controller): @website.route(['/event/', '/event/page//'], type='http', auth="public") def events(self, page=1, **searches): + cr, uid, context = request.cr, request.uid, request.context event_obj = request.registry['event.event'] + type_obj = request.registry['event.type'] + country_obj = request.registry['res.country'] searches.setdefault('date', 'all') searches.setdefault('type', 'all') @@ -73,13 +76,19 @@ class website_event(http.Controller): ] # search domains + current_date = dates[0][1] + current_type = None + current_country = None for date in dates: - if searches.get("date") == date[0]: + if searches["date"] == date[0]: domain_search["date"] = date[2] - if searches.get("type", "all") != 'all': - domain_search["type"] = [("type", "=", int(searches.get("type")))] - if searches.get("country", "all") != 'all': - domain_search["country"] = [("country_id", "=", int(searches.get("country")))] + current_date = date[1] + if searches["type"] != 'all': + current_type = type_obj.browse(cr, uid, int(searches['type']), context=context) + domain_search["type"] = [("type", "=", int(searches["type"]))] + if searches["country"] != 'all': + current_country = country_obj.browse(cr, uid, int(searches['country']), context=context) + domain_search["country"] = [("country_id", "=", int(searches["country"]))] def dom_without(without): domain = SUPERUSER_ID != request.uid and [('website_published', '=', True)] or [(1, "=", 1)] @@ -128,6 +137,9 @@ class website_event(http.Controller): context=request.context) values = { + 'current_date': current_date, + 'current_country': current_country, + 'current_type': current_type, 'event_ids': events_ids, 'dates': dates, 'types': types, -- cgit v1.2.3