mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-22 20:12:04 -06:00
[FIX] PEP8 errors in Odoo code only
This commit is contained in:
parent
480dfe6543
commit
8d97a7ba01
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@ -15,11 +15,11 @@
|
||||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import document_page
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
from . import (
|
||||
document_page,
|
||||
wizard
|
||||
)
|
||||
|
@ -43,6 +43,5 @@ Web pages
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'images': [],
|
||||
'css' : ['static/src/css/document_page.css'],
|
||||
'css': ['static/src/css/document_page.css'],
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
@ -22,7 +22,7 @@
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
import difflib
|
||||
from openerp import tools
|
||||
|
||||
|
||||
class document_page(osv.osv):
|
||||
_name = "document.page"
|
||||
@ -32,10 +32,11 @@ class document_page(osv.osv):
|
||||
def _get_page_index(self, cr, uid, page, link=True):
|
||||
index = []
|
||||
for subpage in page.child_ids:
|
||||
index += ["<li>"+ self._get_page_index(cr, uid, subpage) +"</li>"]
|
||||
index += ["<li>" + self._get_page_index(cr, uid, subpage) +
|
||||
"</li>"]
|
||||
r = ''
|
||||
if link:
|
||||
r = '<a href="#id=%s">%s</a>'%(page.id,page.name)
|
||||
r = '<a href="#id=%s">%s</a>' % (page.id, page.name)
|
||||
if index:
|
||||
r += "<ul>" + "".join(index) + "</ul>"
|
||||
return r
|
||||
@ -44,35 +45,43 @@ class document_page(osv.osv):
|
||||
res = {}
|
||||
for page in self.browse(cr, uid, ids, context=context):
|
||||
if page.type == "category":
|
||||
content = self._get_page_index(cr, uid, page, link=False)
|
||||
content = self._get_page_index(cr, uid, page, link=False)
|
||||
else:
|
||||
content = page.content
|
||||
res[page.id] = content
|
||||
content = page.content
|
||||
res[page.id] = content
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Title', required=True),
|
||||
'type':fields.selection([('content','Content'), ('category','Category')], 'Type', help="Page type"),
|
||||
|
||||
'parent_id': fields.many2one('document.page', 'Category', domain=[('type','=','category')]),
|
||||
'type': fields.selection([('content', 'Content'),
|
||||
('category', 'Category')],
|
||||
'Type', help="Page type"),
|
||||
'parent_id': fields.many2one('document.page', 'Category',
|
||||
domain=[('type', '=', 'category')]),
|
||||
'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
|
||||
|
||||
'content': fields.text("Content"),
|
||||
'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
|
||||
|
||||
'history_ids': fields.one2many('document.page.history', 'page_id', 'History'),
|
||||
'display_content': fields.function(_get_display_content,
|
||||
string='Displayed Content',
|
||||
type='text'),
|
||||
'history_ids': fields.one2many('document.page.history', 'page_id',
|
||||
'History'),
|
||||
'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True),
|
||||
|
||||
'create_date': fields.datetime("Created on", select=True, readonly=True),
|
||||
'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True),
|
||||
'write_date': fields.datetime("Modification Date", select=True, readonly=True),
|
||||
'write_uid': fields.many2one('res.users', "Last Contributor", select=True, readonly=True),
|
||||
'create_date': fields.datetime("Created on", select=True,
|
||||
readonly=True),
|
||||
'create_uid': fields.many2one('res.users', 'Author', select=True,
|
||||
readonly=True),
|
||||
'write_date': fields.datetime("Modification Date", select=True,
|
||||
readonly=True),
|
||||
'write_uid': fields.many2one('res.users', "Last Contributor",
|
||||
select=True, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'type':'content',
|
||||
'type': 'content',
|
||||
}
|
||||
|
||||
def onchange_parent_id(self, cr, uid, ids, parent_id, content, context=None):
|
||||
def onchange_parent_id(self, cr, uid, ids, parent_id, content,
|
||||
context=None):
|
||||
res = {}
|
||||
if parent_id and not content:
|
||||
parent = self.browse(cr, uid, parent_id, context=context)
|
||||
@ -102,6 +111,7 @@ class document_page(osv.osv):
|
||||
self.create_history(cr, uid, ids, vals, context)
|
||||
return result
|
||||
|
||||
|
||||
class document_page_history(osv.osv):
|
||||
_name = "document.page.history"
|
||||
_description = "Document Page History"
|
||||
@ -109,11 +119,11 @@ class document_page_history(osv.osv):
|
||||
_rec_name = "create_date"
|
||||
|
||||
_columns = {
|
||||
'page_id': fields.many2one('document.page', 'Page'),
|
||||
'summary': fields.char('Summary', size=256, select=True),
|
||||
'content': fields.text("Content"),
|
||||
'create_date': fields.datetime("Date"),
|
||||
'create_uid': fields.many2one('res.users', "Modified By"),
|
||||
'page_id': fields.many2one('document.page', 'Page'),
|
||||
'summary': fields.char('Summary', size=256, 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):
|
||||
@ -126,8 +136,8 @@ class document_page_history(osv.osv):
|
||||
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.'))
|
||||
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)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
return diff.make_table(line1, line2, "Revision-%s" % (v1),
|
||||
"Revision-%s" % (v2), context=True)
|
||||
|
@ -22,6 +22,7 @@
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
|
||||
class document_page_create_menu(osv.osv_memory):
|
||||
""" Create Menu """
|
||||
_name = "document.page.create.menu"
|
||||
@ -29,13 +30,17 @@ class document_page_create_menu(osv.osv_memory):
|
||||
|
||||
_columns = {
|
||||
'menu_name': fields.char('Menu Name', size=256, required=True),
|
||||
'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
|
||||
'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu',
|
||||
required=True),
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(document_page_create_menu,self).default_get(cr, uid, fields, context=context)
|
||||
res = super(document_page_create_menu, self).default_get(cr, uid,
|
||||
fields,
|
||||
context=
|
||||
context)
|
||||
page_id = context.get('active_id')
|
||||
obj_page = self.pool.get('document.page')
|
||||
page = obj_page.browse(cr, uid, page_id, context=context)
|
||||
@ -46,7 +51,6 @@ class document_page_create_menu(osv.osv_memory):
|
||||
if context is None:
|
||||
context = {}
|
||||
obj_page = self.pool.get('document.page')
|
||||
obj_view = self.pool.get('ir.ui.view')
|
||||
obj_menu = self.pool.get('ir.ui.menu')
|
||||
obj_action = self.pool.get('ir.actions.act_window')
|
||||
page_id = context.get('active_id', False)
|
||||
@ -71,14 +75,15 @@ class document_page_create_menu(osv.osv_memory):
|
||||
value['res_id'] = page.id
|
||||
|
||||
action_id = obj_action.create(cr, SUPERUSER_ID, value)
|
||||
# only the super user is allowed to create menu due to security rules on ir.values
|
||||
# only the super user is allowed to create menu due to security rules
|
||||
# on ir.values
|
||||
menu_id = obj_menu.create(cr, SUPERUSER_ID, {
|
||||
'name': data.menu_name,
|
||||
'parent_id':data.menu_parent_id.id,
|
||||
'icon': 'STOCK_DIALOG_QUESTION',
|
||||
'action': 'ir.actions.act_window,'+ str(action_id),
|
||||
}, context)
|
||||
obj_page.write(cr, uid, [page_id], {'menu_id':menu_id})
|
||||
'name': data.menu_name,
|
||||
'parent_id': data.menu_parent_id.id,
|
||||
'icon': 'STOCK_DIALOG_QUESTION',
|
||||
'action': 'ir.actions.act_window,' + str(action_id),
|
||||
}, context)
|
||||
obj_page.write(cr, uid, [page_id], {'menu_id': menu_id})
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'reload',
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
import base64
|
||||
|
||||
|
||||
class showdiff(osv.osv_memory):
|
||||
""" Disp[ay Difference for History """
|
||||
@ -47,7 +47,9 @@ class showdiff(osv.osv_memory):
|
||||
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!'))
|
||||
raise osv.except_osv(_('Warning!'), _('You need to select minimum \
|
||||
one or maximum two history \
|
||||
revisions!'))
|
||||
return diff
|
||||
|
||||
_columns = {
|
||||
|
@ -19,9 +19,10 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from osv import osv
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class wiki_make_index(osv.osv_memory):
|
||||
""" Create Index For Selected Page """
|
||||
|
||||
@ -39,17 +40,18 @@ class wiki_make_index(osv.osv_memory):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = context and context.get('active_ids', []) or []
|
||||
|
||||
|
||||
if not data:
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
for index_obj in self.browse(cr, uid, ids, context=context):
|
||||
wiki_pool = self.pool.get('wiki.wiki')
|
||||
cr.execute("Select id, section from wiki_wiki where id IN %s \
|
||||
order by section ", (tuple(data),))
|
||||
lst0 = cr.fetchall()
|
||||
if not lst0[0][1]:
|
||||
raise osv.except_osv(_('Warning!'), _('There is no section in this Page.'))
|
||||
raise osv.except_osv(_('Warning!'), _('There is no section in\
|
||||
this Page.'))
|
||||
|
||||
lst = []
|
||||
s_ids = {}
|
||||
@ -60,6 +62,7 @@ class wiki_make_index(osv.osv_memory):
|
||||
|
||||
lst.sort()
|
||||
val = None
|
||||
|
||||
def toint(x):
|
||||
try:
|
||||
return int(x)
|
||||
@ -77,7 +80,8 @@ class wiki_make_index(osv.osv_memory):
|
||||
if pos >= len(current):
|
||||
current.append('1')
|
||||
continue
|
||||
if (pos == len(l) - 1) or (pos >= len(current2)) or (toint(l[pos]) > toint(current2[pos])):
|
||||
if (pos == len(l) - 1) or (pos >= len(current2)) or \
|
||||
(toint(l[pos]) > toint(current2[pos])):
|
||||
current[pos] = str(toint(current[pos]) + 1)
|
||||
current = current[:pos + 1]
|
||||
if pos == len(l) - 1:
|
||||
@ -91,7 +95,7 @@ class wiki_make_index(osv.osv_memory):
|
||||
current2 = l
|
||||
|
||||
for rs in result:
|
||||
wiki_pool.write(cr, uid, [rs[1]], {'section':rs[0]})
|
||||
wiki_pool.write(cr, uid, [rs[1]], {'section': rs[0]})
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
from osv import osv
|
||||
|
||||
|
||||
class wiki_wiki_page_open(osv.osv_memory):
|
||||
""" wizard Open Page """
|
||||
|
||||
@ -38,7 +39,8 @@ class wiki_wiki_page_open(osv.osv_memory):
|
||||
if context is None:
|
||||
context = {}
|
||||
group_ids = context.get('active_ids', [])
|
||||
for group in self.pool.get('wiki.groups').browse(cr, uid, group_ids, context=context):
|
||||
for group in self.pool.get('wiki.groups').browse(cr, uid, group_ids,
|
||||
context=context):
|
||||
value = {
|
||||
'domain': "[('group_id','=',%d)]" % (group.id),
|
||||
'name': 'Wiki Page',
|
||||
@ -54,9 +56,12 @@ class wiki_wiki_page_open(osv.osv_memory):
|
||||
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.children')])
|
||||
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['domain'] = [('group_id', '=', group.id), ('parent_id', '=',
|
||||
False)]
|
||||
value['view_type'] = 'tree'
|
||||
|
||||
return value
|
||||
|
Loading…
Reference in New Issue
Block a user