[REM] website_blog: removed blog.post.history model and related stuff.
authorJamin Shah <jas@openerp.com>
Thu, 31 Jul 2014 11:41:21 +0000 (17:11 +0530)
committerThibault Delavallée <tde@openerp.com>
Fri, 12 Sep 2014 08:18:02 +0000 (10:18 +0200)
This is not necessary as we will soon have a way to store the various versions
of any website page, including the blog. Let's hope.

addons/website_blog/__init__.py
addons/website_blog/__openerp__.py
addons/website_blog/models/website_blog.py
addons/website_blog/security/ir.model.access.csv
addons/website_blog/tests/test_website_blog.yml
addons/website_blog/views/website_blog_views.xml
addons/website_blog/wizard/__init__.py [deleted file]
addons/website_blog/wizard/document_page_show_diff.py [deleted file]
addons/website_blog/wizard/document_page_show_diff_view.xml [deleted file]

index 2d54250..708d6ce 100644 (file)
@@ -21,4 +21,3 @@
 
 import controllers
 import models
-import wizard
index 69fb61c..c10da06 100644 (file)
@@ -36,7 +36,6 @@ OpenERP Blog
         'data/website_blog_data.xml',
         'views/website_blog_views.xml',
         'views/website_blog_templates.xml',
-        'wizard/document_page_show_diff_view.xml',
         'security/ir.model.access.csv',
         'security/website_blog.xml',
     ],
index 5cb6f82..dc0eaad 100644 (file)
@@ -71,10 +71,6 @@ class BlogPost(osv.Model):
             string='Website Messages',
             help="Website communication history",
         ),
-        'history_ids': fields.one2many(
-            'blog.post.history', 'post_id',
-            'History', help='Last post modifications',
-        ),
         # creation / update stuff
         'create_date': fields.datetime(
             'Created on',
@@ -157,16 +153,6 @@ class BlogPost(osv.Model):
             self.pool['mail.message'].write(cr, SUPERUSER_ID, msg_ids, {'path': new_attribute}, context=context)
         return content
 
-    def create_history(self, cr, uid, ids, vals, context=None):
-        for i in ids:
-            history = self.pool.get('blog.post.history')
-            if vals.get('content'):
-                res = {
-                    'content': vals.get('content', ''),
-                    'post_id': i,
-                }
-                history.create(cr, uid, res)
-
     def create(self, cr, uid, vals, context=None):
         if context is None:
             context = {}
@@ -174,40 +160,10 @@ class BlogPost(osv.Model):
             vals['content'] = self._postproces_content(cr, uid, None, vals['content'], context=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):
         if 'content' in vals:
             vals['content'] = self._postproces_content(cr, uid, None, vals['content'], context=context)
         result = super(BlogPost, self).write(cr, uid, ids, vals, context)
-        self.create_history(cr, uid, ids, vals, context)
         return result
-
-class BlogPostHistory(osv.Model):
-    _name = "blog.post.history"
-    _description = "Blog Post History"
-    _order = 'id DESC'
-    _rec_name = "create_date"
-
-    _columns = {
-        'post_id': fields.many2one('blog.post', 'Blog Post'),
-        'summary': fields.char('Summary', 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):
-        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 = ''
-        if text1:
-            line1 = text1.splitlines(1)
-        if text2:
-            line2 = text2.splitlines(1)
-        if (not line1 and not line2) or (line1 == line2):
-            raise osv.except_osv(_('Warning!'), _('There are no changes in revisions.'))
-        diff = difflib.HtmlDiff()
-        return diff.make_table(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=True)
index cb0498a..1ca50fc 100644 (file)
@@ -2,6 +2,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
 blog_blog_all,blog.blog,model_blog_blog,,1,0,0,0\r
 blog_post_all,blog.post,model_blog_post,,1,0,0,0\r
 blog_post,blog.post,model_blog_post,base.group_document_user,1,1,1,1\r
-blog_post_history,blog.post.history,model_blog_post_history,base.group_document_user,1,0,1,0\r
 blog_tag,blog.tag,model_blog_tag,,1,0,0,0\r
 blog_tag_edition,blog.tag,model_blog_tag,base.group_document_user,1,1,1,1\r
index 826d849..c1a0633 100644 (file)
 
       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[:] })
index 1cf8636..5198284 100644 (file)
         </record>
         <menuitem id="menu_blog" parent="menu_wiki" name="Blogs" action="action_blog_blog" sequence="20"/>
 
