From 9b6ef516217f869a2f38372c64ee769b1be12c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Messiant?= Date: Wed, 9 Oct 2013 14:17:39 +0200 Subject: [PATCH] Add 'Create Contact' link on position view --- .../contact/core/browser/addcontact.py | 12 +++++++++ .../contact/core/browser/configure.zcml | 7 +++++ .../contact/core/browser/position.py | 26 +++++++++++++++++++ .../core/browser/templates/position.pt | 10 +++++++ 4 files changed, 55 insertions(+) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 712f6d9..b19049e 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -318,6 +318,18 @@ class AddContactFromOrganization(AddContact): super(AddContactFromOrganization, self).updateWidgets() +class AddContactFromPosition(AddContact): + def updateWidgets(self): + organization = self.context.get_organization() + if 'oform.widgets.organization' not in self.request.form: + self.request.form['oform.widgets.organization'] = '/'.join( + organization.getPhysicalPath()) + if 'oform.widgets.position' not in self.request.form: + self.request.form['oform.widgets.position'] = '/'.join( + self.context.getPhysicalPath()) + super(AddContactFromPosition, self).updateWidgets() + + class AddOrganization(form.AddForm): implements(IFieldsAndContentProvidersForm) contentProviders = ContentProviders(['organization-ms']) diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 8dab026..22ee4ca 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -79,6 +79,13 @@ permission="cmf.AddPortalContent" /> + + +$(document).ready(function(){ + $('.addnewcontactfromposition').prepOverlay({ + subtype: 'ajax', + filter: common_content_filter, + formselector: '#oform', + cssclass: 'overlay-contact-addnew', + closeselector: '[name="oform.buttons.cancel"]', + noform: function(el, pbo) {return 'reload';}, + config: { + closeOnClick: false, + closeOnEsc: false + } + }); +}); + +""" + + class Position(BaseView): name = '' @@ -35,3 +57,7 @@ class Position(BaseView): # also show fields that were added TTW self.ttw_fields = get_ttw_fields(position) + + sm = getSecurityManager() + self.can_add = sm.checkPermission('Add portal content', self.context) + self.addnew_script = ADDNEW_OVERLAY diff --git a/src/collective/contact/core/browser/templates/position.pt b/src/collective/contact/core/browser/templates/position.pt index 64d977c..1d98260 100644 --- a/src/collective/contact/core/browser/templates/position.pt +++ b/src/collective/contact/core/browser/templates/position.pt @@ -64,6 +64,16 @@
+ + + Create Contact + + +