diff --git a/addons/pad/LICENSE b/addons/pad/LICENSE deleted file mode 100644 index ff64be448e9..00000000000 --- a/addons/pad/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -OpenERP, Open Source Management Solution -Copyright © 2010-2011 OpenERP SA (). - -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 . diff --git a/addons/pad/__init__.py b/addons/pad/__init__.py index 663cac2cbf0..ee80bcaf8d0 100644 --- a/addons/pad/__init__.py +++ b/addons/pad/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import pad import res_company -import ir_attachment + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/pad/__openerp__.py b/addons/pad/__openerp__.py index 267f595c7e5..bc4159089d7 100644 --- a/addons/pad/__openerp__.py +++ b/addons/pad/__openerp__.py @@ -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: diff --git a/addons/pad/ir_attachment.py b/addons/pad/ir_attachment.py deleted file mode 100644 index ba8c88632dd..00000000000 --- a/addons/pad/ir_attachment.py +++ /dev/null @@ -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: diff --git a/addons/pad/pad.py b/addons/pad/pad.py new file mode 100644 index 00000000000..40569fcd589 --- /dev/null +++ b/addons/pad/pad.py @@ -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: diff --git a/addons/pad/res_company.py b/addons/pad/res_company.py index 0c1dc7c4929..bd955cd0481 100644 --- a/addons/pad/res_company.py +++ b/addons/pad/res_company.py @@ -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, } diff --git a/addons/pad/res_company.xml b/addons/pad/res_company.xml index 9b1c0656470..12f14b0f5bd 100644 --- a/addons/pad/res_company.xml +++ b/addons/pad/res_company.xml @@ -8,7 +8,7 @@ - + diff --git a/addons/pad/static/src/css/etherpad.css b/addons/pad/static/src/css/etherpad.css new file mode 100644 index 00000000000..a0240afcab7 --- /dev/null +++ b/addons/pad/static/src/css/etherpad.css @@ -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; } diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 2e5f8820ac4..6384eb72da8 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -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 = ''; + this.$element.find('div.oe_etherpad_default').html(code); + } else { + $.get(url+'/export/html').success(function(data) { + self.$element.html('
'+data+'
'); + }).error(function() { + self.$element.text('Unable to load pad'); + }); + } + } + }, +}); + +instance.web.form.widgets = instance.web.form.widgets.extend({ + 'pad': 'instance.web.form.FieldPad', }); }; diff --git a/addons/pad/static/src/xml/pad.xml b/addons/pad/static/src/xml/pad.xml index e922294d03d..e128fb183fb 100644 --- a/addons/pad/static/src/xml/pad.xml +++ b/addons/pad/static/src/xml/pad.xml @@ -2,4 +2,17 @@ + + + +
+
+ Fullscreen + Return to Record +
+
+
+
+
+
diff --git a/addons/pad_project/__init__.py b/addons/pad_project/__init__.py index d6bf9f9551c..098de31a5a4 100644 --- a/addons/pad_project/__init__.py +++ b/addons/pad_project/__init__.py @@ -19,6 +19,6 @@ # ############################################################################## -import models +import project_task # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/pad_project/__openerp__.py b/addons/pad_project/__openerp__.py index 8ca761d2737..18c7d3191d3 100644 --- a/addons/pad_project/__openerp__.py +++ b/addons/pad_project/__openerp__.py @@ -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: diff --git a/addons/pad_project/models/__init__.py b/addons/pad_project/models/__init__.py deleted file mode 100644 index 098de31a5a4..00000000000 --- a/addons/pad_project/models/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# 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 . -# -############################################################################## - -import project_task - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/pad_project/models/project_task.py b/addons/pad_project/models/project_task.py deleted file mode 100644 index c215aed1325..00000000000 --- a/addons/pad_project/models/project_task.py +++ /dev/null @@ -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: diff --git a/addons/pad_project/models/project_task.xml b/addons/pad_project/models/project_task.xml deleted file mode 100644 index 3c734cf3b97..00000000000 --- a/addons/pad_project/models/project_task.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - project.task.kanban.pad - project.task - kanban - - - - PAD - - - - - diff --git a/addons/pad_project/project_task.py b/addons/pad_project/project_task.py new file mode 100644 index 00000000000..46c2c54cd46 --- /dev/null +++ b/addons/pad_project/project_task.py @@ -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), + } diff --git a/addons/pad_project/project_task.xml b/addons/pad_project/project_task.xml new file mode 100644 index 00000000000..d18f43a92f4 --- /dev/null +++ b/addons/pad_project/project_task.xml @@ -0,0 +1,15 @@ + + + + project.task.form.pad + project.task + form + + + + + + + + +