~openerp-dev/openobject-client-web/6.0-opw-598313-msh

« back to all changes in this revision

Viewing changes to addons/form_logger/editors.py

  • Committer: Xavier Morel
  • Date: 2010-10-25 12:48:08 UTC
  • Revision ID: xmo@openerp.com-20101025124808-lnll3uej741rzppt
[REM] old addons example (overriding of templates) as we now have actual server addons with template overriding

or an actual server addon, more precisely

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
 
3
 
 
4
 
import openobject.templating
5
 
 
6
 
class FormEditor(openobject.templating.TemplateEditor):
7
 
    templates = ['/openerp/widgets/templates/sidebar.mako']
8
 
    SIDEBAR_START = u'<div id="sidebar">'
9
 
 
10
 
    def edit(self, template, template_text):
11
 
        output = super(FormEditor, self).edit(template, template_text)
12
 
 
13
 
        insertion_point = output.index(self.SIDEBAR_START) + len(self.SIDEBAR_START)
14
 
        return output[:insertion_point] + '''
15
 
            % if view_type == 'form':
16
 
                <div class="sideheader-a">
17
 
                    <h2>Piratepad</h2></div>
18
 
                <ul class="clean-a">
19
 
                    % if piratepad:
20
 
                        <li><a href="http://piratepad.net/${piratepad['pad']}" target="_blank">${piratepad['name']}</a></li>
21
 
                    % else:
22
 
                        <li><a href="#" id="add-piratepad" class="button-a">${_("Add")}</a></li>
23
 
                    % endif
24
 
                </ul>
25
 
            % endif
26
 
        ''' + output[insertion_point:]