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 + + +