2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-11-24 07:52:15 +00:00
|
|
|
##############################################################################
|
2010-03-15 13:40:23 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-11-24 07:52:15 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# 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.
|
2008-11-24 07:52:15 +00:00
|
|
|
#
|
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-11-24 07:52:15 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-03-15 13:40:23 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-11-24 07:52:15 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp.tools.translate import _
|
[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
2013-09-20 11:12:21 +00:00
|
|
|
|
2008-11-24 07:52:15 +00:00
|
|
|
|
|
|
|
class showdiff(osv.osv_memory):
|
2010-03-17 08:36:08 +00:00
|
|
|
""" Disp[ay Difference for History """
|
|
|
|
|
[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
2013-09-20 11:12:21 +00:00
|
|
|
_name = 'blog.post.history.show_diff'
|
2010-03-15 13:40:23 +00:00
|
|
|
|
2010-04-12 12:41:47 +00:00
|
|
|
def get_diff(self, cr, uid, context=None):
|
2010-11-23 07:05:05 +00:00
|
|
|
if context is None:
|
2010-11-22 10:37:53 +00:00
|
|
|
context = {}
|
[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
2013-09-20 11:12:21 +00:00
|
|
|
history = self.pool.get('blog.post.history')
|
2010-09-01 11:58:23 +00:00
|
|
|
ids = context.get('active_ids', [])
|
2010-07-12 06:39:51 +00:00
|
|
|
|
2008-11-24 10:14:28 +00:00
|
|
|
diff = ""
|
|
|
|
if len(ids) == 2:
|
|
|
|
if ids[0] > ids[1]:
|
2012-08-10 00:09:08 +00:00
|
|
|
diff = history.getDiff(cr, uid, ids[1], ids[0])
|
2008-11-24 10:14:28 +00:00
|
|
|
else:
|
2012-08-10 00:09:08 +00:00
|
|
|
diff = history.getDiff(cr, uid, ids[0], ids[1])
|
2008-11-24 10:14:28 +00:00
|
|
|
|
|
|
|
elif len(ids) == 1:
|
|
|
|
old = history.browse(cr, uid, ids[0])
|
[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
2013-09-20 11:12:21 +00:00
|
|
|
nids = history.search(cr, uid, [('post_id', '=', old.post_id.id)])
|
2008-11-24 10:14:28 +00:00
|
|
|
nids.sort()
|
2012-08-10 00:09:08 +00:00
|
|
|
diff = history.getDiff(cr, uid, ids[0], nids[-1])
|
2008-11-26 09:04:41 +00:00
|
|
|
else:
|
2012-08-07 11:34:14 +00:00
|
|
|
raise osv.except_osv(_('Warning!'), _('You need to select minimum one or maximum two history revisions!'))
|
2008-11-24 10:14:28 +00:00
|
|
|
return diff
|
2008-11-24 07:52:15 +00:00
|
|
|
|
|
|
|
_columns = {
|
2012-08-10 00:09:08 +00:00
|
|
|
'diff': fields.text('Diff', readonly=True),
|
2008-11-24 07:52:15 +00:00
|
|
|
}
|
2010-03-17 08:36:08 +00:00
|
|
|
|
2008-11-24 07:52:15 +00:00
|
|
|
_defaults = {
|
2012-08-10 00:09:08 +00:00
|
|
|
'diff': get_diff
|
2008-11-24 07:52:15 +00:00
|
|
|
}
|
2010-03-17 08:36:08 +00:00
|
|
|
|
2009-03-06 22:18:24 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|