From 988ad9ccc978bfd6f2aee0f17728ad38f16b1a6c Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Wed, 10 Nov 2010 12:48:32 +0530 Subject: [PATCH 01/11] [IMP] Share web addon. bzr revid: vda@tinyerp.com-20101110071832-ftzgmrd3trsz0icr --- addons/share/__openerp__.py | 2 ++ addons/share/web/__init__.py | 2 ++ addons/share/web/controllers.py | 37 +++++++++++++++++++++++++++ addons/share/web/editors.py | 44 +++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 addons/share/web/__init__.py create mode 100644 addons/share/web/controllers.py create mode 100644 addons/share/web/editors.py diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 21b63fd3bc1..393afb9717b 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -48,6 +48,8 @@ 'wizard/share_wizard_view.xml' ], 'installable': True, + 'active': False, + 'web': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/share/web/__init__.py b/addons/share/web/__init__.py new file mode 100644 index 00000000000..f95bb222c10 --- /dev/null +++ b/addons/share/web/__init__.py @@ -0,0 +1,2 @@ +import controllers +import editors \ No newline at end of file diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py new file mode 100644 index 00000000000..c658a3eede5 --- /dev/null +++ b/addons/share/web/controllers.py @@ -0,0 +1,37 @@ +import urlparse + +import cherrypy + +from openobject.tools import expose, ast +import openerp.controllers +from openerp.controllers import actions +from openerp.utils import rpc, TinyDict + +class Piratepad(openerp.controllers.SecuredController): + _cp_path = "/share" + + @expose() + def index(self, **kw): + domain = ast.literal_eval(kw['domain']) + search_domain = ast.literal_eval(kw['search_domain']) + filter_domain = ast.literal_eval(kw['filter_domain']) + + context = ast.literal_eval(kw['context']) + view_name = context.get('_terp_view_name') + + domain.extend(search_domain) + + action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) + if action_id: + action_id = action_id[0] + + model = 'share.wizard' + proxy = rpc.RPCProxy(model) + + share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) + context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard'}) + data = {'domain': str(domain), 'action_id':action_id} + id = proxy.create(data, context) + res = rpc.session.execute('object', 'execute', model, 'go_step_1', [id], context) + return actions.execute(res, ids=[id]) + diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py new file mode 100644 index 00000000000..b55afbf0896 --- /dev/null +++ b/addons/share/web/editors.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import openobject.templating + +class SidebarTemplateEditor(openobject.templating.TemplateEditor): + templates = ['/openerp/widgets/templates/sidebar.mako'] + ADD_SHARE_BUTTON = u'id="sidebar"' + + def insert_share_link(self, output): + # Insert the link on the line right after the link to open the + # attachment form + form_opener_insertion = output.index( + '\n', + output.index(self.ADD_SHARE_BUTTON)) + 1 + output = output[:form_opener_insertion] + \ + '''

${_("Share View")}

