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/wiki.py b/addons/wiki/wiki.py index e2032634eb7..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" @@ -86,25 +86,22 @@ 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') + 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'): + 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 - def write(self, cr, uid, ids, vals, context=None): - 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) Wiki() class History(osv.osv): @@ -113,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 825537811e2..197bb93bbda 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -27,10 +27,11 @@ form
- + + @@ -94,8 +95,7 @@ - - + @@ -126,8 +126,8 @@ tree - - + + @@ -140,12 +140,11 @@ form - + - + - @@ -161,7 +160,7 @@ id="menu_action_history" action="action_history"/> - - + tree_but_open wiki.groups Wiki Pages - + 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 9d688b34f1c..f97430312bd 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']) @@ -46,8 +46,8 @@ def report_menu_create(self, cr, uid, data, context): 'name': group.name, 'view_type':'form', 'view_mode':"tree,form", - 'context': "{'group_id':%d}" % (group.id,), - 'domain': "[('group_id','child_of',%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' }) pool.get('ir.ui.menu').create(cr, uid, { @@ -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..c348055c9e9 --- /dev/null +++ b/addons/wiki/wizard/show_diff.py @@ -0,0 +1,53 @@ +# -*- 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): + history = self.pool.get('wiki.wiki.history') + 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.text('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