-        <!-- History Tree view -->
-        <record model="ir.ui.view" id="view_blog_history_tree">
-            <field name="name">blog.post.history.tree</field>
-            <field name="model">blog.post.history</field>
-            <field name="arch" type="xml">
-                <tree string="Document History">
-                    <field name="create_date"/>
-                    <field name="create_uid"/>
-                    <field name="post_id"/>
-                </tree>
-            </field>
-        </record>
-        <!-- History Form view  -->
-        <record model="ir.ui.view" id="view_blog_history_form">
-            <field name="name">blog.post.history.form</field>
-            <field name="model">blog.post.history</field>
-            <field name="arch" type="xml">
-                <form string="Blog Post History">
-                    <label for="post_id" class="oe_edit_only"/>
-                    <h1><field name="post_id" select="1" /></h1>
-                    <label for="create_date" class="oe_edit_only"/>
-                    <field name="create_date" readonly="1"/>
-                </form>
-            </field>
-        </record>
-        <!-- History Action  -->
-        <record model="ir.actions.act_window" id="action_history">
-            <field name="name">Page history</field>
-            <field name="res_model">blog.post.history</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-        </record>
-        <menuitem id="menu_page_history" parent="menu_wiki" name="Pages history" action="action_history" sequence="30" groups="base.group_no_one"/>
-        <act_window
-            id="action_related_page_history"
-            context="{'search_default_post_id': [active_id], 'default_post_id': active_id}"
-            domain="[('post_id','=',active_id)]"
-            name="Page History"
-            res_model="blog.post.history"
-            src_model="blog.post"/>
-
     </data>
 </openerp>
diff --git a/addons/website_blog/wizard/__init__.py b/addons/website_blog/wizard/__init__.py
deleted file mode 100644 (file)
index 1c7a3a5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- 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/>.
-#
-##############################################################################
-
-import document_page_show_diff
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/website_blog/wizard/document_page_show_diff.py b/addons/website_blog/wizard/document_page_show_diff.py
deleted file mode 100644 (file)
index 49056fd..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- 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 fields, osv
-from openerp.tools.translate import _
-
-
-class showdiff(osv.osv_memory):
-    """ Disp[ay Difference for History """
-
-    _name = 'blog.post.history.show_diff'
-
-    def get_diff(self, cr, uid, context=None):
-        if context is None:
-            context = {}
-        history = self.pool.get('blog.post.history')
-        ids = context.get('active_ids', [])
-
-        diff = ""
-        if len(ids) == 2:
-            if ids[0] > ids[1]:
-                diff = history.getDiff(cr, uid, ids[1], ids[0])
-            else:
-                diff = history.getDiff(cr, uid, ids[0], ids[1])
-
-        elif len(ids) == 1:
-            old = history.browse(cr, uid, ids[0])
-            nids = history.search(cr, uid, [('post_id', '=', old.post_id.id)])
-            nids.sort()
-            diff = history.getDiff(cr, uid, ids[0], nids[-1])
-        else:
-            raise osv.except_osv(_('Warning!'), _('You need to select minimum one or maximum two history revisions!'))
-        return diff
-
-    _columns = {
-        'diff': fields.text('Diff', readonly=True),
-    }
-
-    _defaults = {
-        'diff': get_diff
-    }
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/website_blog/wizard/document_page_show_diff_view.xml b/addons/website_blog/wizard/document_page_show_diff_view.xml
deleted file mode 100644 (file)
index 684ce0c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-
-        <!-- Create Index Form view  -->
-        <record id="view_wiki_show_diff" model="ir.ui.view">
-            <field name="name">Show Difference</field>
-            <field name="model">blog.post.history.show_diff</field>
-            <field name="arch" type="xml">
-                <form string="Difference">
-                    <field name="diff" widget="html" options='{"safe": True}'/>
-                    <footer>
-                        <button string="Cancel" class="oe_link" special="cancel" />
-                    </footer>
-                </form>
-            </field>
-        </record>
-        <!-- Create Index Action  -->
-        <record id="action_view_wiki_show_diff" model="ir.actions.act_window">
-            <field name="name">Difference</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">blog.post.history.show_diff</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">form</field>
-            <field name="target">new</field>
-        </record>
-        <!-- Create Index Action Window  -->
-        <act_window 
-            id="action_view_wiki_show_diff_values"
-            key2="client_action_multi"
-            name="Difference"
-            res_model="blog.post.history.show_diff"
-            src_model="blog.post.history"
-            view_mode="form"
-            target="new"
-            view_type="form"/>
-
-    </data>
-</openerp>