+ + + \n''' + \ + output[form_opener_insertion:] + return output + + def edit(self, template, template_text): + output = super(SidebarTemplateEditor, self).edit(template, template_text) + + output = self.insert_share_link(output) + return output \ No newline at end of file From 15f8f81e0568ebbf3ab303f9c22e023a23b96ada Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Mon, 15 Nov 2010 16:07:06 +0530 Subject: [PATCH 02/11] [FIX] Improved share action method,share url and passed active db in email. bzr revid: vda@tinyerp.com-20101115103706-vhkrxbnrw73sljmr --- addons/share/__openerp__.py | 1 - addons/share/web/controllers.py | 50 +++++++++++++---------------- addons/share/web/editors.py | 16 ++++----- addons/share/wizard/share_wizard.py | 1 + 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 393afb9717b..768d24974a5 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -48,7 +48,6 @@ 'wizard/share_wizard_view.xml' ], 'installable': True, - 'active': False, 'web': True, } diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py index c658a3eede5..18ed74a2d5e 100644 --- a/addons/share/web/controllers.py +++ b/addons/share/web/controllers.py @@ -1,37 +1,33 @@ -import urlparse +from openobject.tools import expose, ast +from openerp.controllers import actions +from openerp.utils import rpc +import openerp.controllers import cherrypy -from openobject.tools import expose, ast -import openerp.controllers -from openerp.controllers import actions -from openerp.utils import rpc, TinyDict + class Piratepad(openerp.controllers.SecuredController): _cp_path = "/share" @expose() - def index(self, **kw): - domain = ast.literal_eval(kw['domain']) - search_domain = ast.literal_eval(kw['search_domain']) - filter_domain = ast.literal_eval(kw['filter_domain']) - - context = ast.literal_eval(kw['context']) - view_name = context.get('_terp_view_name') - + def index(self, domain, search_domain, context, name): + domain = ast.literal_eval(domain) + search_domain = ast.literal_eval(search_domain) domain.extend(search_domain) - action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) - if action_id: - action_id = action_id[0] - - model = 'share.wizard' - proxy = rpc.RPCProxy(model) - - share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) - context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard'}) - data = {'domain': str(domain), 'action_id':action_id} - id = proxy.create(data, context) - res = rpc.session.execute('object', 'execute', model, 'go_step_1', [id], context) - return actions.execute(res, ids=[id]) - + context = ast.literal_eval(context) + view_name = context.get('_terp_view_name') or name + if view_name: + action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) + if action_id: + action_id = action_id[0] + share_model = 'share.wizard' + share_root_url = cherrypy.config.get('server.socket_host') + ':' + str(cherrypy.config.get('server.socket_port')) + + share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) + context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard', 'share_root_url': share_root_url}) + sharing_view_id = rpc.RPCProxy(share_model).create({'domain': str(domain), 'action_id':action_id}, context) + + return actions.execute(rpc.session.execute('object', 'execute', share_model, 'go_step_1', [sharing_view_id], context), ids=[sharing_view_id], context=context) + diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py index b55afbf0896..fadbe50ff72 100644 --- a/addons/share/web/editors.py +++ b/addons/share/web/editors.py @@ -12,24 +12,20 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): '\n', output.index(self.ADD_SHARE_BUTTON)) + 1 output = output[:form_opener_insertion] + \ - '''

${_("Share View")}

