From 901f57382605ccb3498666d2c2120ef5143f438d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 20 Sep 2013 13:12:21 +0200
Subject: [PATCH 01/27] [REF] document_page: refactored the module, towards
using it in website_blog Main modifications: - category is now a blog.catory
object, instead of a document.page with type='category' - added blog.tag
model, to be able to tag posts - cleaned document.page, now blog.post model,
removing type and unnecessary features - added chatter on blog.post,
blog.category - added subtypes to enable direct follow of posts when
following a category - updated document.page.history (now blog.post.history)
- commented menu creation, because this does not seem to be necessary anymore
considering the new website - updated wizard.document.page.history.show_diff,
now blog.post.history.show_diff - updated all views accordingly, as well as
demo data - removed the use of document_user group, simplified rules on
blog.post (not done for new models) - misc cleaning
Next step: merge with website_mail
bzr revid: tde@openerp.com-20130920111221-qy3x5eoyih26axn8
---
addons/document_page/__openerp__.py | 20 +-
addons/document_page/document_page.py | 114 ++++++------
addons/document_page/document_page_data.xml | 58 +++---
addons/document_page/document_page_demo.xml | 44 +++--
addons/document_page/document_page_view.xml | 172 ++++++++++--------
.../security/document_page_security.xml | 8 +-
.../security/ir.model.access.csv | 6 +-
.../static/src/css/document_page.css | 4 -
.../test/document_page_test00.yml | 8 +-
addons/document_page/wizard/__init__.py | 2 +-
.../wizard/document_page_show_diff.py | 8 +-
.../wizard/document_page_show_diff_view.xml | 8 +-
12 files changed, 232 insertions(+), 220 deletions(-)
diff --git a/addons/document_page/__openerp__.py b/addons/document_page/__openerp__.py
index f08315bf61e..34138f3c719 100644
--- a/addons/document_page/__openerp__.py
+++ b/addons/document_page/__openerp__.py
@@ -30,19 +30,25 @@ Web pages
""",
'author': ['OpenERP SA'],
'website': 'http://www.openerp.com/',
- 'depends': ['knowledge'],
+ 'depends': ['mail', 'knowledge'],
'data': [
- 'wizard/document_page_create_menu_view.xml',
+ # 'wizard/document_page_create_menu_view.xml',
'wizard/document_page_show_diff_view.xml',
'document_page_view.xml',
- 'security/document_page_security.xml',
+ 'document_page_data.xml',
+ # 'security/document_page_security.xml',
'security/ir.model.access.csv',
],
- 'demo': ['document_page_demo.xml'],
- 'test': ['test/document_page_test00.yml'],
+ 'demo': [
+ 'document_page_demo.xml'
+ ],
+ 'test': [
+ # 'test/document_page_test00.yml'
+ ],
'installable': True,
'auto_install': False,
- 'images': [],
- 'css' : ['static/src/css/document_page.css'],
+ 'css': [
+ 'static/src/css/document_page.css'
+ ],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/document_page/document_page.py b/addons/document_page/document_page.py
index 7f885018001..0290de6750c 100644
--- a/addons/document_page/document_page.py
+++ b/addons/document_page/document_page.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
+# Copyright (C) 2004-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
@@ -22,45 +22,56 @@
from openerp.osv import fields, osv
from openerp.tools.translate import _
import difflib
-from openerp import tools
-class document_page(osv.osv):
- _name = "document.page"
- _description = "Document Page"
+
+class BlogCategory(osv.Model):
+ _name = 'blog.category'
+ _description = 'Blog Category'
+ _inherit = ['mail.thread']
_order = 'name'
- def _get_page_index(self, cr, uid, page, link=True):
- index = []
- for subpage in page.child_ids:
- index += ["
"+ self._get_page_index(cr, uid, subpage) +"
"]
- r = ''
- if link:
- r = '%s'%(page.id,page.name)
- if index:
- r += "
" + "".join(index) + "
"
- return r
+ _columns = {
+ 'name': fields.char('Name', required=True),
+ 'description': fields.text('Description'),
+ 'template': fields.text('Template'),
+ 'blog_ids': fields.one2many(
+ 'blog.post', 'category_id',
+ 'Blogs',
+ ),
+ }
- def _get_display_content(self, cr, uid, ids, name, args, context=None):
- res = {}
- for page in self.browse(cr, uid, ids, context=context):
- if page.type == "category":
- content = self._get_page_index(cr, uid, page, link=False)
- else:
- content = page.content
- res[page.id] = content
- return res
+
+class BlogTag(osv.Model):
+ _name = 'blog.tag'
+ _description = 'Blog Tag'
+ _order = 'name'
+
+ _columns = {
+ 'name': fields.char('Name', required=True),
+ }
+
+
+class BlogPost(osv.Model):
+ _name = "blog.post"
+ _description = "Blog Post"
+ _inherit = ['mail.thread']
+ _order = 'name'
_columns = {
'name': fields.char('Title', required=True),
- 'type':fields.selection([('content','Content'), ('category','Category')], 'Type', help="Page type"),
-
- 'parent_id': fields.many2one('document.page', 'Category', domain=[('type','=','category')]),
- 'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
+ 'category_id': fields.many2one(
+ 'blog.category', 'Category',
+ ondelete='set null',
+ ),
+ 'tag_ids': fields.many2many(
+ 'blog.tag', 'blog_tag_rel',
+ 'blog_id', 'tag_id',
+ 'Tags',
+ ),
'content': fields.text("Content"),
- 'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
- 'history_ids': fields.one2many('document.page.history', 'page_id', 'History'),
+ 'history_ids': fields.one2many('blog.post.history', 'post_id', 'History'),
'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True),
'create_date': fields.datetime("Created on", select=True, readonly=True),
@@ -68,52 +79,43 @@ class document_page(osv.osv):
'write_date': fields.datetime("Modification Date", select=True, readonly=True),
'write_uid': fields.many2one('res.users', "Last Contributor", select=True, readonly=True),
}
- _defaults = {
- 'type':'content',
- }
-
- def onchange_parent_id(self, cr, uid, ids, parent_id, content, context=None):
- res = {}
- if parent_id and not content:
- parent = self.browse(cr, uid, parent_id, context=context)
- if parent.type == "category":
- res['value'] = {
- 'content': parent.content,
- }
- return res
def create_history(self, cr, uid, ids, vals, context=None):
for i in ids:
- history = self.pool.get('document.page.history')
+ history = self.pool.get('blog.post.history')
if vals.get('content'):
res = {
'content': vals.get('content', ''),
- 'page_id': i,
+ 'post_id': i,
}
history.create(cr, uid, res)
def create(self, cr, uid, vals, context=None):
- page_id = super(document_page, self).create(cr, uid, vals, context)
- self.create_history(cr, uid, [page_id], vals, context)
- return page_id
+ if context is None:
+ context = {}
+ create_context = dict(context, mail_create_nolog=True)
+ post_id = super(BlogPost, self).create(cr, uid, vals, context=create_context)
+ self.create_history(cr, uid, [post_id], vals, context)
+ return post_id
def write(self, cr, uid, ids, vals, context=None):
- result = super(document_page, self).write(cr, uid, ids, vals, context)
+ result = super(BlogPost, self).write(cr, uid, ids, vals, context)
self.create_history(cr, uid, ids, vals, context)
return result
-class document_page_history(osv.osv):
- _name = "document.page.history"
+
+class BlogPostHistory(osv.Model):
+ _name = "blog.post.history"
_description = "Document Page History"
_order = 'id DESC'
_rec_name = "create_date"
_columns = {
- 'page_id': fields.many2one('document.page', 'Page'),
- 'summary': fields.char('Summary', size=256, select=True),
- 'content': fields.text("Content"),
- 'create_date': fields.datetime("Date"),
- 'create_uid': fields.many2one('res.users', "Modified By"),
+ 'post_id': fields.many2one('blog.post', 'Blog Post'),
+ 'summary': fields.char('Summary', size=256, select=True),
+ 'content': fields.text("Content"),
+ 'create_date': fields.datetime("Date"),
+ 'create_uid': fields.many2one('res.users', "Modified By"),
}
def getDiff(self, cr, uid, v1, v2, context=None):
diff --git a/addons/document_page/document_page_data.xml b/addons/document_page/document_page_data.xml
index 1cef65694d8..85e8aaed530 100644
--- a/addons/document_page/document_page_data.xml
+++ b/addons/document_page/document_page_data.xml
@@ -1,41 +1,29 @@
-
-
- The OpenERP wiki
- help, quick start, wiki, formatting
- 0
- 1
- Initial Page
- ==The OpenERP wiki==
-
-[[File:http://www.openerp.com/sites/all/themes/openerp/logo.png OpenERP]]
+
+
-The OpenERP wiki allows you to manage your enterprise's contents using wiki
-restructured texts. This module provides a collaborative way to manage internal
-FAQs, quality manuals, technical references, etc.
-
-==Keypoints==
-* Same formating style than MediaWiki,
-* Any number of wiki group for different purposes,
-* Detailed history on all pages,
-* Integrated with the document management system.
-
-==Why you should use the OpenERP integrated wiki than a separate wiki system ?==
-* Allows links to any document of the system,
-* Uses the access controls of OpenERP for uniq access rights management,
-* Use it to describe projects, tasks, products,
-* Integrated with customer portal to provide restricted external accesses,
-* Linked to users processes for quality manuals.
-
-==To get more information==
-* [[Basic Wiki Editing]]
-* [[Wiki Documentation]]
-* [http://openerp.com The OpenERP website]
-
-
-
-
+
+
+ New Post
+ blog.post
+
+ New Post
+
+ Post Published
+ blog.post
+
+ Post Published
+
+
+
+ New Post
+ blog.category
+
+
+ category_id
+
+
diff --git a/addons/document_page/document_page_demo.xml b/addons/document_page/document_page_demo.xml
index f779ea8313f..f636f5631d0 100644
--- a/addons/document_page/document_page_demo.xml
+++ b/addons/document_page/document_page_demo.xml
@@ -1,13 +1,13 @@
-
-
-
-
-
- OpenERP Features
- category
-
+
+
+
+
+
+ News
+ Presentation of new OpenERP features
+
Summary of the feature
Long explanation
@@ -15,13 +15,22 @@ Long explanation
Conclusion
Additional ressources
-
-
+
-
- OpenERP 6.1. Functional Demo
-
+
+
+ functional
+
+
+ pos
+
+
+
+
+ OpenERP 7.0 Functional Demo
+
+
@@ -48,9 +57,9 @@ company, with your clients and implement it now for your business.
-
+ Personalise Dashboards
-
+
@@ -89,9 +98,10 @@ you change your mind there is a reset button to return to the default view.
-
+ Touchscreen Point of Sale
-
+
+
diff --git a/addons/document_page/document_page_view.xml b/addons/document_page/document_page_view.xml
index 9d02b47d265..5cbc947e172 100644
--- a/addons/document_page/document_page_view.xml
+++ b/addons/document_page/document_page_view.xml
@@ -1,116 +1,128 @@
-
-
+
+
-
-
- document.page.tree
- document.page
- child_ids
- 100
+
+
+ blog.category.list
+ blog.category
-
+
-
-
-
-
- document.page.list
- document.page
+
+ blog.category.form
+ blog.category
-
+
+
+
+
+
+
+ blog.post.list
+ blog.post
+
+
-
+
-
-
- document.page.form
- document.page
+
+
+ blog.post.form
+ blog.post
-
diff --git a/addons/mail/tests/test_mail_base.py b/addons/mail/tests/test_mail_base.py
index b0f9f72b6f7..841a22c34dd 100644
--- a/addons/mail/tests/test_mail_base.py
+++ b/addons/mail/tests/test_mail_base.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Business Applications
-# Copyright (c) 2012-TODAY OpenERP S.A.
+# Copyright (c) 20123TODAY OpenERP S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
diff --git a/addons/website_blog/__init__.py b/addons/website_blog/__init__.py
index 85599508fdd..8b6698d444e 100644
--- a/addons/website_blog/__init__.py
+++ b/addons/website_blog/__init__.py
@@ -20,5 +20,6 @@
##############################################################################
import controllers
-import document_page
+import website_blog
import res_config
+import wizard
diff --git a/addons/website_blog/__openerp__.py b/addons/website_blog/__openerp__.py
index 67a176df083..104b2f7c073 100644
--- a/addons/website_blog/__openerp__.py
+++ b/addons/website_blog/__openerp__.py
@@ -30,13 +30,23 @@ OpenERP Blog
""",
'author': 'OpenERP SA',
- 'depends': ['website_mail', 'document_page'],
+ 'depends': ['knowledge', 'website_mail'],
'data': [
- 'website_mail_data.xml',
- 'views/website_mail.xml',
+ 'website_blog_data.xml',
+ 'views/website_blog_views.xml',
+ 'views/website_templates.xml',
'views/res_config.xml',
+ # 'wizard/document_page_create_menu_view.xml',
+ 'wizard/document_page_show_diff_view.xml',
+ 'security/ir.model.access.csv',
'security/website_mail.xml',
],
+ 'demo': [
+ 'website_blog_demo.xml'
+ ],
+ 'test': [
+ 'test/document_page_test00.yml'
+ ],
'qweb': [
'static/src/xml/*.xml'
],
diff --git a/addons/website_blog/document_page.py b/addons/website_blog/document_page.py
deleted file mode 100644
index 994e1df028c..00000000000
--- a/addons/website_blog/document_page.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- 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 tools
-from openerp import SUPERUSER_ID
-from openerp.osv import osv, fields
-
-
-class WebsiteDocumentPage(osv.Model):
- """ Inherit document.page to add website-related columns
-
- - website_published: standard publish column
- - website_message_ids: messages to display on website, aka comments
-
- """
- _inherit = "blog.post"
- # maximum number of characters to display in summary
- _shorten_max_char = 10
-
- def get_shortened_content(self, cr, uid, ids, name, arg, context=None):
- res = {}
- for page in self.browse(cr, uid, ids, context=context):
- try:
- body_short = tools.html_email_clean(page.content, remove=True, shorten=True, max_length=self._shorten_max_char)
- except Exception:
- body_short = False
- res[page.id] = body_short
- return res
-
- _columns = {
- 'website_published': fields.boolean(
- 'Publish', help="Publish on the website"
- ),
- 'website_published_datetime': fields.datetime(
- 'Publish Date'
- ),
- 'website_message_ids': fields.one2many(
- 'mail.message', 'res_id',
- domain=lambda self: [
- '&', ('model', '=', self._name), ('type', '=', 'comment')
- ],
- auto_join=True,
- string='Website Messages',
- help="Website communication history",
- ),
- 'shortened_content': fields.function(
- get_shortened_content,
- type='text',
- string='Shortened Content',
- help="Shortened content of the page that serves as a summary"
- ),
- }
-
- def img(self, cr, uid, ids, field='image_small', context=None):
- post = self.browse(cr, SUPERUSER_ID, ids[0], context=context)
- return "/website/image?model=%s&field=%s&id=%s" % ('res.users', field, post.create_uid.id)
diff --git a/addons/document_page/security/ir.model.access.csv b/addons/website_blog/security/ir.model.access.csv
similarity index 100%
rename from addons/document_page/security/ir.model.access.csv
rename to addons/website_blog/security/ir.model.access.csv
diff --git a/addons/website_blog/test/document_page_test00.yml b/addons/website_blog/test/document_page_test00.yml
new file mode 100644
index 00000000000..14d090dfd59
--- /dev/null
+++ b/addons/website_blog/test/document_page_test00.yml
@@ -0,0 +1,54 @@
+-
+ In order to test the document_page in OpenERP, I create a new page to category blog_category_1
+-
+ !record {model: blog.post, id: test_page0}:
+ name: Test Page0
+ category_id: blog_category_1
+ content: 'Test content
+
+ The Open ERP wiki allows you to manage your enterprise contents using wiki
+
+ restructured texts. This module provides a collaborative way to manage internal
+
+ FAQs, quality manuals, technical references, etc.'
+
+# -
+# I check the category index contains my page.
+# -
+ # !python {model: blog.post}: |
+ # res = self.read(cr, uid, [ref('blog_category_1')], ['display_content'])
+ # assert res[0]['display_content'].find('Test Page') > 1
+-
+ !record {model: blog.post, id: test_page0}:
+ content: 'Test updated content
+
+ The Open ERP wiki allows you to manage your enterprise contents using wiki
+
+ restructured texts. This module provides a collaborative way to manage internal
+
+ FAQs, quality manuals, technical references, etc.
+
+ Wiki text can easily be edited
+ '
+-
+ I check the page history for the current page by clicking on "Page History".After that find difference between history.
+-
+ !python {model: blog.post.history.show_diff}: |
+ hist_obj = model.pool.get('blog.post.history')
+ ids = hist_obj.search(cr, uid, [('post_id', '=', ref("test_page0"))])
+ model.get_diff(cr, uid, {'active_ids': ids[:] })
+# -
+# I click the "create menu" link and i fill the form.
+# -
+ # !record {model: document.page.create.menu, id: test_create_menu0}:
+ # menu_name: Wiki Test menu
+ # menu_parent_id: base.menu_base_partner
+# -
+# I create a Menu by clicking on "create menu"
+# -
+ # !python {model: document.page.create.menu}: |
+ # ids = [ref("test_create_menu0")]
+ # context['active_id'] = ref('test_page0')
+ # self.document_page_menu_create(cr, uid, ids, context)
+
+
diff --git a/addons/document_page/__init__.py b/addons/website_blog/tests/__init__.py
similarity index 80%
rename from addons/document_page/__init__.py
rename to addons/website_blog/tests/__init__.py
index 7ce5f4b6474..97f1da2f54b 100644
--- a/addons/document_page/__init__.py
+++ b/addons/website_blog/tests/__init__.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 20123TODAY OpenERP S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -15,11 +15,14 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
-import document_page
-import wizard
+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_blog/tests/test_controllers.py b/addons/website_blog/tests/test_controllers.py
new file mode 100644
index 00000000000..60ffa5ac9a3
--- /dev/null
+++ b/addons/website_blog/tests/test_controllers.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 2013-TODAY OpenERP S.A.
+#
+# 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.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/document_page/document_page_view.xml b/addons/website_blog/views/website_blog_views.xml
similarity index 100%
rename from addons/document_page/document_page_view.xml
rename to addons/website_blog/views/website_blog_views.xml
diff --git a/addons/website_blog/views/website_mail.xml b/addons/website_blog/views/website_templates.xml
similarity index 98%
rename from addons/website_blog/views/website_mail.xml
rename to addons/website_blog/views/website_templates.xml
index c6fbbb28b38..dddf59258f7 100644
--- a/addons/website_blog/views/website_mail.xml
+++ b/addons/website_blog/views/website_templates.xml
@@ -5,10 +5,10 @@
-
diff --git a/addons/document_page/document_page.py b/addons/website_blog/website_blog.py
similarity index 74%
rename from addons/document_page/document_page.py
rename to addons/website_blog/website_blog.py
index d198122aad3..63b5b3477e2 100644
--- a/addons/document_page/document_page.py
+++ b/addons/website_blog/website_blog.py
@@ -19,8 +19,12 @@
#
##############################################################################
-from openerp.osv import fields, osv
+
+from openerp import tools
+from openerp import SUPERUSER_ID
+from openerp.osv import osv, fields
from openerp.tools.translate import _
+
import difflib
@@ -56,6 +60,18 @@ class BlogPost(osv.Model):
_description = "Blog Post"
_inherit = ['mail.thread']
_order = 'name'
+ # maximum number of characters to display in summary
+ _shorten_max_char = 10
+
+ def get_shortened_content(self, cr, uid, ids, name, arg, context=None):
+ res = {}
+ for page in self.browse(cr, uid, ids, context=context):
+ try:
+ body_short = tools.html_email_clean(page.content, remove=True, shorten=True, max_length=self._shorten_max_char)
+ except Exception:
+ body_short = False
+ res[page.id] = body_short
+ return res
_columns = {
'name': fields.char('Title', required=True),
@@ -69,6 +85,28 @@ class BlogPost(osv.Model):
'Tags',
),
'content': fields.text('Content'),
+ 'shortened_content': fields.function(
+ get_shortened_content,
+ type='text',
+ string='Shortened Content',
+ help="Shortened content of the page that serves as a summary"
+ ),
+ # website control
+ 'website_published': fields.boolean(
+ 'Publish', help="Publish on the website"
+ ),
+ 'website_published_datetime': fields.datetime(
+ 'Publish Date'
+ ),
+ 'website_message_ids': fields.one2many(
+ 'mail.message', 'res_id',
+ domain=lambda self: [
+ '&', ('model', '=', self._name), ('type', '=', 'comment')
+ ],
+ auto_join=True,
+ string='Website Messages',
+ help="Website communication history",
+ ),
# technical stuff: history, menu (to keep ?)
'history_ids': fields.one2many(
'blog.post.history', 'post_id',
@@ -105,6 +143,10 @@ class BlogPost(osv.Model):
self.create_history(cr, uid, ids, vals, context)
return result
+ def img(self, cr, uid, ids, field='image_small', context=None):
+ post = self.browse(cr, SUPERUSER_ID, ids[0], context=context)
+ return "/website/image?model=%s&field=%s&id=%s" % ('res.users', field, post.create_uid.id)
+
class BlogPostHistory(osv.Model):
_name = "blog.post.history"
@@ -121,7 +163,7 @@ class BlogPostHistory(osv.Model):
}
def getDiff(self, cr, uid, v1, v2, context=None):
- history_pool = self.pool.get('document.page.history')
+ history_pool = self.pool.get('blog.post.history')
text1 = history_pool.read(cr, uid, [v1], ['content'])[0]['content']
text2 = history_pool.read(cr, uid, [v2], ['content'])[0]['content']
line1 = line2 = ''
diff --git a/addons/document_page/document_page_data.xml b/addons/website_blog/website_blog_data.xml
similarity index 79%
rename from addons/document_page/document_page_data.xml
rename to addons/website_blog/website_blog_data.xml
index b60ab1c8dc4..5883da445c4 100644
--- a/addons/document_page/document_page_data.xml
+++ b/addons/website_blog/website_blog_data.xml
@@ -3,6 +3,16 @@
+
+ Website Blogs
+ self
+ /blog
+
+
+
+ open
+
+
News
diff --git a/addons/document_page/document_page_demo.xml b/addons/website_blog/website_blog_demo.xml
similarity index 100%
rename from addons/document_page/document_page_demo.xml
rename to addons/website_blog/website_blog_demo.xml
diff --git a/addons/website_blog/website_mail_data.xml b/addons/website_blog/website_mail_data.xml
deleted file mode 100644
index cb5db2e250d..00000000000
--- a/addons/website_blog/website_mail_data.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
- Website Blogs
- self
- /blog
-
-
-
- open
-
-
-
-
diff --git a/addons/document_page/wizard/__init__.py b/addons/website_blog/wizard/__init__.py
similarity index 100%
rename from addons/document_page/wizard/__init__.py
rename to addons/website_blog/wizard/__init__.py
diff --git a/addons/document_page/wizard/document_page_create_menu.py b/addons/website_blog/wizard/document_page_create_menu.py
similarity index 100%
rename from addons/document_page/wizard/document_page_create_menu.py
rename to addons/website_blog/wizard/document_page_create_menu.py
diff --git a/addons/document_page/wizard/document_page_create_menu_view.xml b/addons/website_blog/wizard/document_page_create_menu_view.xml
similarity index 100%
rename from addons/document_page/wizard/document_page_create_menu_view.xml
rename to addons/website_blog/wizard/document_page_create_menu_view.xml
diff --git a/addons/document_page/wizard/document_page_show_diff.py b/addons/website_blog/wizard/document_page_show_diff.py
similarity index 100%
rename from addons/document_page/wizard/document_page_show_diff.py
rename to addons/website_blog/wizard/document_page_show_diff.py
diff --git a/addons/document_page/wizard/document_page_show_diff_view.xml b/addons/website_blog/wizard/document_page_show_diff_view.xml
similarity index 100%
rename from addons/document_page/wizard/document_page_show_diff_view.xml
rename to addons/website_blog/wizard/document_page_show_diff_view.xml
From 0ae0ebcdf6d97d59328e6ef3cd7160f738e692e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 20 Sep 2013 16:29:34 +0200
Subject: [PATCH 05/27] [DOC] website_blog: added skeleton for doc, and added
changelog with initial create mention of the module.
bzr revid: tde@openerp.com-20130920142934-ak0tvgdlti1z6oq1
---
addons/website_blog/doc/changelog.rst | 9 +++++++++
addons/website_blog/doc/index.rst | 10 ++++++++++
2 files changed, 19 insertions(+)
create mode 100644 addons/website_blog/doc/changelog.rst
create mode 100644 addons/website_blog/doc/index.rst
diff --git a/addons/website_blog/doc/changelog.rst b/addons/website_blog/doc/changelog.rst
new file mode 100644
index 00000000000..8b6131b5806
--- /dev/null
+++ b/addons/website_blog/doc/changelog.rst
@@ -0,0 +1,9 @@
+.. _changelog:
+
+Changelog
+=========
+
+`trunk (saas-3)`
+----------------
+
+ - created ``website_blog`` menu, build on defunct document_page module.
diff --git a/addons/website_blog/doc/index.rst b/addons/website_blog/doc/index.rst
new file mode 100644
index 00000000000..953748fd48d
--- /dev/null
+++ b/addons/website_blog/doc/index.rst
@@ -0,0 +1,10 @@
+Blog Module documentation topics
+''''''''''''''''''''''''''''''''
+
+Changelog
+'''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ changelog.rst
From 9ce9bbc13866f4363ea204c9fcd55e9fde45c44b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Fri, 20 Sep 2013 17:38:23 +0200
Subject: [PATCH 06/27] [FIX] website_blog: quite fixed demo data
bzr revid: tde@openerp.com-20130920153823-36rhrr8wcyncw0wn
---
addons/website_blog/website_blog_demo.xml | 147 ++++++++++------------
1 file changed, 65 insertions(+), 82 deletions(-)
diff --git a/addons/website_blog/website_blog_demo.xml b/addons/website_blog/website_blog_demo.xml
index de4ac4f87cc..b9fa3b893f5 100644
--- a/addons/website_blog/website_blog_demo.xml
+++ b/addons/website_blog/website_blog_demo.xml
@@ -17,27 +17,23 @@
-
-
-The news is out, OpenERP's latest version 6.1. is here. It's more
-user-friendly, even more business oriented and efficient to manage your company
-
-How to discover the latest version 6.1.?
-
-Demo :
-Online:
-Download:
-
-We have also put together a functional demo that presents 6.1. Watch this video
-to learn directly from us what OpenERP 6.1. can do for you. Share it in your
-company, with your clients and implement it now for your business.
-
-
Watch on Youtube!
-
-
-
-
+The news is out, OpenERP's latest version 7.0 is here. It's more
+user-friendly, even more business oriented and efficient to manage your company.
We have also put together a functional demo that presents 6.1. Watch this video
+to learn directly from us what OpenERP 6.1. can do for you. Share it in your
+company, with your clients and implement it now for your business.
+
Watch on Youtube!
+
]]>
@@ -47,38 +43,27 @@ company, with your clients and implement it now for your business.
-You like OpenERP, but feel like you want to personalise it more? Now, OpenERP
-goes a step further and lets you customize your dashboard. Thanks to a new
-feature that allows you to customize your dashboard by adding new boards of any
-search view.
-
-
How is it done?
-
-Step 1: access one search view
-
-Step 2: apply the filter you want to see at each connection to the application
-(eg. on sales, manufacturing, etc)
-
-Step 3: add it into the dashboard in the same space where you can save the filter
-
-Step 4: choose the application you want it visible on and the name of the array
-
-Look at this simple example below from Purchase, where I want to put on the
-application's dashboard "Purchases to Approve". After I access the search view
-and apply the filter for "Purchases to Approve", I can add it immediately to my
-Purchase dashboard.
-
-
-
-In less than a minute, the search view is visible on the dashboard
-
-
-
-Of course, you are free to delete what you don't need or like, but just in case
-you change your mind there is a reset button to return to the default view.
-
-
+
You like OpenERP, but feel like you want to personalise it more? Now, OpenERP
+goes a step further and lets you customize your dashboard. Thanks to a new
+feature that allows you to customize your dashboard by adding new boards of any
+search view.
+
How is it done?
+
+
Step 1: access one search view
+
Step 2: apply the filter you want to see at each connection to the application
+(eg. on sales, manufacturing, etc)
+
Step 3: add it into the dashboard in the same space where you can save the filter
+
Step 4: choose the application you want it visible on and the name of the array
+
+
Look at this simple example below from Purchase, where I want to put on the
+application's dashboard "Purchases to Approve". After I access the search view
+and apply the filter for "Purchases to Approve", I can add it immediately to my
+Purchase dashboard.
+
+
In less than a minute, the search view is visible on the dashboard
+
+
Of course, you are free to delete what you don't need or like, but just in case
+you change your mind there is a reset button to return to the default view.
]]>
@@ -88,35 +73,33 @@ you change your mind there is a reset button to return to the default view.
-
-The brand new OpenERP touchscreen point of sale available with 6.1 allows you
-to manage your shop sales very easily. It's fully web based so that you don't
-have to install or deploy any software and all the sales shops can be easily
-consolidated. It works in connected and disconnected modes so that you can
-continue to sell if you lose your internet connection.
-
-
-
-
Here's a summary of its main features and benefits:
-
-100% WEB based
-
-
available for any touchscreen device (ipod, ipad, any tablet)mobile (with portable devices)
no installation required
no synchronization needed, completely integrated
continue working even when your connection is down if you close your browser, data won't be lost
fully web based with a clean interface smart interface
-
-You have different options to select your products. You can do it through the
-barcode reader, just browse through the categories you have put in place (ie.
-drinks, snacks, meals, etc.), or text search in case neither of the other
-options work for you. If you need to use the POS for your restaurant, for
-example, your employees can record at the same time multiple tickets without
-having to wait to do one transaction at a time. Along, to facilitate payment,
-the application allows multiple payment methods.
-
-The POS application is so simple and accessible to use that your shop or
-restaurant will never need any other tool to manage orders. Due to its smart
-and user-friendly interface you don't need any training to learn how to use it.
-Think of it as an out-of-the-box solution to boost your business' productivity.
-
+The brand new OpenERP touchscreen point of sale available with 6.1 allows you
+to manage your shop sales very easily. It's fully web based so that you don't
+have to install or deploy any software and all the sales shops can be easily
+consolidated. It works in connected and disconnected modes so that you can
+continue to sell if you lose your internet connection.
+
+
Here's a summary of its main features and benefits:
+
+
100% WEB based
+
available for any touchscreen device (ipod, ipad, any tablet)mobile (with portable devices)
+
no installation required
+
no synchronization needed, completely integrated
+
continue working even when your connection is down if you close your browser, data won't be lost
+
fully web based with a clean interface smart interface
+
+
You have different options to select your products. You can do it through the
+barcode reader, just browse through the categories you have put in place (ie.
+drinks, snacks, meals, etc.), or text search in case neither of the other
+options work for you. If you need to use the POS for your restaurant, for
+example, your employees can record at the same time multiple tickets without
+having to wait to do one transaction at a time. Along, to facilitate payment,
+the application allows multiple payment methods.
+
The POS application is so simple and accessible to use that your shop or
+restaurant will never need any other tool to manage orders. Due to its smart
+and user-friendly interface you don't need any training to learn how to use it.
+Think of it as an out-of-the-box solution to boost your business' productivity.
+
]]>
From b34f746c36586b5f1a986e36d721513f95b88108 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 11:59:09 +0200
Subject: [PATCH 07/27] [ADD] website_mail: added templates, js and css to have
a generic follow button. Based on the same principle as publish, there is now
a generic button to follow or unfollow objects in openerp. This should
replace all custom instance of subscription in other addons.
bzr revid: tde@openerp.com-20130923095909-4p5aiswlwy14g32k
---
addons/website_mail/__init__.py | 1 +
addons/website_mail/__openerp__.py | 17 ++++--
addons/website_mail/controllers/__init__.py | 1 +
addons/website_mail/controllers/main.py | 58 +++++++++++++++++++
addons/website_mail/static/src/css/Makefile | 2 +
.../static/src/css/website_mail.css | 40 +++++++++++++
.../static/src/css/website_mail.sass | 33 +++++++++++
.../static/src/js/website_mail.js | 27 +++++++++
addons/website_mail/views/website_mail.xml | 22 +++++++
9 files changed, 197 insertions(+), 4 deletions(-)
create mode 100644 addons/website_mail/controllers/__init__.py
create mode 100644 addons/website_mail/controllers/main.py
create mode 100644 addons/website_mail/static/src/css/Makefile
create mode 100644 addons/website_mail/static/src/css/website_mail.css
create mode 100644 addons/website_mail/static/src/css/website_mail.sass
create mode 100644 addons/website_mail/static/src/js/website_mail.js
create mode 100644 addons/website_mail/views/website_mail.xml
diff --git a/addons/website_mail/__init__.py b/addons/website_mail/__init__.py
index f452f9f142e..4eb031ad44b 100644
--- a/addons/website_mail/__init__.py
+++ b/addons/website_mail/__init__.py
@@ -19,4 +19,5 @@
#
##############################################################################
+import controllers
import mail_message
diff --git a/addons/website_mail/__openerp__.py b/addons/website_mail/__openerp__.py
index df01cb69ca1..bf4620d7a8c 100644
--- a/addons/website_mail/__openerp__.py
+++ b/addons/website_mail/__openerp__.py
@@ -24,12 +24,21 @@
'category': 'Website',
'summary': 'Glue Module',
'version': '0.1',
- 'description': """Glue module holding mail improvements for website.
- """,
+ 'description': """Glue module holding mail improvements for website.""",
'author': 'OpenERP SA',
'depends': ['website', 'mail'],
- 'data': [],
- 'qweb': [],
+ 'data': [
+ 'views/website_mail.xml',
+ ],
+ 'css': [
+ 'static/src/css/website_mail.css',
+ ],
+ 'js': [
+ 'static/src/js/website_mail.js',
+ ],
+ 'qweb': [
+ 'static/src/xml/website_mail.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..f1b91ed22a2
--- /dev/null
+++ b/addons/website_mail/controllers/main.py
@@ -0,0 +1,58 @@
+# -*- 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
+from openerp.addons.web.http import request
+from openerp.addons.website import website
+
+
+class WebsiteMail(http.Controller):
+
+ def _find_or_create_partner(self, email, context=None):
+ # TDE TODO: FIXME: use mail_thread method
+ partner_obj = request.registry['res.partner']
+ user_obj = request.registry['res.users']
+ partner_ids = []
+ if request.context['is_public_user'] and email:
+ partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)], context=request.context)
+ if not partner_ids:
+ partner_ids = [partner_obj.create(request.cr, SUPERUSER_ID, {"email": email, "name": email}, request.context)]
+ else:
+ partner_ids = [user_obj.browse(request.cr, request.uid, request.uid, request.context).partner_id.id]
+ return partner_ids
+
+ @website.route(['/website_mail/follow/'], type='http', auth="public")
+ def website_message_subscribe(self, **post):
+ _id = int(post['id'])
+ _message_is_follower = post['message_is_follower'] == 'on'
+ _object = request.registry[post['object']]
+ partner_ids = self._find_or_create_partner(post.get('email'), request.context)
+
+ if _message_is_follower:
+ _object.check_access_rule(request.cr, request.uid, [_id], 'read', request.context)
+ _object.message_unsubscribe(request.cr, SUPERUSER_ID, [_id], partner_ids, context=request.context)
+ else:
+ _object.check_access_rule(request.cr, request.uid, [_id], 'read', request.context)
+ _object.message_subscribe(request.cr, SUPERUSER_ID, [_id], partner_ids, context=request.context)
+ obj = _object.browse(request.cr, request.uid, _id)
+
+ return obj.message_is_follower and "1" or "0"
diff --git a/addons/website_mail/static/src/css/Makefile b/addons/website_mail/static/src/css/Makefile
new file mode 100644
index 00000000000..d7c1ea77439
--- /dev/null
+++ b/addons/website_mail/static/src/css/Makefile
@@ -0,0 +1,2 @@
+sass:
+ sass -t expanded --unix-newlines --watch website_mail.sass:website_mail.css&
diff --git a/addons/website_mail/static/src/css/website_mail.css b/addons/website_mail/static/src/css/website_mail.css
new file mode 100644
index 00000000000..a93199a2ddf
--- /dev/null
+++ b/addons/website_mail/static/src/css/website_mail.css
@@ -0,0 +1,40 @@
+/* ---- FOLLOW ---- */
+a[data-follow] {
+ text-decoration: none !important;
+ z-index: 2;
+}
+a[data-follow] .label {
+ padding: 5px 8px;
+}
+a[data-follow] .css_unfollow, a[data-follow] .css_follow, a[data-follow] .css_unfollowed, a[data-follow] .css_followed {
+ display: none;
+}
+a[data-follow][data-follow='off'] .css_unfollowed, a[data-follow][data-follow='off']:hover .css_follow {
+ display: inline;
+}
+a[data-follow][data-follow='off']:hover .css_unfollowed {
+ display: none;
+}
+a[data-follow][data-follow='on'] .css_followed, a[data-follow][data-follow='on']:hover .css_unfollow {
+ display: inline;
+}
+a[data-follow][data-follow='on']:hover .css_followed {
+ display: none;
+}
+
+[data-follow='off']:not(a) > :not([data-follow]) {
+ opacity: 0.5;
+}
+
+[data-follow]:not(a) {
+ position: relative;
+ overflow: visible;
+ /*&:hover > [data-follow] */
+ /* display: block */
+}
+[data-follow]:not(a) > [data-follow] {
+ position: absolute;
+ right: -6px;
+ top: -10px;
+ display: none;
+}
diff --git a/addons/website_mail/static/src/css/website_mail.sass b/addons/website_mail/static/src/css/website_mail.sass
new file mode 100644
index 00000000000..b648270ec04
--- /dev/null
+++ b/addons/website_mail/static/src/css/website_mail.sass
@@ -0,0 +1,33 @@
+
+/* ---- FOLLOW ---- */
+a[data-follow]
+ text-decoration: none !important
+ z-index: 2
+ .label
+ padding: 5px 8px
+ .css_unfollow, .css_follow, .css_unfollowed, .css_followed
+ display: none
+ &[data-follow='off']
+ .css_unfollowed, &:hover .css_follow
+ display: inline
+ &:hover .css_unfollowed
+ display: none
+ &[data-follow='on']
+ .css_followed, &:hover .css_unfollow
+ display: inline
+ &:hover .css_followed
+ display: none
+
+[data-follow='off']:not(a)
+ >:not([data-follow])
+ opacity: 0.5
+[data-follow]:not(a)
+ position: relative
+ overflow: visible
+ >[data-follow]
+ position: absolute
+ right: -6px
+ top: -10px
+ display: none
+ /*&:hover > [data-follow]*/
+ /* display: block*/
diff --git a/addons/website_mail/static/src/js/website_mail.js b/addons/website_mail/static/src/js/website_mail.js
new file mode 100644
index 00000000000..e40715c30fc
--- /dev/null
+++ b/addons/website_mail/static/src/js/website_mail.js
@@ -0,0 +1,27 @@
+$(document).ready(function () {
+
+ /* ----- FOLLOWING STUFF ---- */
+ $('[data-follow]:has([data-follow])').each(function () {
+ var $pub = $("[data-follow]", this);
+ if($pub.size())
+ $(this).attr("data-follow", $pub.attr("data-follow"));
+ else
+ $(this).removeAttr("data-follow");
+ });
+
+ $(document).on('click', '.js_follow', function (ev) {
+ console.log(ev);
+ ev.preventDefault();
+ var $data = $(":first", this).parents("[data-follow]");
+ var message_is_follower = $data.first().attr("data-follow");
+ $data.attr("data-follow", message_is_follower == 'off' ? 'on' : 'off');
+ $.post('/website_mail/follow', {
+ 'id': $(this).data('id'),
+ 'object': $(this).data('object'),
+ 'message_is_follower': message_is_follower,
+ }, function (result) {
+ $data.attr("data-follow", + result ? 'on' : 'off');
+ });
+ });
+
+});
diff --git a/addons/website_mail/views/website_mail.xml b/addons/website_mail/views/website_mail.xml
new file mode 100644
index 00000000000..7a55352f07b
--- /dev/null
+++ b/addons/website_mail/views/website_mail.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Follow
+ Unfollow
+ Followed
+ Unfollowed
+
+
+
+
+
+
+
+
+
+
+
+
From 8c89bfda88fc33ebcc85c13352417688dd88e752 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 12:17:30 +0200
Subject: [PATCH 08/27] [IMP] website_blog: Some file renaming Delegated
followers of categories / blog posts management to website_mail, allowing to
remove some templates and controllers Various cleanings and improvements in
blog templates
bzr revid: tde@openerp.com-20130923101730-b9606qcyd3sj2pwx
---
addons/website_blog/__openerp__.py | 7 +-
addons/website_blog/controllers/main.py | 61 ++-----------
addons/website_blog/static/src/css/Makefile | 2 +-
addons/website_blog/static/src/css/blog.sass | 42 ---------
.../src/css/{blog.css => website_blog.css} | 0
.../static/src/css/website_blog.sass | 9 ++
.../src/js/{blog.js => website_blog.js} | 3 +-
...log_views.xml => website_blog_classic.xml} | 0
...mplates.xml => website_blog_templates.xml} | 90 +++++++------------
addons/website_blog/website_blog.py | 4 +-
.../static/src/js/website_mail.js | 1 -
11 files changed, 56 insertions(+), 163 deletions(-)
delete mode 100644 addons/website_blog/static/src/css/blog.sass
rename addons/website_blog/static/src/css/{blog.css => website_blog.css} (100%)
create mode 100644 addons/website_blog/static/src/css/website_blog.sass
rename addons/website_blog/static/src/js/{blog.js => website_blog.js} (95%)
rename addons/website_blog/views/{website_blog_views.xml => website_blog_classic.xml} (100%)
rename addons/website_blog/views/{website_templates.xml => website_blog_templates.xml} (56%)
diff --git a/addons/website_blog/__openerp__.py b/addons/website_blog/__openerp__.py
index 104b2f7c073..8b38698dc35 100644
--- a/addons/website_blog/__openerp__.py
+++ b/addons/website_blog/__openerp__.py
@@ -33,8 +33,9 @@ OpenERP Blog
'depends': ['knowledge', 'website_mail'],
'data': [
'website_blog_data.xml',
- 'views/website_blog_views.xml',
- 'views/website_templates.xml',
+ 'website_blog_demo.xml',
+ 'views/website_blog_classic.xml',
+ 'views/website_blog_templates.xml',
'views/res_config.xml',
# 'wizard/document_page_create_menu_view.xml',
'wizard/document_page_show_diff_view.xml',
@@ -42,7 +43,7 @@ OpenERP Blog
'security/website_mail.xml',
],
'demo': [
- 'website_blog_demo.xml'
+ # 'website_blog_demo.xml'
],
'test': [
'test/document_page_test00.yml'
diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py
index 564beeaed39..090a4bfba4d 100644
--- a/addons/website_blog/controllers/main.py
+++ b/addons/website_blog/controllers/main.py
@@ -59,11 +59,12 @@ class website_mail(http.Controller):
blog_post = None
blog_posts = None
pager = None
- if not category_id:
- category_ids = category_obj.search(cr, uid, [], context=context)
- categories = category_obj.browse(cr, uid, category_ids, context=context)
+
+ category_ids = category_obj.search(cr, uid, [], context=context)
+ categories = category_obj.browse(cr, uid, category_ids, context=context)
+
# category but no post chosen: display the last ones, create pager
- elif category_id and not blog_post_id:
+ if category_id and not blog_post_id:
pager_begin = (page - 1) * self._category_post_per_page
pager_end = page * self._category_post_per_page
category = category_obj.browse(cr, uid, category_id, context=context)
@@ -129,55 +130,3 @@ class website_mail(http.Controller):
'website_published': False,
}, context=create_context)
return werkzeug.utils.redirect("/blog/%s/%s/?unable_editor=1" % (category_id, blog_id))
-
- def _find_or_create_partner(self, email, context=None):
- partner_obj = request.registry['res.partner']
- user_obj = request.registry['res.users']
- partner_ids = []
- if request.context['is_public_user'] and email:
- partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)], context=request.context)
- if not partner_ids:
- partner_ids = [partner_obj.create(request.cr, SUPERUSER_ID, {"email": email, "name": email}, request.context)]
- else:
- partner_ids = [user_obj.browse(request.cr, request.uid, request.uid, request.context).partner_id.id]
- return partner_ids
-
- @website.route(['/blog//subscribe'], type='http', auth="public")
- def category_subscribe(self, category_id=None, **post):
- partner_ids = self._find_or_create_partner(post.get('email'), request.context)
- category_obj = request.registry['blog.category']
-
- category_obj.check_access_rule(request.cr, request.uid, [category_id], 'read', request.context)
- category_obj.message_subscribe(request.cr, SUPERUSER_ID, [category_id], partner_ids, context=request.context)
-
- return self.blog(category_id=category_id)
-
- @website.route(['/blog//unsubscribe'], type='http', auth="public")
- def category_unsubscribe(self, category_id=None, **post):
- partner_ids = self._find_or_create_partner(post.get('email'), request.context)
- category_obj = request.registry['blog.category']
-
- category_obj.check_access_rule(request.cr, request.uid, [category_id], 'read', request.context)
- category_obj.message_unsubscribe(request.cr, SUPERUSER_ID, [category_id], partner_ids, context=request.context)
-
- return self.blog(category_id=category_id)
-
- @website.route(['/blog///subscribe'], type='http', auth="public")
- def blog_post_subscribe(self, category_id=None, blog_post_id=None, **post):
- partner_ids = self._find_or_create_partner(post.get('email'), request.context)
- blog_post_obj = request.registry['blog.post']
-
- blog_post_obj.check_access_rule(request.cr, request.uid, [blog_post_id], 'read', request.context)
- blog_post_obj.message_subscribe(request.cr, SUPERUSER_ID, [blog_post_id], partner_ids, context=request.context)
-
- return self.blog(category_id=category_id, blog_post_id=blog_post_id)
-
- @website.route(['/blog///unsubscribe'], type='http', auth="public")
- def blog_post_unsubscribe(self, category_id=None, blog_post_id=None, **post):
- partner_ids = self._find_or_create_partner(post.get('email'), request.context)
- blog_post_obj = request.registry['blog.post']
-
- blog_post_obj.check_access_rule(request.cr, request.uid, [blog_post_id], 'read', request.context)
- blog_post_obj.message_unsubscribe(request.cr, SUPERUSER_ID, [blog_post_id], partner_ids, context=request.context)
-
- return self.blog(category_id=category_id, blog_post_id=blog_post_id)
diff --git a/addons/website_blog/static/src/css/Makefile b/addons/website_blog/static/src/css/Makefile
index 5042d6d8f54..f71f4dd7be8 100644
--- a/addons/website_blog/static/src/css/Makefile
+++ b/addons/website_blog/static/src/css/Makefile
@@ -1,2 +1,2 @@
sass:
- sass --compass --trace -t expanded blog.sass blog.css
+ sass --compass --trace -t expanded website_blog.sass website_blog.css
diff --git a/addons/website_blog/static/src/css/blog.sass b/addons/website_blog/static/src/css/blog.sass
deleted file mode 100644
index b176996ca80..00000000000
--- a/addons/website_blog/static/src/css/blog.sass
+++ /dev/null
@@ -1,42 +0,0 @@
-@import "compass/css3"
-
-.css_website_mail
- .has-error
- border-color: red
- .css_nav_month
- display: none
- &:first-of-type
- display: block
-
-/* ---- PUBLISH ---- */
-/ a[data-publish]
-/ text-decoration: none !important
-/ z-index: 2
-/ .label
-/ padding: 5px 8px
-/ .css_unpublish, .css_publish, .css_unpublished, .css_published
-/ display: none
-/ &[data-publish='off']
-/ .css_unpublished, &:hover .css_publish
-/ display: inline
-/ &:hover .css_unpublished
-/ display: none
-/ &[data-publish='on']
-/ .css_published, &:hover .css_unpublish
-/ display: inline
-/ &:hover .css_published
-/ display: none
-
-/ [data-publish='off']:not(a)
-/ >:not([data-publish])
-/ opacity: 0.5
-/ [data-publish]:not(a)
-/ position: relative
-/ overflow: visible
-/ >[data-publish]
-/ position: absolute
-/ right: -6px
-/ top: -10px
-/ display: none
- /*&:hover > [data-publish]*/
- /* display: block*/
diff --git a/addons/website_blog/static/src/css/blog.css b/addons/website_blog/static/src/css/website_blog.css
similarity index 100%
rename from addons/website_blog/static/src/css/blog.css
rename to addons/website_blog/static/src/css/website_blog.css
diff --git a/addons/website_blog/static/src/css/website_blog.sass b/addons/website_blog/static/src/css/website_blog.sass
new file mode 100644
index 00000000000..8a7c5f30a5e
--- /dev/null
+++ b/addons/website_blog/static/src/css/website_blog.sass
@@ -0,0 +1,9 @@
+@import "compass/css3"
+
+.css_website_mail
+ .has-error
+ border-color: red
+ .css_nav_month
+ display: none
+ &:first-of-type
+ display: block
diff --git a/addons/website_blog/static/src/js/blog.js b/addons/website_blog/static/src/js/website_blog.js
similarity index 95%
rename from addons/website_blog/static/src/js/blog.js
rename to addons/website_blog/static/src/js/website_blog.js
index 4db3726123a..ed39817ca59 100644
--- a/addons/website_blog/static/src/js/blog.js
+++ b/addons/website_blog/static/src/js/website_blog.js
@@ -27,9 +27,10 @@ $(document).ready(function () {
}
});
- $form = $('.js_website_mail form#post');
+ $form = $('.js_website_blog form#comment');
$form.submit(function (e) {
e.preventDefault();
+ console.log(e)
var error = $form.find("textarea").val().length < 3;
$form.find("textarea").toggleClass("has-error", error);
if (!error) {
diff --git a/addons/website_blog/views/website_blog_views.xml b/addons/website_blog/views/website_blog_classic.xml
similarity index 100%
rename from addons/website_blog/views/website_blog_views.xml
rename to addons/website_blog/views/website_blog_classic.xml
diff --git a/addons/website_blog/views/website_templates.xml b/addons/website_blog/views/website_blog_templates.xml
similarity index 56%
rename from addons/website_blog/views/website_templates.xml
rename to addons/website_blog/views/website_blog_templates.xml
index dddf59258f7..c5c2ef0ee62 100644
--- a/addons/website_blog/views/website_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -12,47 +12,29 @@
-
-
-
We have also put together a functional demo that presents 6.1. Watch this video
From 35ce110ab014cd75c18d91eaddd5ad30635775a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 14:42:48 +0200
Subject: [PATCH 14/27] [IMP] website_blog: improved blog post view, to
integrate comments and a comments pager
bzr revid: tde@openerp.com-20130923124248-zuuoqbyb1d5sqi6a
---
addons/website_blog/controllers/main.py | 11 +++++++
.../views/website_blog_templates.xml | 33 +++++++++++++------
2 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py
index 737cbb7959c..b7149e97d98 100644
--- a/addons/website_blog/controllers/main.py
+++ b/addons/website_blog/controllers/main.py
@@ -74,6 +74,17 @@ class website_mail(http.Controller):
category = category_obj.browse(cr, uid, category_id, context=context)
blog_post = blog_post_obj.browse(cr, uid, blog_post_id, context=context)
+ if blog_post_id:
+ blog_post = blog_post_obj.browse(cr, uid, blog_post_id, context=context)
+ pager = request.website.pager(
+ url="/blog/%s/%s/" % (category_id, blog_post_id),
+ total=len(blog_post.website_message_ids),
+ page=page,
+ step=self._post_comment_per_page,
+ scope=7
+ )
+ print pager
+
values.update({
'blog_post': blog_post,
'blog_posts': blog_posts,
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml
index c5c2ef0ee62..519558bed43 100644
--- a/addons/website_blog/views/website_blog_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -42,24 +42,37 @@
+
+
+
+
+
+
+ Comment
+
+
+ Comments
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+ on
-
-
-
-
From d910b8c5330a8645aad6843679eed555cbeeda6b Mon Sep 17 00:00:00 2001
From: ddm
Date: Mon, 23 Sep 2013 15:37:03 +0200
Subject: [PATCH 15/27] [FIX] improve keyword detection
bzr revid: ddm@openerp.com-20130923133703-ysil60j2t08gk0kf
---
addons/website/static/src/js/website.seo.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/addons/website/static/src/js/website.seo.js b/addons/website/static/src/js/website.seo.js
index 1d9234165c4..3a27e8187e6 100644
--- a/addons/website/static/src/js/website.seo.js
+++ b/addons/website/static/src/js/website.seo.js
@@ -281,13 +281,13 @@
return $('body').children().not('.js_seo_configuration').text();
},
isInBody: function (text) {
- return new RegExp(text, "gi").test(this.bodyText());
+ return new RegExp("\\b"+text+"\\b", "gi").test(this.bodyText());
},
isInTitle: function (text) {
- return new RegExp(text, "gi").test(this.title());
+ return new RegExp("\\b"+text+"\\b", "gi").test(this.title());
},
isInDescription: function (text) {
- return new RegExp(text, "gi").test(this.description());
+ return new RegExp("\\b"+text+"\\b", "gi").test(this.description());
},
});
From 5c9bdf1dcbe7950f409b813912e8cb0a5bd0ed85 Mon Sep 17 00:00:00 2001
From: ddm
Date: Mon, 23 Sep 2013 15:42:40 +0200
Subject: [PATCH 16/27] [IMP] SEO sitemap.xml + robots.txt
bzr revid: ddm@openerp.com-20130923134240-4qx4pyfv2rl65xyz
---
addons/website/controllers/main.py | 8 ++++++++
addons/website/views/views.xml | 12 ++++++++++++
addons/website/website.py | 2 +-
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index 5cd2891d868..fa2145dc77d 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -271,4 +271,12 @@ class Website(openerp.addons.web.controllers.main.Home):
def kanban(self, **post):
return request.website.kanban_col(**post)
+ @website.route(['/robots.txt'], type='http', auth="public")
+ def robots(self):
+ return request.website.render('website.robots', {'url_root': request.httprequest.url_root})
+
+ @website.route(['/sitemap.xml'], type='http', auth="public")
+ def sitemap(self):
+ return request.website.render('website.sitemap', {'pages': request.website.list_pages()})
+
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml
index ebc788104a8..a5466e38dca 100644
--- a/addons/website/views/views.xml
+++ b/addons/website/views/views.xml
@@ -386,5 +386,17 @@
+
+# robotstxt.org/
+User-agent: *
+Sitemap: sitemap.xml
+
+
+
+
+
+
+
+
diff --git a/addons/website/website.py b/addons/website/website.py
index 018e89a5f4b..0957054ed8f 100644
--- a/addons/website/website.py
+++ b/addons/website/website.py
@@ -172,7 +172,7 @@ class website(osv.osv):
]
}
- def list_pages(self, cr, uid, context=None):
+ def list_pages(self, cr, uid, ids, context=None):
""" Available pages in the website/CMS. This is mostly used for links
generation and can be overridden by modules setting up new HTML
controllers for dynamic pages (e.g. blog).
From dcdefd0e8da3377e8a4f5a46349721a67293ae76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 15:46:39 +0200
Subject: [PATCH 17/27] [IMP] website_mail: added override of mail.message
search and check_access_rule to restrict messages vsible by public user to
have website_published = True
bzr revid: tde@openerp.com-20130923134639-ou1hkwzetm9st95f
---
addons/website_mail/mail_message.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/addons/website_mail/mail_message.py b/addons/website_mail/mail_message.py
index 54af1a3a618..6d5893dd797 100644
--- a/addons/website_mail/mail_message.py
+++ b/addons/website_mail/mail_message.py
@@ -19,6 +19,7 @@
#
##############################################################################
+from openerp.tools.translate import _
from openerp.osv import osv, fields
@@ -30,3 +31,31 @@ class MailMessage(osv.Model):
'Publish', help="Publish on the website as a blog"
),
}
+
+ def _search(self, cr, uid, args, offset=0, limit=None, order=None,
+ context=None, count=False, access_rights_uid=None):
+ """ Override that adds specific access rights of mail.message, to restrict
+ messages to published messages for public users. """
+ group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
+ group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
+ if group_user_id in [group.id for group in group_ids]:
+ args = ['&', ('website_published', '=', True)] + list(args)
+
+ return super(MailMessage, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
+ context=context, count=False, access_rights_uid=access_rights_uid)
+
+ def check_access_rule(self, cr, uid, ids, operation, context=None):
+ """ Add Access rules of mail.message for non-employee user:
+ - read:
+ - raise if the type is comment and subtype NULL (internal note)
+ """
+ group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
+ group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
+ if group_user_id in [group.id for group in group_ids]:
+ cr.execute('SELECT DISTINCT id FROM "%s" WHERE website_published IS FALSE AND id = ANY (%%s)' % (self._table), (ids,))
+ if cr.fetchall():
+ raise osv.except_osv(
+ _('Access Denied'),
+ _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation))
+
+ return super(MailMessage, self).check_access_rule(cr, uid, ids=ids, operation=operation, context=context)
From 4b0c341f2ba8c69b8243d0c5b53e83e2ec600e8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 15:47:02 +0200
Subject: [PATCH 18/27] [CLEAN] website_blog: cleaned controllers blog code
bzr revid: tde@openerp.com-20130923134702-d426ypzic6g9n1oj
---
addons/website_blog/controllers/main.py | 88 +++++++++++++++----------
addons/website_blog/website_blog.py | 1 -
2 files changed, 53 insertions(+), 36 deletions(-)
diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py
index b7149e97d98..09c912cc61c 100644
--- a/addons/website_blog/controllers/main.py
+++ b/addons/website_blog/controllers/main.py
@@ -19,7 +19,6 @@
#
##############################################################################
-from openerp import SUPERUSER_ID
from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.addons.website import website
@@ -42,39 +41,57 @@ class website_mail(http.Controller):
'/blog///page//'
], type='http', auth="public")
def blog(self, category_id=None, blog_post_id=None, page=1, **post):
+ """ Prepare all values to display the blog.
+
+ :param integer category_id: id of the category currently browsed.
+ :param integer blog_post_id: ID of the blog post currently browsed. If not
+ set, the user is browsing the category and
+ a post pager is calculated. If set the user
+ is reading the blog post and a comments pager
+ is calculated.
+ :param integer page: current page of the pager. Can be the category or
+ post pager.
+ :param dict post: kwargs, may contain
+
+ - 'unable_editor': editor control
+
+ :return dict values: values for the templates, containing
+
+ - 'blog_post': browse of the current post, if blog_post_id
+ - 'blog_posts': list of browse records that are the posts to display
+ in a given category, if not blog_post_id
+ - 'category': browse of the current category, if category_id
+ - 'categories': list of browse records of categories
+ - 'pager': the pager to display, posts pager in a category or comments
+ pager in a blog post
+ - 'nav_list': a dict [year][month] for archives navigation
+ """
cr, uid, context = request.cr, request.uid, request.context
blog_post_obj = request.registry['blog.post']
category_obj = request.registry['blog.category']
- values = {
- 'blog_ids': None,
- 'blog_id': None,
- 'nav_list': dict(),
- 'unable_editor': post.get('unable_editor')
- }
-
- # no category chosen: display categories
- categories = None
category = None
blog_post = None
blog_posts = None
pager = None
+ nav = {}
category_ids = category_obj.search(cr, uid, [], context=context)
categories = category_obj.browse(cr, uid, category_ids, context=context)
-
- # category but no post chosen: display the last ones, create pager
- if category_id and not blog_post_id:
- pager_begin = (page - 1) * self._category_post_per_page
- pager_end = page * self._category_post_per_page
+ if category_id:
category = category_obj.browse(cr, uid, category_id, context=context)
- blog_posts = category.blog_ids[pager_begin:pager_end]
- pager = request.website.pager(url="/blog/%s/" % category_id, total=len(category.blog_ids), page=page, step=self._category_post_per_page, scope=7)
- elif category_id and blog_post_id:
- category = category_obj.browse(cr, uid, category_id, context=context)
- blog_post = blog_post_obj.browse(cr, uid, blog_post_id, context=context)
-
- if blog_post_id:
+ if not blog_post_id:
+ pager = request.website.pager(
+ url="/blog/%s/" % category_id,
+ total=len(category.blog_ids),
+ page=page,
+ step=self._category_post_per_page,
+ scope=7
+ )
+ pager_begin = (page - 1) * self._category_post_per_page
+ pager_end = page * self._category_post_per_page
+ blog_posts = category.blog_ids[pager_begin:pager_end]
+ if category_id and blog_post_id:
blog_post = blog_post_obj.browse(cr, uid, blog_post_id, context=context)
pager = request.website.pager(
url="/blog/%s/%s/" % (category_id, blog_post_id),
@@ -83,25 +100,27 @@ class website_mail(http.Controller):
step=self._post_comment_per_page,
scope=7
)
- print pager
+ pager_begin = (page - 1) * self._post_comment_per_page
+ pager_end = page * self._post_comment_per_page
+ blog_post.website_message_ids = blog_post.website_message_ids[pager_begin:pager_end]
- values.update({
+ for group in blog_post_obj.read_group(cr, uid, [], ['name', 'create_date'], groupby="create_date", orderby="create_date asc", context=context):
+ year = group['create_date'].split(" ")[1]
+ if not year in nav:
+ nav[year] = {'name': year, 'create_date_count': 0, 'months': []}
+ nav[year]['create_date_count'] += group['create_date_count']
+ nav[year]['months'].append(group)
+
+ values = {
'blog_post': blog_post,
'blog_posts': blog_posts,
'categories': categories,
'category': category,
'pager': pager,
- })
+ 'nav_list': nav,
+ 'unable_editor': post.get('unable_editor')
+ }
- for group in blog_post_obj.read_group(cr, uid, [], ['name', 'create_date'], groupby="create_date", orderby="create_date asc", context=context):
- print 'group', group
- year = group['create_date'].split(" ")[1]
- if not values['nav_list'].get(year):
- values['nav_list'][year] = {'name': year, 'create_date_count': 0, 'months': []}
- values['nav_list'][year]['create_date_count'] += group['create_date_count']
- values['nav_list'][year]['months'].append(group)
-
- print values
return request.website.render("website_blog.index", values)
@website.route(['/blog/nav'], type='http', auth="public")
@@ -129,7 +148,6 @@ class website_mail(http.Controller):
cr, uid, context = request.cr, request.uid, request.context
url = request.httprequest.host_url
request.session.body = post.get('body')
- print category_id, blog_post_id, post
if request.context['is_public_user']: # purpose of this ?
return '%s/admin#action=redirect&url=%s/blog/%s/%s/post' % (url, url, category_id, blog_post_id)
diff --git a/addons/website_blog/website_blog.py b/addons/website_blog/website_blog.py
index 0fc61e06336..1df81ee98f6 100644
--- a/addons/website_blog/website_blog.py
+++ b/addons/website_blog/website_blog.py
@@ -111,7 +111,6 @@ class BlogPost(osv.Model):
domain=lambda self: [
'&', ('model', '=', self._name), ('type', '=', 'comment')
],
- auto_join=True,
string='Website Messages',
help="Website communication history",
),
From f040cfc7b1b8cfcdaddc3c2ea36110e886a8e47d Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Mon, 23 Sep 2013 15:49:14 +0200
Subject: [PATCH 19/27] [FIX] placeholder image when edition starts
it's apparently better when it's completely broken and can't be edited. YMMV
bzr revid: xmo@openerp.com-20130923134914-1si4fz8fg72iktvw
---
addons/website/static/src/js/website.editor.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 0c32cf40fb2..945164dfed8 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -406,6 +406,9 @@
allowedContent: true,
// Don't insert paragraphs around content in e.g.
autoParagraph: false,
+ // Don't automatically add or in empty block-level
+ // elements when edition starts
+ fillEmptyBlocks: false,
filebrowserImageUploadUrl: "/website/attach",
// Support for sharedSpaces in 4.x
extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref',
From f217813c62af50ef7be5d023b50abfe0a6625d47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 16:35:01 +0200
Subject: [PATCH 20/27] [FIX] call write with a list of ids because I can't be
arsed to handle the other case
bzr revid: tde@openerp.com-20130923143501-99onvm218vg222pq
---
addons/website/view.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/website/view.py b/addons/website/view.py
index 8b3da581732..04dfa44594c 100644
--- a/addons/website/view.py
+++ b/addons/website/view.py
@@ -97,7 +97,7 @@ class view(osv.osv):
field = el.get('data-oe-field')
column = Model._all_columns[field].column
- Model.write(cr, uid, int(el.get('data-oe-id')), {
+ Model.write(cr, uid, [int(el.get('data-oe-id'))], {
field: self.convert_embedded_field(cr, uid, el, column, context=context)
}, context=context)
From f420f98492c24c786e7cb3c47399f16603487ffc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 16:35:34 +0200
Subject: [PATCH 21/27] [FIX] turns out a new mandatory positional argument
blows things up a bit
bzr revid: tde@openerp.com-20130923143534-qnab6bv6upw1vt70
---
addons/website/static/src/js/website.editor.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 945164dfed8..b82f665c838 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -649,7 +649,7 @@
return openerp.jsonRpc('/web/dataset/call_kw', 'call', {
model: 'website',
method: 'list_pages',
- args: [],
+ args: [null],
kwargs: {
context: website.get_context()
},
From 0d49f723eba97c7f81f657c4d768d8dcc21cc875 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 16:44:22 +0200
Subject: [PATCH 22/27] [CLEAN] website_blog: misc cleaning
bzr revid: tde@openerp.com-20130923144422-7vuocxo8bntvuana
---
addons/website_blog/__openerp__.py | 3 +--
addons/website_blog/res_config.py | 25 +++++++++++++++++--
addons/website_blog/tests/test_controllers.py | 4 +--
.../views/website_blog_templates.xml | 14 +++--------
addons/website_mail/tests/test_controllers.py | 4 +--
5 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/addons/website_blog/__openerp__.py b/addons/website_blog/__openerp__.py
index 8b38698dc35..431a95ac8ea 100644
--- a/addons/website_blog/__openerp__.py
+++ b/addons/website_blog/__openerp__.py
@@ -33,7 +33,6 @@ OpenERP Blog
'depends': ['knowledge', 'website_mail'],
'data': [
'website_blog_data.xml',
- 'website_blog_demo.xml',
'views/website_blog_classic.xml',
'views/website_blog_templates.xml',
'views/res_config.xml',
@@ -43,7 +42,7 @@ OpenERP Blog
'security/website_mail.xml',
],
'demo': [
- # 'website_blog_demo.xml'
+ 'website_blog_demo.xml'
],
'test': [
'test/document_page_test00.yml'
diff --git a/addons/website_blog/res_config.py b/addons/website_blog/res_config.py
index 1b6e02e691d..f88d953b0d3 100644
--- a/addons/website_blog/res_config.py
+++ b/addons/website_blog/res_config.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.osv import fields, osv
@@ -6,6 +25,8 @@ from openerp.osv import fields, osv
class website_config_settings(osv.osv_memory):
_inherit = 'website.config.settings'
_columns = {
- 'group_website_mail_reply': fields.boolean('Visitors can reply on blogs',
- implied_group='website_mail.group_website_mail_reply'),
+ 'group_website_mail_reply': fields.boolean(
+ 'Visitors can reply on blogs',
+ implied_group='website_blog.group_website_mail_reply'
+ ),
}
diff --git a/addons/website_blog/tests/test_controllers.py b/addons/website_blog/tests/test_controllers.py
index 60ffa5ac9a3..d1c28cab5af 100644
--- a/addons/website_blog/tests/test_controllers.py
+++ b/addons/website_blog/tests/test_controllers.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Business Applications
-# Copyright (c) 2013-TODAY OpenERP S.A.
+# 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
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml
index 45484e786a8..8edf269ab53 100644
--- a/addons/website_blog/views/website_blog_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -12,7 +12,7 @@
-
+
@@ -31,6 +31,7 @@
+
@@ -124,17 +125,8 @@
-
-
-
-
-
+
Archives
diff --git a/addons/website_mail/tests/test_controllers.py b/addons/website_mail/tests/test_controllers.py
index 60ffa5ac9a3..d1c28cab5af 100644
--- a/addons/website_mail/tests/test_controllers.py
+++ b/addons/website_mail/tests/test_controllers.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Business Applications
-# Copyright (c) 2013-TODAY OpenERP S.A.
+# 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
From 5ebd3c50474e84a58e66536462c7f71ee7b6e430 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 16:48:53 +0200
Subject: [PATCH 23/27] [IMP] website_blog: blog_post: public user limited to
published posts
bzr revid: tde@openerp.com-20130923144853-unxxa7i5u5zfskhk
---
addons/website_blog/security/website_mail.xml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/addons/website_blog/security/website_mail.xml b/addons/website_blog/security/website_mail.xml
index c765a620d1d..eff2a657087 100644
--- a/addons/website_blog/security/website_mail.xml
+++ b/addons/website_blog/security/website_mail.xml
@@ -2,10 +2,17 @@
-
+ Visitors can reply on blogs
+
+ Blog Post: public: published only
+
+ [('website_published', '=', True)]
+
+
+
From d71a20054305e99a6246b08bbfd4e40a736022d0 Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Mon, 23 Sep 2013 16:57:44 +0200
Subject: [PATCH 24/27] [FIX] handling of multiple children in an HTML field
bzr revid: xmo@openerp.com-20130923145744-3dpta6w2qnqe851b
---
addons/website/view.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/addons/website/view.py b/addons/website/view.py
index 8b3da581732..1c91914ff2f 100644
--- a/addons/website/view.py
+++ b/addons/website/view.py
@@ -70,8 +70,11 @@ class view(osv.osv):
column_type = type_override or type(column)
if issubclass(column_type, fields.html):
- # FIXME: multiple children?
- return html.tostring(el[0])
+ content = []
+ if el.text: content.append(el.text)
+ content.extend(html.tostring(child)
+ for child in el.iterchildren(tag=etree.Element))
+ return '\n'.join(content)
elif issubclass(column_type, fields.integer):
return int(el.text_content())
elif issubclass(column_type, fields.float):
From 68d9add6cea9eccc23c3b7fd0e9b13881ef0a4fd Mon Sep 17 00:00:00 2001
From: Xavier Morel
Date: Mon, 23 Sep 2013 17:16:33 +0200
Subject: [PATCH 25/27] [ADD] saving m2o fields
bzr revid: xmo@openerp.com-20130923151633-61v7gw0llol4fvyo
---
addons/website/view.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/addons/website/view.py b/addons/website/view.py
index 1c91914ff2f..676704a269e 100644
--- a/addons/website/view.py
+++ b/addons/website/view.py
@@ -83,7 +83,11 @@ class view(osv.osv):
fields.date, fields.datetime)):
return el.text_content()
# TODO: fields.selection
- # TODO: fields.many2one
+ elif issubclass(column_type, fields.many2one):
+ matches = self.pool[column._obj].name_search(
+ cr, uid, name=el.text_content().strip(), context=context)
+ # FIXME: more than one match, error reporting
+ return matches[0][0]
elif issubclass(column_type, fields.function):
# FIXME: special-case selection as in get_pg_type?
return self.convert_embedded_field(
From a42d020a3470a871a5da031e1bf7d41460c8874b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 23 Sep 2013 17:40:39 +0200
Subject: [PATCH 26/27] [CLEAN] [IMP] website_blog: cleaned blog.post,
blog.post.category and blog.tag models; added basic appearance of tags and
base routing method in controllers. Will have to be improved in a future
branch.
bzr revid: tde@openerp.com-20130923154039-ppn1loy002tcppun
---
addons/website_blog/controllers/main.py | 64 +++++++++++++------
.../views/website_blog_templates.xml | 3 +
addons/website_blog/website_blog.py | 29 +++++++--
addons/website_blog/website_blog_demo.xml | 1 +
4 files changed, 71 insertions(+), 26 deletions(-)
diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py
index 09c912cc61c..b727bbbafd5 100644
--- a/addons/website_blog/controllers/main.py
+++ b/addons/website_blog/controllers/main.py
@@ -38,12 +38,16 @@ class website_mail(http.Controller):
'/blog//',
'/blog///',
'/blog//page//',
- '/blog///page//'
+ '/blog///page//',
+ '/blog/tag/',
+ '/blog/tag//',
], type='http', auth="public")
- def blog(self, category_id=None, blog_post_id=None, page=1, **post):
+ def blog(self, category_id=None, blog_post_id=None, tag_id=None, page=1, **post):
""" Prepare all values to display the blog.
:param integer category_id: id of the category currently browsed.
+ :param integer tag_id: id of the tag that is currently used to filter
+ blog posts
:param integer blog_post_id: ID of the blog post currently browsed. If not
set, the user is browsing the category and
a post pager is calculated. If set the user
@@ -64,12 +68,15 @@ class website_mail(http.Controller):
- 'categories': list of browse records of categories
- 'pager': the pager to display, posts pager in a category or comments
pager in a blog post
+ - 'tag': current tag, if tag_id
- 'nav_list': a dict [year][month] for archives navigation
"""
cr, uid, context = request.cr, request.uid, request.context
blog_post_obj = request.registry['blog.post']
+ tag_obj = request.registry['blog.tag']
category_obj = request.registry['blog.category']
+ tag = None
category = None
blog_post = None
blog_posts = None
@@ -78,24 +85,40 @@ class website_mail(http.Controller):
category_ids = category_obj.search(cr, uid, [], context=context)
categories = category_obj.browse(cr, uid, category_ids, context=context)
+
+ if tag_id:
+ tag = tag_obj.browse(cr, uid, tag_id, context=context)
if category_id:
category = category_obj.browse(cr, uid, category_id, context=context)
- if not blog_post_id:
- pager = request.website.pager(
- url="/blog/%s/" % category_id,
- total=len(category.blog_ids),
- page=page,
- step=self._category_post_per_page,
- scope=7
- )
- pager_begin = (page - 1) * self._category_post_per_page
- pager_end = page * self._category_post_per_page
- blog_posts = category.blog_ids[pager_begin:pager_end]
- if category_id and blog_post_id:
+
+ if category and blog_post_id:
blog_post = blog_post_obj.browse(cr, uid, blog_post_id, context=context)
+ blog_message_ids = blog_post.website_message_ids
+ else:
+ if category and tag:
+ blog_posts = [cat_post for cat_post in category.blog_post_ids
+ if tag_id in [post_tag.id for post_tag in cat_post.tag_ids]]
+ elif category:
+ blog_posts = category.blog_post_ids
+ elif tag:
+ blog_posts = tag.blog_post_ids
+
+ if blog_posts:
+ pager = request.website.pager(
+ url="/blog/%s/" % category_id,
+ total=len(blog_posts),
+ page=page,
+ step=self._category_post_per_page,
+ scope=7
+ )
+ pager_begin = (page - 1) * self._category_post_per_page
+ pager_end = page * self._category_post_per_page
+ blog_posts = blog_posts[pager_begin:pager_end]
+
+ if blog_post:
pager = request.website.pager(
url="/blog/%s/%s/" % (category_id, blog_post_id),
- total=len(blog_post.website_message_ids),
+ total=len(blog_message_ids),
page=page,
step=self._post_comment_per_page,
scope=7
@@ -112,10 +135,11 @@ class website_mail(http.Controller):
nav[year]['months'].append(group)
values = {
- 'blog_post': blog_post,
- 'blog_posts': blog_posts,
'categories': categories,
'category': category,
+ 'tag': tag,
+ 'blog_post': blog_post,
+ 'blog_posts': blog_posts,
'pager': pager,
'nav_list': nav,
'unable_editor': post.get('unable_editor')
@@ -160,17 +184,17 @@ class website_mail(http.Controller):
context=dict(context, mail_create_nosubcribe=True))
request.session.body = False
- return self.blog(category_id=category_id, blog_post_id=blog_post_id)
+ return werkzeug.utils.redirect("/blog/%s/%s/?unable_editor=1" % (category_id, blog_post_id))
@website.route(['/blog//new'], type='http', auth="public")
def create_blog_post(self, category_id=None, **post):
cr, uid, context = request.cr, request.uid, request.context
create_context = dict(context, mail_create_nosubscribe=True)
- blog_id = request.registry['blog.post'].create(
+ blog_post_id = request.registry['blog.post'].create(
request.cr, request.uid, {
'category_id': category_id,
'name': _("Blog title"),
'content': '',
'website_published': False,
}, context=create_context)
- return werkzeug.utils.redirect("/blog/%s/%s/?unable_editor=1" % (category_id, blog_id))
+ return werkzeug.utils.redirect("/blog/%s/%s/?unable_editor=1" % (category_id, blog_post_id))
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml
index 8edf269ab53..59d39252f77 100644
--- a/addons/website_blog/views/website_blog_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -41,6 +41,9 @@
on
+
+
+