[MERGE] etherpad
bzr revid: al@openerp.com-20120721195900-04o3e4oibe5pt9m1
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
OpenERP, Open Source Management Solution
|
||||
Copyright © 2010-2011 OpenERP SA (<http://openerp.com>).
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public Lice
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pad
|
||||
import res_company
|
||||
import ir_attachment
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -25,6 +25,7 @@ Lets the company customize which Pad installation should be used to link to new
|
||||
"static/src/xml/*.xml",
|
||||
],
|
||||
'images': ['static/src/img/pad_link_companies.jpeg'],
|
||||
"css": ['static/src/css/etherpad.css',],
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from osv import fields, osv
|
||||
import random
|
||||
import string
|
||||
|
||||
class ir_attachment(osv.osv):
|
||||
_inherit = 'ir.attachment'
|
||||
|
||||
def pad_generate_url(self, cr, uid, model, id):
|
||||
pad_url_template = self.pool.get('res.users').browse(cr,uid,[uid])[0].company_id.pad_url_template
|
||||
s = string.ascii_uppercase + string.digits
|
||||
salt = ''.join([s[random.randint(0, len(s) - 1)] for i in range(8)])
|
||||
template_vars = {
|
||||
'db' : cr.dbname,
|
||||
'model' : model,
|
||||
'id' : id,
|
||||
'salt' : salt,
|
||||
'name' : '',
|
||||
}
|
||||
return pad_url_template % template_vars
|
||||
|
||||
def pad_get(self, cr, uid, model, id):
|
||||
attachment = self.search(cr, uid, [('res_model', '=', model), ('res_id', '=', id), ('type', '=', 'url'), ('name', '=', 'Pad')])
|
||||
if attachment:
|
||||
return self.read(cr, uid, attachment)[0]['url']
|
||||
else:
|
||||
url = self.pad_generate_url(cr, uid, model, id)
|
||||
self.create(cr, uid, {
|
||||
'res_model' : model,
|
||||
'res_id' : id,
|
||||
'type' : 'url',
|
||||
'name' : 'Pad',
|
||||
'url' : url,
|
||||
})
|
||||
return url
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from osv import fields, osv
|
||||
import random
|
||||
import string
|
||||
import urllib2
|
||||
from tools.translate import _
|
||||
|
||||
class pad_common(osv.osv_memory):
|
||||
_name = 'pad.common'
|
||||
_pad_fields = []
|
||||
def pad_generate_url(self, cr, uid, context=None):
|
||||
pad_url_template = self.pool.get('res.users').browse(cr,uid, uid, context).company_id.pad_url_template
|
||||
s = string.ascii_uppercase + string.digits
|
||||
salt = ''.join([s[random.randint(0, len(s) - 1)] for i in range(8)])
|
||||
template_vars = {
|
||||
'db' : cr.dbname,
|
||||
'model' : self._name,
|
||||
'salt' : salt,
|
||||
}
|
||||
url = pad_url_template % template_vars
|
||||
return url
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if not default:
|
||||
default = {}
|
||||
update = [(field,self.pad_generate_url(cr, uid, context)) for field in self._pad_fields]
|
||||
default.update(update)
|
||||
return super(pad_common, self).copy(cr, uid, id, default, context)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,14 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from osv import fields, osv
|
||||
|
||||
DEFAULT_PAD_TEMPLATE = 'http://beta.etherpad.org/p/%(db)s-%(model)s-%(salt)s'
|
||||
|
||||
class company_pad(osv.osv):
|
||||
_inherit = 'res.company'
|
||||
_columns = {
|
||||
'pad_url_template': fields.char('Pad URL Template', size=128, required=True,
|
||||
help="Template used to generate pad URL."),
|
||||
'pad_url_template': fields.char('Pad URL Template', size=128, required=True, help="Template used to generate pad URL."),
|
||||
}
|
||||
_defaults = {
|
||||
'pad_url_template': 'http://ietherpad.com/%(db)s-%(model)s-%(id)d-%(salt)s-%(name)s'
|
||||
'pad_url_template': DEFAULT_PAD_TEMPLATE,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='account_grp']" position="after">
|
||||
<group string="Pads">
|
||||
<field name="pad_url_template"/>
|
||||
<field name="pad_url_template" placeholder="e.g. http://beta.etherpad.org/p/%%(db)s-%%(model)s-%%(salt)s"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
.oe_etherpad_head{
|
||||
width: 100%;
|
||||
display: block;
|
||||
padding-left:3px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.oe_etherpad_fullscreen div.oe_etherpad_head .oe_normal {
|
||||
display: none;
|
||||
}
|
||||
.oe_etherpad_normal div.oe_etherpad_head .oe_fullscreen {
|
||||
display: none;
|
||||
}
|
||||
.oe_etherpad_fullscreen {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
z-index:10001 !important;
|
||||
}
|
||||
.etherpad_default{
|
||||
width: 100%;
|
||||
height: 450px;
|
||||
}
|
||||
.oe_etherpad_fullscreen .etherpad_default{
|
||||
height: 100%
|
||||
}
|
||||
|
||||
.etherpad_body{
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.etherpad_readonly{
|
||||
width: 100%;
|
||||
height: 450px;
|
||||
overflow:auto;
|
||||
}
|
||||
.etherpad_readonly ul,.etherpad_readonly ol{
|
||||
-webkit-margin-before: 1em;
|
||||
-webkit-margin-after: 1em;
|
||||
-webkit-margin-start: 0px;
|
||||
-webkit-margin-end: 0px;
|
||||
-webkit-padding-start: 40px !important;
|
||||
}
|
||||
.etherpad_readonly ul li{
|
||||
list-style-type: disc;
|
||||
}
|
||||
.etherpad_readonly ol li{
|
||||
list-style-type: decimal;
|
||||
}
|
||||
.etherpad_readonly .indent li{
|
||||
list-style-type: none !important;
|
||||
}
|
||||
|
||||
.etherpad_readonly{
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 17px;
|
||||
}
|
||||
|
||||
.etherpad_readonly ul.indent { list-style-type: none !important; }
|
||||
.etherpad_readonly ol li{ list-style-type: decimal !important; }
|
||||
.etherpad_readonly ol ol li{ list-style-type: lower-latin !important; }
|
||||
.etherpad_readonly ol ol ol li{ list-style-type: lower-roman !important; }
|
||||
.etherpad_readonly ol ol ol ol li{ list-style-type: decimal !important; }
|
||||
.etherpad_readonly ol ol ol ol ol li{ list-style-type: lower-latin !important; }
|
||||
.etherpad_readonly ol ol ol ol ol ol li{ list-style-type: lower-roman !important; }
|
||||
.etherpad_readonly ol ol ol ol ol ol ol li{ list-style-type: decimal !important; }
|
||||
.etherpad_readonly ol ol ol ol ol ol ol ol li{ list-style-type: lower-latin !important; }
|
||||
@@ -1,18 +1,40 @@
|
||||
openerp.pad = function(instance) {
|
||||
|
||||
instance.web.Sidebar = instance.web.Sidebar.extend({
|
||||
init: function(parent) {
|
||||
this._super(parent);
|
||||
this.add_items('other',[{ label: "Pad", callback: this.on_add_pad }]);
|
||||
},
|
||||
on_add_pad: function() {
|
||||
instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
||||
template: 'FieldPad',
|
||||
initialize_content: function() {
|
||||
var self = this;
|
||||
var view = this.getParent();
|
||||
var model = new instance.web.Model('ir.attachment');
|
||||
model.call('pad_get', [view.model ,view.datarecord.id],{}).then(function(r) {
|
||||
self.do_action({ type: "ir.actions.act_url", url: r });
|
||||
this.$textarea = undefined;
|
||||
this.$element.find('div.oe_etherpad_head').click(function(ev) {
|
||||
self.$element.toggleClass('oe_etherpad_fullscreen').toggleClass('oe_etherpad_normal');
|
||||
});
|
||||
}
|
||||
},
|
||||
set_value: function(value_) {
|
||||
this._super(value_);
|
||||
this.render_value();
|
||||
},
|
||||
render_value: function() {
|
||||
var self = this;
|
||||
var value = this.get('value');
|
||||
if(value !== false) {
|
||||
var url = value.split('\n')[0];
|
||||
if (!this.get("effective_readonly")) {
|
||||
var pad_username = this.session.username;
|
||||
var code = '<iframe width="100%" height="100%" frameborder="0" src="'+url+'?showChat=false&userName='+pad_username+'"></iframe>';
|
||||
this.$element.find('div.oe_etherpad_default').html(code);
|
||||
} else {
|
||||
$.get(url+'/export/html').success(function(data) {
|
||||
self.$element.html('<div class="etherpad_readonly">'+data+'</div>');
|
||||
}).error(function() {
|
||||
self.$element.text('Unable to load pad');
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
instance.web.form.widgets = instance.web.form.widgets.extend({
|
||||
'pad': 'instance.web.form.FieldPad',
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -2,4 +2,17 @@
|
||||
<!-- vim:fdl=1:
|
||||
-->
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="FieldPad">
|
||||
<t t-if="!widget.get('effective_readonly')">
|
||||
<div class="oe_form_field_text oe_etherpad_normal">
|
||||
<div class="oe_etherpad_head">
|
||||
<span class="oe_normal">Fullscreen</span>
|
||||
<span class="oe_fullscreen">Return to Record</span>
|
||||
</div>
|
||||
<div class="oe_etherpad_default" ></div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import models
|
||||
import project_task
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Specifications on PADs',
|
||||
'name': 'Pad on tasks',
|
||||
'version': '1.0',
|
||||
"category": "Project Management",
|
||||
'description': """
|
||||
@@ -31,9 +31,9 @@ This module adds a PAD in all project kanban views
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['project', 'pad'],
|
||||
'init_xml': [],
|
||||
'update_xml': ['models/project_task.xml'],
|
||||
'update_xml': ['project_task.xml'],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'auto_install': True,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import project_task
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,17 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from tools.translate import _
|
||||
from osv import fields, osv
|
||||
|
||||
class task(osv.osv):
|
||||
_inherit = "project.task"
|
||||
|
||||
def pad_get(self, cr, uid, ids, context=None):
|
||||
"""Get pad action
|
||||
"""
|
||||
url = self.pool.get("ir.attachment").pad_get(cr, uid, self._name, ids[0])
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': url
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,15 +0,0 @@
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_task_kanban_with_pad" model="ir.ui.view">
|
||||
<field name="name">project.task.kanban.pad</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="type">kanban</field>
|
||||
<field name="inherit_id" ref="project.view_task_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//span[@class='oe_kanban_project_times']" position="before">
|
||||
<a name="pad_get" string="Pad" type="object" class="oe_kanban_button" style="margin-left: 5px;"><b>PAD</b></a>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from tools.translate import _
|
||||
from osv import fields, osv
|
||||
|
||||
class task(osv.osv):
|
||||
_name = "project.task"
|
||||
_inherit = ["project.task",'pad.common']
|
||||
_pad_fields = ['description_pad']
|
||||
_columns = {
|
||||
'description_pad': fields.char('Description PAD', size=250)
|
||||
}
|
||||
_defaults = {
|
||||
'description_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context),
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_task_form_with_pad" model="ir.ui.view">
|
||||
<field name="name">project.task.form.pad</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="project.view_task_form2"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="description" position="replace">
|
||||
<field name="description_pad" attrs="{'readonly':[('state','=','done')]}" widget="pad"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user