+ '''

${_("Sharing")}

@@ -41,4 +37,4 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): output = super(SidebarTemplateEditor, self).edit(template, template_text) output = self.insert_share_link(output) - return output \ No newline at end of file + return output diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 9349980933f..4943f6a6e10 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -427,6 +427,7 @@ class share_create(osv.osv_memory): body += _("You may use the following login and password to get access to this protected area:") + "\n" body += "%s: %s" % (_("Username"), result_line.login) + "\n" body += "%s: %s" % (_("Password"), result_line.password) + "\n" + body += "%s: %s" % (_("Database"), cr.dbname) + "\n" else: body += _("This additional data has been automatically added to your current access.\n") body += _("You may use your existing login and password to view it. As a reminder, your login is %s.\n") % result_line.login From 4342ea125216e9fe563a95715db3a629e5c06e2d Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Sat, 20 Nov 2010 12:30:51 +0530 Subject: [PATCH 03/11] [FIX] Fixed share action according to framework,share_root_url. bzr revid: vda@tinyerp.com-20101120070051-vnlh1dp99shaxpoa --- addons/share/web/controllers.py | 4 +--- addons/share/web/editors.py | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py index 18ed74a2d5e..c37af991b25 100644 --- a/addons/share/web/controllers.py +++ b/addons/share/web/controllers.py @@ -15,7 +15,6 @@ class Piratepad(openerp.controllers.SecuredController): domain = ast.literal_eval(domain) search_domain = ast.literal_eval(search_domain) domain.extend(search_domain) - context = ast.literal_eval(context) view_name = context.get('_terp_view_name') or name if view_name: @@ -23,11 +22,10 @@ class Piratepad(openerp.controllers.SecuredController): if action_id: action_id = action_id[0] share_model = 'share.wizard' - share_root_url = cherrypy.config.get('server.socket_host') + ':' + str(cherrypy.config.get('server.socket_port')) + share_root_url = cherrypy.request.base share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard', 'share_root_url': share_root_url}) sharing_view_id = rpc.RPCProxy(share_model).create({'domain': str(domain), 'action_id':action_id}, context) - return actions.execute(rpc.session.execute('object', 'execute', share_model, 'go_step_1', [sharing_view_id], context), ids=[sharing_view_id], context=context) diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py index fadbe50ff72..9059e841034 100644 --- a/addons/share/web/editors.py +++ b/addons/share/web/editors.py @@ -20,12 +20,13 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): From 6f3ef38b8832d8ccb1d6a0cf03a36e2f952a8085 Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Mon, 22 Nov 2010 12:08:23 +0530 Subject: [PATCH 04/11] [FIX] Fixed share root url with direct access of user. bzr revid: vda@tinyerp.com-20101122063823-suc6cj5k8cu7y7ac --- addons/share/wizard/share_wizard.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 4943f6a6e10..bce94c1dc3e 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -99,12 +99,16 @@ class share_create(osv.osv_memory): for new_user in wizard_data.new_users.split('\n'): # attempt to show more user-friendly msg than default constraint error existing = user_obj.search(cr, 1, [('login', '=', new_user)]) + password = generate_random_pass() + if wizard_data.share_root_url: + wizard_data.share_root_url = wizard_data.share_root_url + '/openerp/login?db=%s'%(cr.dbname) + '&user=%s'%(new_user) + '&password=%s'%(password) + self.write(cr, 1, [uid], {'share_root_url': wizard_data.share_root_url}) if existing: raise osv.except_osv(_('User already exists'), _('This username (%s) already exists, perhaps data has already been shared with this person.\nYou may want to try selecting existing shared users instead.')) user_id = user_obj.create(cr, 1, { 'login': new_user, - 'password': generate_random_pass(), + 'password': password, 'name': new_user, 'user_email': new_user, 'groups_id': [(6,0,[group_id])], @@ -395,7 +399,6 @@ class share_create(osv.osv_memory): # C. all_relations = obj0 + obj1 + obj2 + obj3 self._link_or_copy_current_user_rules(cr, uid, group_id, all_relations, context=context) - # so far, so good -> populate summary results and return them self._create_result_lines(cr, uid, wizard_data, context=context) From d452c65969688234760affac1d87cac3857206db Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 22 Nov 2010 12:44:29 +0100 Subject: [PATCH 05/11] [REV] alterations to server side of share wizard bzr revid: xmo@openerp.com-20101122114429-cmi5h10t5iwv9x0l --- addons/share/wizard/share_wizard.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index bce94c1dc3e..152bc55969b 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -99,16 +99,12 @@ class share_create(osv.osv_memory): for new_user in wizard_data.new_users.split('\n'): # attempt to show more user-friendly msg than default constraint error existing = user_obj.search(cr, 1, [('login', '=', new_user)]) - password = generate_random_pass() - if wizard_data.share_root_url: - wizard_data.share_root_url = wizard_data.share_root_url + '/openerp/login?db=%s'%(cr.dbname) + '&user=%s'%(new_user) + '&password=%s'%(password) - self.write(cr, 1, [uid], {'share_root_url': wizard_data.share_root_url}) if existing: raise osv.except_osv(_('User already exists'), _('This username (%s) already exists, perhaps data has already been shared with this person.\nYou may want to try selecting existing shared users instead.')) user_id = user_obj.create(cr, 1, { 'login': new_user, - 'password': password, + 'password': generate_random_pass(), 'name': new_user, 'user_email': new_user, 'groups_id': [(6,0,[group_id])], From c2aedebfcb7be64cc9de0f87c8879cef5321c702 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 22 Nov 2010 12:47:55 +0100 Subject: [PATCH 06/11] [IMP] cleanup JS share button/link bzr revid: xmo@openerp.com-20101122114755-00wuiehftfx3mm5t --- addons/share/web/editors.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py index 9059e841034..c628969ec8d 100644 --- a/addons/share/web/editors.py +++ b/addons/share/web/editors.py @@ -20,13 +20,15 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): From 11d5607f05a0ec673d6a41b6e9cb82995478a682 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 22 Nov 2010 13:12:27 +0100 Subject: [PATCH 07/11] [FIX] share: naming of classes in web module bzr revid: xmo@openerp.com-20101122121227-bjx7fi4r3ospdml1 --- addons/share/web/controllers.py | 2 +- addons/share/web/editors.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py index c37af991b25..4a9b5f69cb7 100644 --- a/addons/share/web/controllers.py +++ b/addons/share/web/controllers.py @@ -7,7 +7,7 @@ import cherrypy -class Piratepad(openerp.controllers.SecuredController): +class ShareWizardController(openerp.controllers.SecuredController): _cp_path = "/share" @expose() diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py index c628969ec8d..06591ef36f6 100644 --- a/addons/share/web/editors.py +++ b/addons/share/web/editors.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import openobject.templating -class SidebarTemplateEditor(openobject.templating.TemplateEditor): +class ShareActionEditor(openobject.templating.TemplateEditor): templates = ['/openerp/widgets/templates/sidebar.mako'] ADD_SHARE_BUTTON = u'id="sidebar"' @@ -20,14 +20,14 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor):