improve the wiki module remove unused code

bzr revid: mga@tinyerp.com-20081121133648-igqir2svi9noyv16
This commit is contained in:
Mantavya Gajjar
2008-11-21 19:06:48 +05:30
parent 959d0130a2
commit 3a481e9a6a
3 changed files with 1 additions and 181 deletions
-1
View File
@@ -8,7 +8,6 @@
"demo_xml" : [],
"update_xml" : [
"wiki_view.xml",
"wiki_data.xml"
],
"active": False,
"installable": True
+1 -170
View File
@@ -115,173 +115,4 @@ class History(osv.osv):
diff = difflib.HtmlDiff()
return diff.make_file(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=False)
History()
class IndexLine(osv.osv):
_name="wiki.index.line"
_description="Index Lines"
_columns={
'name':fields.text('Content', select=True),
'active':fields.boolean('Active', select=True),
'model':fields.char('Resource',size=256, select=True),
'res_id':fields.integer('Resource Id', select=True),
}
_defaults = {
'active': lambda *a: True,
}
def __init__(self, cr , pool):
super(IndexLine, self).__init__(cr, pool)
def reIndex(self, cr, uid, ids, context={}):
password = self.pool.get('res.users').browse(cr, uid, uid).password
self.server.init(cr.dbname, uid, password, True)
self.server.open()
self.Index(cr, uid, context)
self.server.close()
return True
def Index(self, cr, uid, ids, context={}):
entry_pool = self.pool.get('wiki.index.line')
eids = entry_pool.search(cr, uid, [])
model_pool = self.pool.get('ir.model')
field_pool = self.pool.get('ir.model.fields')
ids = model_pool.search(cr, uid, [('model','!=','wiki.index.line')])
models = model_pool.read(cr, uid, ids, ['id', 'model'])
for mod in models:
res_ids = None
if str(mod['model']).startswith('workflow'):
continue
if str(mod['model']).startswith('ir'):
continue
if str(mod['model']).startswith('wiki.index.line'):
continue
if str(mod['model']).startswith('res.currency'):
continue
if str(mod['model']).startswith('wiki.wiki'):
continue
if str(mod['model']).startswith('report'):
continue
if str(mod['model']).startswith('account_analytic_analysis.summary.user'):
continue
if str(mod['model']).startswith('hr_timesheet_invoice.factor'):
continue
try:
fids = field_pool.search(cr, 1, [('model_id','=',mod['id'])])
fdata = field_pool.read(cr, uid, fids, ['name','relation', 'ttype'])
except Exception, e:
continue
res_pool = None
res_ids = None
res_pool = self.pool.get(mod['model'])
res_datas = None
try:
res_ids = res_pool.search(cr, 1, [])
res_datas = res_pool.read(cr, 1, res_ids)
except Exception, e:
print e
continue
print 'Indexing : ', mod['model'], ' Auto Status : '
if res_datas:
for res_data in res_datas:
exist_ids = entry_pool.search(cr, uid, [('res_id','=',res_data['id']),('model','=',mod['model'])])
if exist_ids.__len__() > 0:
continue
final_res = ''
final_res += ' '.join(map(str,res_data.values()))
entry_pool.create(cr, uid, {
'model':mod['model'],
'res_id':res_data['id'],
'name': final_res
})
cr.commit()
return True
def createIndex(self, cr, uid, ids, context={}):
return self.Index(cr, uid, ids, context)
def getResult(self, cr, uid, key, reSearch=True, context = {}):
if context and context.get('read_all') and key:
try:
ids = self.search(cr, uid, [('name','ilike',key)])
res = self.read(cr, uid, ids, ['model', 'res_id'])
except Exception, e:
raise osv.except_osv('Search Error !!', e.faultString)
trs = {}
for rs in res:
model = rs.get('model')
id = rs.get('res_id')
if trs.has_key(model):
olds = trs[model]
olds.append(id)
else:
trs[model] = [id]
res = trs
if res:
buffer = ''
for mod in res.keys():
sbuff = ''
obj_pool = self.pool.get(mod)
header = False
for id in res[mod]:
name = None
try:
name = obj_pool.name_get(cr, 1, [id])[0][1]
obj_pool.read(cr, uid, [id])
header = True
except Exception, e:
header = False
continue
rec_url = '/form/view?model=' + mod + "&id=" + str(id)
edit_url = '/form/edit?model=' + mod + "&id=" + str(id)
sbuff+= '#Row\n'
name = name.replace('/',' ')
name = name.replace('*',' ')
name = name.replace('_',' ')
sbuff+= '| # | ' + name + ' | [' + mod + '/' + str(id) + ' - Wiki]' + ' | [' + rec_url + ' - Browse ] | [' + edit_url + ' - Edit ]\n'
if header == True:
mid = self.pool.get('ir.model').search(cr, uid, [('model','=',mod)])[0]
mod_data = self.pool.get('ir.model').browse(cr, uid, mid).name
sbuff = '\n==' + mod_data + '==\n' + sbuff
buffer += sbuff
html = self.pool.get('wiki.wiki').Wiki2Html(buffer)
html = html.replace('$s', '<strike>')
html = html.replace('$es', '</strike>')
return [{'html':html}]
return None
IndexLine()
History()
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<terp>
<data>
<record model="wiki.wiki" id="base_wiki_home">
<field name="name">Wiki Home</field>
<field name="minor_edit">False</field>
<field name="summary"></field>
</record>
</data>
</terp>