summaryrefslogtreecommitdiff
path: root/addons/website_event/controllers/main.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2013-09-24 15:05:17 +0200
committerThibault Delavallée <tde@openerp.com>2013-09-24 15:05:17 +0200
commit0c040ae2370d36f560dbcbce794ce3c3bdb72bb2 (patch)
tree5261996256bc4fa981f9ac5d2038bce1ef02e7e2 /addons/website_event/controllers/main.py
parentf181f21cf47c314b2cfec58f7c831d3e9a1897ee (diff)
parent39726ffe2d8041a0b8b15bcc97b324a96d1fe64f (diff)
[MERGE] [IMP] [DEMO] event, website_event improvements
[IMP] [DEMO] event: cleaned demo data. Also renamed note field into description, and moved it out of groups_noone, in order to effectively use it to hold the html description of the event. [IMP] event_sale: cleaned demo data [ADD] website_mail: added mail_thread file that hold website_message_ids field, holding published comments. Use it for public objects. However as inheritance seems to be still buggy, this field is redefined in website_blog and website_event (at least) to be able to use it. Remove specific declarations when the bug is fixed. [IMP] [ADD] website_event: - added skeleton directory for doc - added skeleton directory for tests - added dependency towards website_mail module, to benefit from follow feature - cleaned demo data - use website_mail for follow / unfollow mechanism - added website_message_ids field, use it in view - some improvements in website view (title, event description) [FIX] website_sales: somewhat fixed partner information fetch in checkout; whole code of those controllers is really obfuscated and very dubious. bzr revid: tde@openerp.com-20130924130517-hzi2qm108ec65viq
Diffstat (limited to 'addons/website_event/controllers/main.py')
-rw-r--r--addons/website_event/controllers/main.py92
1 files changed, 37 insertions, 55 deletions
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index 0b61534a84b..7843df406e5 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 (<http://www.openerp.com>).
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
from openerp import SUPERUSER_ID
from openerp.addons.web import http
@@ -18,7 +37,10 @@ class website_event(http.Controller):
@website.route(['/event/', '/event/page/<int: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')
@@ -54,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)]
@@ -109,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,
@@ -126,11 +157,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/<int:event_id>/add_cart'], type='http', auth="public")
def add_cart(self, event_id=None, **post):
@@ -182,50 +211,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/<int:event_id>/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/<int:event_id>/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)