Example #1
0
    def addInternalLinks(self, text):
        proxy = rpc.RPCProxy('wiki.wiki')

        def link(path):
            link = path.group().replace('[', '').replace('[', '').replace(
                ']', '').replace(']', '').split("|")
            name_to_search = link[0].strip()
            mids = proxy.search([('name', 'ilike', name_to_search)])
            link_str = ""
            if mids:
                if len(link) == 2:
                    link_str = "<a href='/openerp/form/view?model=wiki.wiki&amp;id=%s'>%s</a>" % (
                        mids[0], link[1])
                elif len(link) == 1:
                    link_str = "<a href='/openerp/form/view?model=wiki.wiki&amp;id=%s'>%s</a>" % (
                        mids[0], link[0])
            else:
                if len(link) == 2:
                    link_str = "<a href='%s'>%s</a>" % (link[0], link[1])
                elif len(link) == 1:
                    link_str = "<a href='/openerp/form/edit?model=wiki.wiki&amp;id=False'>%s</a>" % (
                        link[0])

            return link_str

        bits = _internalLinks.sub(link, text)
        return bits
Example #2
0
 def image(path):
     file = path.group().replace('img:', '')
     if file.startswith('http') or file.startswith('ftp'):
         return "<img src='%s'/>" % (file)
     else:
         proxy = rpc.RPCProxy('ir.attachment')
         ids = proxy.search([('datas_fname', '=', file.strip()),
                             ('res_model', '=', 'wiki.wiki'),
                             ('res_id', '=', id)])
         if len(ids) > 0:
             return "<img src='/widget_wiki/wiki/getImage?file=%s&amp;id=%d'/>" % (
                 file, id)
         else:
             return """<a onclick="openobject.tools.openWindow(openobject.http.getURL('/openerp/attachment', {model: 'wiki.wiki', id: %d}),
             {name : 'Wiki Attachments'})">Attach : %s </a>""" % (id,
                                                                  file)
Example #3
0
    def set_value(self, value):
        super(WikiWidget, self).set_value(value)

        if value:
            toc = True
            id = False
            if hasattr(cherrypy.request, 'terp_record'):
                params = cherrypy.request.terp_params
                if params._terp_model == 'wiki.wiki':
                    proxy = rpc.RPCProxy('wiki.wiki')
                    toc = proxy.read([params.id], ['toc'])[0]['toc']
                    id = params.id

            text = value + '\n\n'
            html = wiki2html(text, toc, id)

            self.data = html
Example #4
0
 def record(path):
     record = path.group().replace('view:', '').split("|")
     model = record[0]
     text = record[1].replace('\r', '').strip()
     label = "View Record"
     if len(record) > 2:
         label = record[2]
     proxy = rpc.RPCProxy(model)
     ids = proxy.name_search(text, [], 'ilike', {})
     if len(ids):
         id = ids[0][0]
     else:
         try:
             id = int(text)
         except:
             id = 0
     return "[[/openerp/form/view?model=%s&amp;id=%d | %s]]" % (
         model, id, label)