from osv import fields, osv
from tools.translate import _
import difflib
+import tools
class wiki_wiki(osv.osv):
""" wiki """
'method': lambda *a: 'page',
}
- def open_wiki_page(self, cr, uid, ids, context):
+ def open_wiki_page(self, cr, uid, ids, context=None):
""" Opens Wiki Page of Group
@param cr: the current row, from the database cursor,
@param ids: List of open wiki group’s IDs
@return: dictionay of open wiki window on give group id
"""
- if not context:
- context = {}
if type(ids) in (int,long,):
ids = [ids]
group_id = False
value['view_type'] = 'form'
value['view_mode'] = 'tree,form'
elif group.method == 'tree':
- view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'wiki.wiki.tree.childs')])
+ view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'wiki.wiki.tree.children')])
value['view_id'] = view_id
value['domain'] = [('group_id', '=', group.id), ('parent_id', '=', False)]
value['view_type'] = 'tree'
'name': fields.char('Title', size=256, select=True, required=True),
'write_uid': fields.many2one('res.users', "Last Contributor", select=True),
'text_area': fields.text("Content"),
- 'create_uid': fields.many2one('res.users', 'Author', select=True),
- 'create_date': fields.datetime("Created on", select=True),
- 'write_date': fields.datetime("Modification Date", select=True),
+ 'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True),
+ 'create_date': fields.datetime("Created on", select=True, readonly=True),
+ 'write_date': fields.datetime("Modification Date", select=True, readonly=True),
'tags': fields.char('Keywords', size=1024, select=True),
'history_id': fields.one2many('wiki.wiki.history', 'wiki_id', 'History Lines'),
'minor_edit': fields.boolean('Minor edit', select=True),
'child_ids': fields.one2many('wiki.wiki', 'parent_id', 'Child Pages'),
}
_defaults = {
- 'toc': lambda *a: True,
- 'review': lambda *a: True,
- 'minor_edit': lambda *a: True,
+ 'toc': True,
+ 'review': True,
+ 'minor_edit': True,
}
- def onchange_group_id(self, cr, uid, ids, group_id, content, context={}):
+ def onchange_group_id(self, cr, uid, ids, group_id, content, context=None):
""" @param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
if (not group_id) or content:
return {}
- grp = self.pool.get('wiki.groups').browse(cr, uid, group_id)
+ grp = self.pool.get('wiki.groups').browse(cr, uid, group_id, context=context)
section = '0'
for page in grp.page_ids:
if page.section: section = page.section
@param uid: the current user’s ID for security checks,
@param id: Give wiki page's ID """
- return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
+ return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
def create_history(self, cr, uid, ids, vals, context=None):
history_id = False
""" @param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks, """
-
- id = super(wiki_wiki2, self).create(cr, uid, vals, context)
- self.create_history(cr, uid, [id], vals, context)
- return id
+ wiki_id = super(wiki_wiki2, self).create(cr, uid,
+ vals, context)
+ self.create_history(cr, uid, [wiki_id], vals, context)
+ return wiki_id
def write(self, cr, uid, ids, vals, context=None):
""" @param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks, """
-
result = super(wiki_wiki2, self).write(cr, uid, ids, vals, context)
self.create_history(cr, uid, ids, vals, context)
return result
text2 = history_pool.read(cr, uid, [v2], ['text_area'])[0]['text_area']
line1 = line2 = ''
if text1:
- line1 = text1.splitlines(1)
+ line1 = tools.ustr(text1.splitlines(1))
if text2:
- line2 = text2.splitlines(1)
+ line2=tools.ustr(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()