From 15d51bf5e96522374d2bd08a3ec32e686ba0326c Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 24 Nov 2008 11:56:51 +0530 Subject: [PATCH 1/4] bugfixing to the group tree action for opening related list of pages action change form wizard to ir.actions.act_window bzr revid: mga@tinyerp.com-20081124062651-l0crpajm6kqfx55w --- addons/wiki/wiki.py | 10 ---------- addons/wiki/wiki_view.xml | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py index e2032634eb7..3d749c2ef2f 100644 --- a/addons/wiki/wiki.py +++ b/addons/wiki/wiki.py @@ -86,16 +86,6 @@ class Wiki(osv.osv): } } - def read(self, cr, uid, cids, fields=None, context=None, load='_classic_read'): - ids = [] - for id in cids: - if type(id) == type(1): - ids.append(id) - elif type(id) == type(u''): - ids.append(10) - result = super(Wiki, self).read(cr, uid, ids, fields, None, load='_classic_read') - return result - def write(self, cr, uid, ids, vals, context=None): if vals.get('text_area'): vals['history_id']=[(0,0,{ diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml index 825537811e2..0aed52c4856 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -174,11 +174,11 @@ res_model="wiki.wiki" src_model="wiki.groups"/> - + tree_but_open wiki.groups Wiki Pages - + From 2e4230ae7c4cc5e3742a91803d618795a5bee091 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 24 Nov 2008 12:19:47 +0530 Subject: [PATCH 2/4] * Few changes, fields in history * Bug fix for the create manu wizard bzr revid: mga@tinyerp.com-20081124064947-l0dgvyyzt49vkb6i --- addons/wiki/wiki.py | 31 ++++++++++++++++++------------- addons/wiki/wiki_view.xml | 11 +++++------ addons/wiki/wizard/create_menu.py | 2 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py index 3d749c2ef2f..5d7d05615cb 100644 --- a/addons/wiki/wiki.py +++ b/addons/wiki/wiki.py @@ -87,14 +87,21 @@ class Wiki(osv.osv): } def write(self, cr, uid, ids, vals, context=None): + result = super(Wiki,self).write(cr, uid, ids, vals, context) + history = self.pool.get('wiki.wiki.history') + if vals.get('text_area'): - vals['history_id']=[(0,0,{ - 'minor_edit':vals.get('minor_edit', False), - 'text_area':vals['text_area'], - 'modify_by':uid, - 'summary':vals.get('summary','') - })] - return super(Wiki,self).write(cr, uid, ids, vals, context) + for id in ids: + res = { + 'minor_edit':vals.get('minor_edit', True), + 'text_area':vals.get('text_area',''), + 'write_uid':uid, + 'wiki_id' : id, + 'summary':vals.get('summary','') + } + history.create(cr, uid, res) + return result + Wiki() class History(osv.osv): @@ -103,17 +110,15 @@ class History(osv.osv): _rec_name="date_time" _order = 'id DESC' _columns={ - 'date_time':fields.datetime("Date",select=True), + 'create_date':fields.datetime("Date",select=True), 'text_area':fields.text("Text area",select=True), 'minor_edit':fields.boolean('This is a major edit ?',select=True), 'summary':fields.char('Summary',size=256, select=True), - 'modify_by':fields.many2one('res.users',"Modify By", select=True), - 'hist_write_date':fields.datetime("Last modified", select=True), - 'history_wiki_id':fields.many2one('wiki.wiki','Wiki Id', select=True) + 'write_uid':fields.many2one('res.users',"Modify By", select=True), + 'wiki_id':fields.many2one('wiki.wiki','Wiki Id', select=True) } _defaults = { - 'hist_write_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), - 'modify_by': lambda obj,cr,uid,context: uid, + 'write_uid': lambda obj,cr,uid,context: uid, } def getDiff(self, cr, uid, v1, v2, context={}): import difflib diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml index 0aed52c4856..4fca7a8f7df 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -126,8 +126,8 @@ tree - - + + @@ -140,12 +140,11 @@ form
- + - + -
@@ -161,7 +160,7 @@ id="menu_action_history" action="action_history"/> - Date: Mon, 24 Nov 2008 13:22:15 +0530 Subject: [PATCH 3/4] implement * differance wizard to show diff between 2 history lines bzr revid: mga@tinyerp.com-20081124075215-7bhiqoyc6vray2bg --- addons/wiki/__terp__.py | 1 + addons/wiki/wizard/__init__.py | 3 +- addons/wiki/wizard/create_menu.py | 4 +-- addons/wiki/wizard/show_diff.py | 50 ++++++++++++++++++++++++++++++ addons/wiki/wizard/wizard_view.xml | 25 +++++++++++++++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 addons/wiki/wizard/show_diff.py create mode 100644 addons/wiki/wizard/wizard_view.xml diff --git a/addons/wiki/__terp__.py b/addons/wiki/__terp__.py index b42cb542b1e..f78d78955d6 100644 --- a/addons/wiki/__terp__.py +++ b/addons/wiki/__terp__.py @@ -14,6 +14,7 @@ "demo_xml" : [], "update_xml" : [ "wiki_view.xml", + "wizard/wizard_view.xml", "security/ir.model.access.csv" ], "active": False, diff --git a/addons/wiki/wizard/__init__.py b/addons/wiki/wizard/__init__.py index 2d0a1a53130..ee734cd9600 100644 --- a/addons/wiki/wizard/__init__.py +++ b/addons/wiki/wizard/__init__.py @@ -1 +1,2 @@ -import create_menu \ No newline at end of file +import create_menu +import show_diff \ No newline at end of file diff --git a/addons/wiki/wizard/create_menu.py b/addons/wiki/wizard/create_menu.py index 2b6c4df8e64..93507afeab2 100644 --- a/addons/wiki/wizard/create_menu.py +++ b/addons/wiki/wizard/create_menu.py @@ -38,7 +38,7 @@ section_fields = { 'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True}, } -def report_menu_create(self, cr, uid, data, context): +def wiki_menu_create(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) group = pool.get('wiki.groups').browse(cr, uid, data['id']) @@ -65,7 +65,7 @@ class wizard_create_menu(wizard.interface): 'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]} }, 'create_menu': { - 'actions': [report_menu_create], + 'actions': [wiki_menu_create], 'result': { 'type':'state', 'state':'end' diff --git a/addons/wiki/wizard/show_diff.py b/addons/wiki/wizard/show_diff.py new file mode 100644 index 00000000000..6ea9bcf814d --- /dev/null +++ b/addons/wiki/wizard/show_diff.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields,osv + + + +class showdiff(osv.osv_memory): + _name = 'wizard.wiki.history.show_diff' + + def _get_diff(self, cr, uid, ctx): + print 'XXXXXXXXXXXXXXXXXX : ', ctx + history = self.pool.get('wiki.wiki.history') + res = {} +# if lan(ids) == 2: +# diff = history.getDiff(cr, uid, ids[0]. ids[1]) +# res = { +# ids[0] : diff, +# ids[1] : diff, +# } + return res + + _columns = { + 'diff': fields.function(_get_diff, method=True, type='char', string='Diff'), + } + _defaults = { + 'diff': _get_diff + } +showdiff() + + \ No newline at end of file diff --git a/addons/wiki/wizard/wizard_view.xml b/addons/wiki/wizard/wizard_view.xml new file mode 100644 index 00000000000..2fa562b8aec --- /dev/null +++ b/addons/wiki/wizard/wizard_view.xml @@ -0,0 +1,25 @@ + + + + + Wiki Differance + wizard.wiki.history.show_diff + form + +
+ + + + +
+ + +
+
\ No newline at end of file From 655205d823208ca60628fba61fddbddd642bd008 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 24 Nov 2008 15:44:28 +0530 Subject: [PATCH 4/4] implement * show diff for the 2 wiki history line * make section enabled based on the wiki group bzr revid: mga@tinyerp.com-20081124101428-z89vuq3p4822m2bd --- addons/wiki/wiki.py | 4 ++-- addons/wiki/wiki_view.xml | 6 +++--- addons/wiki/wizard/create_menu.py | 2 +- addons/wiki/wizard/show_diff.py | 33 +++++++++++++++++-------------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py index 5d7d05615cb..5e1ba1b7aa6 100644 --- a/addons/wiki/wiki.py +++ b/addons/wiki/wiki.py @@ -42,11 +42,11 @@ class WikiGroup(osv.osv): 'page_ids':fields.one2many('wiki.wiki', 'group_id', 'Pages'), 'notes':fields.text("Description", select=True), 'create_date':fields.datetime("Created Date", select=True), - 'template': fields.text('Wiki Template') + 'template': fields.text('Wiki Template'), + 'section': fields.boolean("Make Section?") } WikiGroup() - class Wiki(osv.osv): _name="wiki.wiki" _description="Wiki Page" diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml index 4fca7a8f7df..197bb93bbda 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -27,10 +27,11 @@ form
- + + @@ -94,8 +95,7 @@ - - + diff --git a/addons/wiki/wizard/create_menu.py b/addons/wiki/wizard/create_menu.py index 93507afeab2..f97430312bd 100644 --- a/addons/wiki/wizard/create_menu.py +++ b/addons/wiki/wizard/create_menu.py @@ -46,7 +46,7 @@ def wiki_menu_create(self, cr, uid, data, context): 'name': group.name, 'view_type':'form', 'view_mode':"tree,form", - 'context': "{'group_id':%d}" % (group.id,), + 'context': "{'group_id':%d, 'section':%d}" % (group.id, group.section), 'domain': "[('group_id','child_of',[%d])]" % (group.id,), 'res_model': 'wiki.wiki' }) diff --git a/addons/wiki/wizard/show_diff.py b/addons/wiki/wizard/show_diff.py index 6ea9bcf814d..c348055c9e9 100644 --- a/addons/wiki/wizard/show_diff.py +++ b/addons/wiki/wizard/show_diff.py @@ -22,29 +22,32 @@ from osv import fields,osv - - class showdiff(osv.osv_memory): _name = 'wizard.wiki.history.show_diff' def _get_diff(self, cr, uid, ctx): - print 'XXXXXXXXXXXXXXXXXX : ', ctx history = self.pool.get('wiki.wiki.history') - res = {} -# if lan(ids) == 2: -# diff = history.getDiff(cr, uid, ids[0]. ids[1]) -# res = { -# ids[0] : diff, -# ids[1] : diff, -# } - return res + ids = ctx.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, [('wiki_id','=',old.wiki_id.id)]) + nids.sort() + if ids[0] != nids[-1]: + diff = history.getDiff(cr, uid, ids[0], nids[-1]) + + return diff _columns = { - 'diff': fields.function(_get_diff, method=True, type='char', string='Diff'), + 'diff': fields.text('Diff'), } _defaults = { 'diff': _get_diff } -showdiff() - - \ No newline at end of file +showdiff() \ No newline at end of file