summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2013-07-24 17:20:27 +0200
committerChristophe Matthieu <chm@openerp.com>2013-07-24 17:20:27 +0200
commit185827a579d1a03aec925a4daf2cd6f92e202011 (patch)
treec440d938dea0917d0fbc12d31ebce3db64f75ad0
parentc3e11ba9ca52cf3c16c1cdc96b67125f00019817 (diff)
[IMP] website_mail
bzr revid: chm@openerp.com-20130724152027-hzcdqli4t80ytg3l
-rw-r--r--addons/website_mail/__init__.py2
-rw-r--r--addons/website_mail/__openerp__.py20
-rw-r--r--addons/website_mail/controllers/__init__.py1
-rw-r--r--addons/website_mail/controllers/main.py44
-rw-r--r--addons/website_mail/mail_message.py29
-rw-r--r--addons/website_mail/views/website_mail.xml108
-rw-r--r--addons/website_sale/views/ecommerce.xml4
7 files changed, 204 insertions, 4 deletions
diff --git a/addons/website_mail/__init__.py b/addons/website_mail/__init__.py
new file mode 100644
index 00000000000..f2eed8dcedb
--- /dev/null
+++ b/addons/website_mail/__init__.py
@@ -0,0 +1,2 @@
+import controllers
+import mail_message
diff --git a/addons/website_mail/__openerp__.py b/addons/website_mail/__openerp__.py
new file mode 100644
index 00000000000..2ed5290fdc2
--- /dev/null
+++ b/addons/website_mail/__openerp__.py
@@ -0,0 +1,20 @@
+{
+ 'name': 'Blog',
+ 'category': 'mail',
+ 'version': '1.0',
+ 'description': """
+OpenERP Blog
+============
+
+ """,
+ 'author': 'OpenERP SA',
+ 'depends': ['website', 'mail'],
+ 'data': [
+ 'views/website_mail.xml',
+ ],
+ 'js': ['static/src/js/*.js'],
+ 'css': ['static/src/css/*.css'],
+ 'qweb': ['static/src/xml/*.xml'],
+ 'installable': True,
+ 'auto_install': True,
+}
diff --git a/addons/website_mail/controllers/__init__.py b/addons/website_mail/controllers/__init__.py
new file mode 100644
index 00000000000..8ee9bae18d9
--- /dev/null
+++ b/addons/website_mail/controllers/__init__.py
@@ -0,0 +1 @@
+import main
diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py
new file mode 100644
index 00000000000..05ef2130b12
--- /dev/null
+++ b/addons/website_mail/controllers/main.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+from openerp.addons.web import http
+from openerp.addons.web.http import request
+from openerp.addons.website.controllers.main import template_values
+
+
+class website_mail(http.Controller):
+
+ @http.route(['/blog', '/blog/<int:mail_group_id>/<int:blog_id>'], type='http', auth="admin")
+ def blog(self, mail_group_id=None, blog_id=None, **post):
+ cr = request.cr
+ uid = request.uid
+ values = template_values()
+
+ mail_group_obj = request.registry['mail.group']
+ mail_message_obj = request.registry['mail.message']
+
+ if not mail_group_id:
+ mail_group_ids = mail_group_obj.search(cr, uid, [("public", "=", "public")])
+ mail_group_id = mail_group_ids[0]
+
+ domain = [("subject", "!=", False), ("parent_id", "=", False)]#, ("website_published", "=", True)]
+
+ if blog_id and not mail_message_obj.search(cr, uid, [("id", "=", blog_id)] + domain):
+ blog_id = None
+
+ message_ids = mail_message_obj.search(cr, uid, [("res_id", "=", mail_group_id), ("model", "=", 'mail.group')])
+ domain += [("id", "in", message_ids)]
+
+ values.update({
+ 'res_company': request.registry['res.company'].browse(cr, uid, 1),
+ 'blog_ids': not blog_id and mail_message_obj.browse(cr, uid,
+ mail_message_obj.search(cr, uid, domain, order="create_date desc", limit=20)) or None,
+ 'popular_ids': mail_message_obj.browse(cr, uid,
+ mail_message_obj.search(cr, uid, domain, order="child_ids desc", limit=5)),
+ 'recent_ids': mail_message_obj.browse(cr, uid,
+ mail_message_obj.search(cr, uid, domain, order="create_date desc", limit=5)),
+ 'last_ids': mail_message_obj.browse(cr, uid,
+ mail_message_obj.search(cr, uid, domain, order="write_date desc", limit=5)),
+ 'blog_id': blog_id and mail_message_obj.browse(cr, uid, blog_id) or None,
+ })
+ html = request.registry.get("ir.ui.view").render(cr, uid, "website_mail.index", values)
+ return html
diff --git a/addons/website_mail/mail_message.py b/addons/website_mail/mail_message.py
new file mode 100644
index 00000000000..4427af34e9d
--- /dev/null
+++ b/addons/website_mail/mail_message.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# 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
+
+
+class mail_message(osv.osv):
+ _inherit = "mail.message"
+ _columns = {
+ 'website_published': fields.boolean('Publish', help="Publish on the website as a blog"),
+ }
diff --git a/addons/website_mail/views/website_mail.xml b/addons/website_mail/views/website_mail.xml
new file mode 100644
index 00000000000..94c394c520a
--- /dev/null
+++ b/addons/website_mail/views/website_mail.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+ <!-- add website_published field on mail group -->
+
+ <record model="ir.ui.view" id="blog_website_form">
+ <field name="name">mail.group.website.form</field>
+ <field name="model">mail.group</field>
+ <field name="inherit_id" ref="mail.group_all_employees"/>
+ <field name="arch" type="xml">
+ <field name="public" position="after">
+ <field name="website_published" attrs="{'invisible': [('public','!=','public')]}"/>
+ </field>
+ </field>
+ </record>
+
+ <!-- Layout add nav and footer -->
+
+ <record id="header_website_mail" model="ir.ui.view">
+ <field name="name">header_website_mail</field>
+ <field name="inherit_id" ref="website.header"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr="(//li)[last()]" position="after">
+ <li class="pull-right"><a href="/blog">Blog</a></li>
+ </xpath>
+ </data>
+ </field>
+ </record>
+
+ <!-- Page Shop -->
+
+ <template id="index">
+ <t t-call="website.layout">
+ <t t-set="title">Blog</t>
+ <div class="container css_website_mail">
+ <div class="row">
+ <div class="span4">
+ <ul class="nav nav-list">
+ <li class="nav-header">Most Popular</li>
+ <t t-foreach="popular_ids or []" t-as="blog">
+ <li><a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><t t-esc="blog.subject"/> </a></li>
+ </t>
+ <li class="nav-header">Recent</li>
+ <t t-foreach="recent_ids or []" t-as="blog">
+ <li><a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><t t-esc="blog.subject"/> </a></li>
+ </t>
+ <li class="nav-header">Last Commit</li>
+ <t t-foreach="last_ids or []" t-as="blog">
+ <li><a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><t t-esc="blog.subject"/> </a></li>
+ </t>
+ </ul>
+ </div>
+ <div class="span8" t-if="blog_id">
+ <div class="media">
+ <div class="media-body well">
+ <h3><t t-esc="blog_id.subject"/></h3>
+ <p><t t-raw="blog_id.body"/></p>
+ <small class="pull-right muted text-right">
+ <div><t t-esc="blog_id.author_id.name"/></div>
+ <div><t t-esc="blog_id.date"/></div>
+ </small>
+ </div>
+ <ul class="media-list">
+ <t t-foreach="blog_id.child_ids or []" t-as="mail">
+ <li class="media well well-small">
+ <div class="media-body">
+ <h4 t-if="mail.subject" class="media-heading"><t t-esc="mail.subject"/></h4>
+ <div class="media">
+ <t t-raw="mail.body"/>
+ <small class="pull-right muted text-right">
+ <div><t t-esc="mail.author_id.name"/></div>
+ <div><t t-esc="mail.date"/></div>
+ </small>
+ </div>
+ </div>
+ </li>
+ </t>
+ </ul>
+ </div>
+ </div>
+ <div class="span8" t-if="not blog_id">
+ <ul class="media-list">
+ <t t-foreach="blog_ids or []" t-as="blog">
+ <li class="media">
+ <div class="media-body">
+ <h4 class="media-heading"><t t-esc="blog.subject"/></h4>
+ <div class="media">
+ <t t-raw="blog.body"/>
+ <small class="pull-right muted text-right">
+ <a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)">Read more </a>
+ <div><t t-esc="blog.author_id.name"/></div>
+ <div><t t-esc="blog.date"/></div>
+ </small>
+ </div>
+ </div>
+ </li>
+ </t>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </t>
+ </template>
+
+ </data>
+</openerp>
diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml
index e719943bffb..026359c781c 100644
--- a/addons/website_sale/views/ecommerce.xml
+++ b/addons/website_sale/views/ecommerce.xml
@@ -2,10 +2,6 @@
<openerp>
<data>
- <record id="website_sale.shipping_address" model="res.partner.category">
- <field name="name">Shipping Address</field>
- </record>
-
<!-- Layout add nav and footer -->
<record id="header_ecommerce" model="ir.ui.view">