[FIX] document_page wiki

bzr revid: al@openerp.com-20120909104340-z4c85dcq6s11v83y
This commit is contained in:
Antony Lesuisse 2012-09-09 12:43:40 +02:00
parent bc619a3e53
commit f2ddf0ea65
4 changed files with 28 additions and 25 deletions

View File

@ -29,11 +29,13 @@ class document_page(osv.osv):
_description = "Document Page"
_order = 'name'
def _get_page_index(self, cr, uid, page):
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>"]
r = '<a href="#id=%s">%s</a>'%(page.id,page.name)
r = ''
if link:
r = '<a href="#id=%s">%s</a>'%(page.id,page.name)
if index:
r += "<ul>" + "".join(index) + "</ul>"
return r
@ -42,7 +44,7 @@ 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)
content = self._get_page_index(cr, uid, page, link=False)
else:
content = page.content
res[page.id] = content
@ -120,12 +122,12 @@ class document_page_history(osv.osv):
text2 = history_pool.read(cr, uid, [v2], ['content'])[0]['content']
line1 = line2 = ''
if text1:
line1 = tools.ustr(text1.splitlines(1))
line1 = text1.splitlines(1)
if text2:
line2=tools.ustr(text2.splitlines(1))
line2 = 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()
return diff.make_file(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=False)
return diff.make_table(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=True)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -78,17 +78,6 @@
</field>
</record>
<!-- page action -->
<record id="action_category" model="ir.actions.act_window">
<field name="name">Category</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','category')]</field>
<field name="context">{'default_type': 'category'}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_wiki_tree"/>
<field name="search_view_id" ref="view_wiki_filter"/>
</record>
<menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_category" sequence="10"/>
<record id="action_page" model="ir.actions.act_window">
<field name="name">Pages</field>
<field name="res_model">document.page</field>
@ -100,7 +89,18 @@
<field name="search_view_id" ref="view_wiki_filter"/>
<field name="help">Create web pages</field>
</record>
<menuitem id="menu_page" parent="menu_wiki" name="Pages" action="action_page" sequence="20"/>
<menuitem id="menu_page" parent="menu_wiki" name="Pages" action="action_page" sequence="10"/>
<record id="action_category" model="ir.actions.act_window">
<field name="name">Category</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','category')]</field>
<field name="context">{'default_type': 'category'}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_wiki_tree"/>
<field name="search_view_id" ref="view_wiki_filter"/>
</record>
<menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_category" sequence="20"/>
<!-- History Tree view -->
<record model="ir.ui.view" id="view_wiki_history_tree">

View File

@ -1,11 +1,12 @@
.oe_document_page ul, .oe_document_page li {
padding: 2px 8px;
margin: 2px 8px;
list-style-type: circle;
}
.oe_form_editable .oe_document_page {
display: none;
}
table.diff {font-family:Courier; border:medium;}
.diff_header {background-color:#e0e0e0}
td.diff_header {text-align:right}
.diff_next {background-color:#c0c0c0}
.diff_add {background-color:#aaffaa}
.diff_chg {background-color:#ffff77}
.diff_sub {background-color:#ffaaaa}

View File

@ -8,7 +8,7 @@
<field name="model">wizard.document.page.history.show_diff</field>
<field name="arch" type="xml">
<form string="Difference" version="7.0">
<field name="diff"/>
<field name="diff" widget="html"/>
<footer>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>