merging new development from lp:~openerp/openobject-addons/addons-wiki-new/
for wiki module new development * diff wizard * groups, sections-visible, invisable bzr revid: mga@tinyerp.com-20081124125818-xkyzn77s6q3013lr
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
"wiki_view.xml",
|
||||
"wizard/wizard_view.xml",
|
||||
"security/ir.model.access.csv"
|
||||
],
|
||||
"active": False,
|
||||
|
||||
+20
-25
@@ -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
|
||||
|
||||
+10
-11
@@ -27,10 +27,11 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form srting="Wiki Groups">
|
||||
<group colspan="4" col="6">
|
||||
<group colspan="4" col="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="parent_id" select="2"/>
|
||||
<field name="create_date" readonly="2"/>
|
||||
<field name="section"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Notes">
|
||||
@@ -94,8 +95,7 @@
|
||||
<group col="6" colspan="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="group_id" select="1" on_change="onchange_group_id(group_id, text_area)"/>
|
||||
<field name="section" select="2"/>
|
||||
|
||||
<field name="section" select="2" invisible="not context.get('section',False)"/>
|
||||
<field name="write_date" readonly="1" select="2"/>
|
||||
<field name="write_uid" readonly="1" select="2"/>
|
||||
<field name="tags" select="2" groups="base.group_extended"/>
|
||||
@@ -126,8 +126,8 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree srting="Wiki History">
|
||||
<field name="date_time"/>
|
||||
<field name="modify_by"/>
|
||||
<field name="create_date"/>
|
||||
<field name="write_uid"/>
|
||||
<field name="minor_edit"/>
|
||||
<field name="summary"/>
|
||||
</tree>
|
||||
@@ -140,12 +140,11 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form srting="Wiki History">
|
||||
<field name="history_wiki_id" select="1" colspan="4"/>
|
||||
<field name="wiki_id" select="1" colspan="4"/>
|
||||
<field name="summary" select="1" colspan="4"/>
|
||||
<field name="text_area" select="1" colspan="4" widget="text_wiki"/>
|
||||
<field name="date_time" select="1"/>
|
||||
<field name="create_date" select="1"/>
|
||||
<field name="minor_edit" select="1"/>
|
||||
<field name="history_wiki_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -161,7 +160,7 @@
|
||||
id="menu_action_history"
|
||||
action="action_history"/>
|
||||
|
||||
<act_window domain="[('history_wiki_id', '=', active_id)]"
|
||||
<act_window domain="[('wiki_id', '=', active_id)]"
|
||||
id="act_wiki_wiki_history"
|
||||
name="History"
|
||||
res_model="wiki.wiki.history"
|
||||
@@ -174,11 +173,11 @@
|
||||
res_model="wiki.wiki"
|
||||
src_model="wiki.groups"/>
|
||||
|
||||
<record id="ir_open_journal_period" model="ir.values">
|
||||
<record id="ir_open_wiki_pages" model="ir.values">
|
||||
<field name="key2">tree_but_open</field>
|
||||
<field name="model">wiki.groups</field>
|
||||
<field name="name">Wiki Pages</field>
|
||||
<field eval="'ir.actions.wizard,%d'%act_wiki_group_open" name="value"/>
|
||||
<field eval="'ir.actions.act_window,%d'%act_wiki_group_open" name="value"/>
|
||||
<field eval="True" name="object"/>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
import create_menu
|
||||
import create_menu
|
||||
import show_diff
|
||||
@@ -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'
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_wiki_history_diff" model="ir.ui.view">
|
||||
<field name="name">Wiki Differance</field>
|
||||
<field name="model">wizard.wiki.history.show_diff</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="History Differance">
|
||||
<separator string="Wiki Differance" colspan="4"/>
|
||||
<field name="diff" widget="html_tag" nolabel="1" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window
|
||||
id="act_view_diff"
|
||||
name="View Differance"
|
||||
res_model="wizard.wiki.history.show_diff"
|
||||
src_model="wiki.wiki.history"
|
||||
target="new"
|
||||
view_mode="form"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user