summaryrefslogtreecommitdiff
path: root/addons/website_event
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website_event')
-rw-r--r--addons/website_event/__init__.py23
-rw-r--r--addons/website_event/__openerp__.py8
-rw-r--r--addons/website_event/controllers/__init__.py2
-rw-r--r--addons/website_event/controllers/main.py92
-rw-r--r--addons/website_event/doc/changelog.rst9
-rw-r--r--addons/website_event/doc/index.rst10
-rw-r--r--addons/website_event/event.py35
-rw-r--r--addons/website_event/event_demo.xml63
-rw-r--r--addons/website_event/tests/__init__.py28
-rw-r--r--addons/website_event/tests/test_controllers.py29
-rw-r--r--addons/website_event/views/website_event.xml59
11 files changed, 216 insertions, 142 deletions
diff --git a/addons/website_event/__init__.py b/addons/website_event/__init__.py
index 91898dc2123..b4f256be0d9 100644
--- a/addons/website_event/__init__.py
+++ b/addons/website_event/__init__.py
@@ -1,2 +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/>.
+#
+##############################################################################
+
import controllers
-import event \ No newline at end of file
+import event
diff --git a/addons/website_event/__openerp__.py b/addons/website_event/__openerp__.py
index 9a697d6f7c4..a5b034b0a8f 100644
--- a/addons/website_event/__openerp__.py
+++ b/addons/website_event/__openerp__.py
@@ -1,15 +1,17 @@
+# -*- coding: utf-8 -*-
+
{
'name': 'Online Events',
'category': 'Website',
'summary': 'Schedule, Promote and Sell Events',
'version': '1.0',
'description': """
-OpenERP Blog
-============
+Online Events
+=============
""",
'author': 'OpenERP SA',
- 'depends': ['website', 'event_sale', 'website_sale'],
+ 'depends': ['website', 'website_mail', 'event_sale', 'website_sale'],
'data': [
'event_data.xml',
'views/website_event.xml',
diff --git a/addons/website_event/controllers/__init__.py b/addons/website_event/controllers/__init__.py
index 8ee9bae18d9..bbd183e955b 100644
--- a/addons/website_event/controllers/__init__.py
+++ b/addons/website_event/controllers/__init__.py
@@ -1 +1,3 @@
+# -*- coding: utf-8 -*-
+
import main
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)
diff --git a/addons/website_event/doc/changelog.rst b/addons/website_event/doc/changelog.rst
new file mode 100644
index 00000000000..ac212494c7e
--- /dev/null
+++ b/addons/website_event/doc/changelog.rst
@@ -0,0 +1,9 @@
+.. _changelog:
+
+Changelog
+=========
+
+`trunk (saas-3)`
+----------------
+
+ - created ``website_event``
diff --git a/addons/website_event/doc/index.rst b/addons/website_event/doc/index.rst
new file mode 100644
index 00000000000..3edce4cc8f1
--- /dev/null
+++ b/addons/website_event/doc/index.rst
@@ -0,0 +1,10 @@
+Website Event Module documentation topics
+'''''''''''''''''''''''''''''''''''''''''
+
+Changelog
+'''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ changelog.rst
diff --git a/addons/website_event/event.py b/addons/website_event/event.py
index 05d032780da..47ad0fbffab 100644
--- a/addons/website_event/event.py
+++ b/addons/website_event/event.py
@@ -1,8 +1,28 @@
# -*- 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.osv import osv, fields
from openerp import SUPERUSER_ID
+
# defined for access rules
class product(osv.osv):
_inherit = 'product.product'
@@ -15,7 +35,15 @@ class event(osv.osv):
_inherit = 'event.event'
_columns = {
'website_published': fields.boolean('Available in the website'),
- 'description_website': fields.html('Description for the website'),
+ # TDE TODO FIXME: when website_mail/mail_thread.py inheritance work -> this field won't be necessary
+ 'website_message_ids': fields.one2many(
+ 'mail.message', 'res_id',
+ domain=lambda self: [
+ '&', ('model', '=', self._name), ('type', '=', 'comment')
+ ],
+ string='Website Messages',
+ help="Website communication history",
+ ),
}
def google_map_img(self, cr, uid, ids, zoom=8, width=298, height=298, context=None):
@@ -28,13 +56,14 @@ class event(osv.osv):
if partner.address_id:
return self.browse(cr, SUPERUSER_ID, ids[0], context=context).address_id.google_map_link()
+
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
-
+
def _recalculate_product_values(self, cr, uid, ids, product_id=None, context=None):
if not ids:
return super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product_id, context=context)
-
+
order_line = self.browse(cr, uid, ids[0], context=context)
product = product_id and self.pool.get('product.product').browse(cr, uid, product_id, context=context) or order_line.product_id
res = super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product.id, context=context)
diff --git a/addons/website_event/event_demo.xml b/addons/website_event/event_demo.xml
index a471f36a039..afd2a045e50 100644
--- a/addons/website_event/event_demo.xml
+++ b/addons/website_event/event_demo.xml
@@ -2,54 +2,21 @@
<openerp>
<data>
- <record id="event_sale.event_technical_training" model="event.event">
- <field name="website_published">True</field>
- <field name="description_website"><![CDATA[
-<center><strong>OpenERP v.7 Technical Training in English (5 days)</strong></center>
-<p>&nbsp;</p>
-<p><strong>Course summary:</strong></p>
-<p>This course is dedicated to partners, integrators and developers who need to grasp knowledge of the OpenERP development process. This course is for new developers or for IT professionals eager to learn more about the OpenERP technical aspects.</p>
-<p>&nbsp;</p>
-<p><strong>Objectives:</strong></p>
-<p>Having attended this course, participants should be able to:</p>
-<ul>
-<li>Understand the development concepts and architecture;</li>
-<li>Install and administer OpenERP;</li>
-<li>Develop a new OpenERP module.</li>
-</ul>
-<p>&nbsp;</p>
-<p><strong>Our prices include:</strong></p>
-<ul>
-<li>drinks and lunch;</li>
-<li>training material.</li>
-</ul>
-<p>&nbsp;</p>
-<p><strong>Requirements:</strong></p>
-<ul>
-<li>Bring your own laptop.</li>
-<li>Participants are expected to have some knowledge in programming.&nbsp;A basic knowledge of the Python programming is recommended.</li>
-<li>Participants preferably have a functional knowledge of the OpenERP software (see Functional Training).</li>
-</ul>
-<p>&nbsp;</p>
-<p>For more information on the program, please explore <a href="http://www.openerp.com/services/technical-training">http://www.openerp.com/services/technical-training</a>.</p>
-<p>If you have a question<strong>&nbsp;concerning the content of the training</strong>, please contact <a href="mailto:training@openerp.com">training@openerp.com</a>.</p>
-<p>&nbsp;</p>
-<p><strong>Where to find us:</strong></p>
-<p>Chaussée de Namur 40, 1367 Ramillies (Belgium)</p>
-<p>More information about our Headquarter office (directions, transports, parking, hotels, ...), please have a look at&nbsp;<a href="http://bit.ly/VD8J67">http://bit.ly/VD8J67.</a></p>
-<p>&nbsp;</p>
-<p><strong>Cancellation Policy:&nbsp;</strong></p>
-<p>The organization of the training session has related costs. Due to these costs, cancellations made less than 2 weeks (14 calendar days) prior to the start of the training session is a subject to a fee. This fee can be up to a maximum of 1000€ per cancellation request.</p>
-<p>We strongly recommend to book your flight tickets and/or hotel reservations 2 weeks prior to the training. If the training is cancelled 2 weeks in advance, you'll be notified by email.</p>
-<div>&nbsp;</div>
-<p>For any additional information, please contact us at <a href="mailto:events@openerp.com">events@openerp.com</a>.</p>
-<p>&nbsp;</p>
-<p>Best regards,</p>
-<p>Miss Charline Louis, OpenERP Junior Event Manager</p>
-<p>&nbsp;</p>
-<p align="RIGHT"><em>(OpenERP reserves the right to cancel, re-name or re-locate<br/>the event or change the dates on which it is held.)</em></p>
-]]></field>
- </record>
+ <record id="event.event_0" model="event.event">
+ <field name="website_published">True</field>
+ </record>
+ <record id="event.event_1" model="event.event">
+ <field name="website_published">True</field>
+ </record>
+
+ <record id="event.event_2" model="event.event">
+ <field name="website_published">True</field>
+ </record>
+
+ <record id="event.event_3" model="event.event">
+ <field name="website_published">True</field>
+ </record>
+
</data>
</openerp>
diff --git a/addons/website_event/tests/__init__.py b/addons/website_event/tests/__init__.py
new file mode 100644
index 00000000000..97f1da2f54b
--- /dev/null
+++ b/addons/website_event/tests/__init__.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 20123TODAY OpenERP S.A. <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.addons.website_blog.tests import test_controllers
+
+checks = [
+ test_controllers,
+]
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/website_event/tests/test_controllers.py b/addons/website_event/tests/test_controllers.py
new file mode 100644
index 00000000000..d1c28cab5af
--- /dev/null
+++ b/addons/website_event/tests/test_controllers.py
@@ -0,0 +1,29 @@
+# -*- 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.addons.mail.tests.test_mail_base import TestMailBase
+from openerp.tools import mute_logger, email_split
+
+
+class TestControllers(TestMailBase):
+
+ def test_00(self):
+ cr, uid = self.cr, self.uid
diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml
index da52e27e140..d79750b1e4d 100644
--- a/addons/website_event/views/website_event.xml
+++ b/addons/website_event/views/website_event.xml
@@ -22,7 +22,6 @@
</template>
<!-- Page -->
-
<template id="index" name="Events" page="True">
<t t-call="website.layout">
<t t-set="head">
@@ -30,9 +29,6 @@
</t>
<t t-set="title">Events</t>
<div id="wrap">
- <div class="oe_structure">
- <h1 class="text-center">Our Events</h1>
- </div>
<div class="container">
<div class="row">
<div class="col-md-4 css_noprint" id="left_column">
@@ -51,6 +47,17 @@
</t>
</div>
<div class="col-md-8">
+ <div class="oe_structure">
+ <h2>
+ Events for <t t-esc="current_date"/>
+ <t t-if="current_type">
+ in <t t-esc="current_type.name"/>
+ </t>
+ <t t-if="current_country">
+ in <t t-esc="current_country.name"/>
+ </t>
+ </h2>
+ </div>
<ul class="media-list">
<li t-foreach="event_ids" t-as="event" class="media" data-publish="">
<t t-call="website.publish"><t t-set="object" t-value="event"/></t>
@@ -119,7 +126,7 @@
</xpath>
</template>
- <template id="detail">
+ <template id="event_description_full">
<t t-call="website.layout">
<t t-set="head">
<script type="text/javascript" src="/website_event/static/src/js/website_event.js"></script>
@@ -128,21 +135,10 @@
<t t-set="title">Events</t>
<div id="wrap">
<div class="container">
- <t t-call="website.publish"><t t-set="object" t-value="event_id"/></t>
<div class="row">
- <div class="col-md-4">
- <form action="./subscribe" method="POST" class="form-inline" t-if="not subscribe">
- <div class="col-lg-7">
- <input placeholder="Email Address" type="email" name="email" class="form-control" t-if="is_public_user"/>
- </div>
- <button type="submit" class="btn btn-primary" name="subscribe">Subscribe</button>
- </form>
- <form action="./unsubscribe" method="POST" class="form-inline" t-if="subscribe">
- <input type="hidden" name="email" t-att-value="subscribe"/>
- <button type="submit" class="btn btn-default" name="unsubscribe">Unsubscribe</button>
- </form>
- </div>
- <div class="col-md-8">
+ <div class="col-md-8">
+ <t t-call="website.publish"><t t-set="object" t-value="event_id"/></t>
+ <t t-call="website_mail.follow"><t t-set="object" t-value="event_id"/></t>
<h1 class="text-center" t-field="event_id.name"></h1>
<h4 class="text-center">
<i class="icon-time"></i> <span t-field="event_id.date_begin"/> to
@@ -151,20 +147,19 @@
<h5 class="text-center" t-field="event_id.address_id"/>
</div>
- <div class="col-md-4 css_noprint">
+ <div class="col-md-4 css_noprint pull-right">
<h4>When &amp; Where</h4>
<a t-att-href="event_id.google_map_link()" target="_BLANK">
<img class="thumbnail" t-att-src="event_id.google_map_img()"/>
</a>
- <address>
- <pre t-field="event_id.address_id"/>
- <i class="icon-time"></i> <span t-field="event_id.date_begin"> </span><br/>
- <i class="icon-time"></i> <span t-field="event_id.date_end"> </span>
- <t t-if="event_id.organizer_id">
- <h6>Organized by:</h6>
- <pre><t t-field="event_id.organizer_id"/><t t-if="event_id.phone"><br/><span>&amp;#x2706;</span> <span t-field="event_id.phone"></span></t><t t-if="event_id.email"><br/><i class="icon-envelope"></i> <span t-field="event_id.email"></span></t></pre>
- </t>
- </address>
+
+ <address><pre t-field="event_id.address_id"/></address>
+ <i class="icon-time"></i> <span t-field="event_id.date_begin"> </span><br/>
+ <i class="icon-time"></i> <span t-field="event_id.date_end"> </span>
+ <t t-if="event_id.organizer_id">
+ <h6>Organized by:</h6>
+ <address><strong t-field="event_id.organizer_id.display_name"/><t t-if="event_id.phone"><br/><span>&amp;#x2706;</span> <span t-field="event_id.phone"></span></t><t t-if="event_id.email"><br/><i class="icon-envelope"></i> <span t-field="event_id.email"></span></t></address>
+ </t>
</div>
<div class="col-md-8">
<t t-if="event_id.event_ticket_ids">
@@ -195,14 +190,14 @@
</tr>
</tbody>
</table>
- <button type="submit" class="btn btn-primary" t-if="event_id.register_avail">Order Now</button>
+ <button type="submit" class="btn btn-primary pull-right" t-if="event_id.register_avail">Order Now</button><br/>
</form>
</t>
<hr/>
- <div t-field="event_id.description_website"></div>
+ <div t-field="event_id.description"></div>
<hr/>
<ul class="media-list" id="comment">
- <li t-foreach="message_ids" t-as="comment" class="media">
+ <li t-foreach="event_id.website_message_ids" t-as="comment" class="media">
<div class="media-body">
<t t-call="website.publish"><t t-set="object" t-value="comment"/></t>
<t t-raw="comment.body"/>