Add 'Create Contact' link on position view
This commit is contained in:
parent
481ad7443c
commit
9b6ef51621
|
@ -318,6 +318,18 @@ class AddContactFromOrganization(AddContact):
|
||||||
super(AddContactFromOrganization, self).updateWidgets()
|
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):
|
class AddOrganization(form.AddForm):
|
||||||
implements(IFieldsAndContentProvidersForm)
|
implements(IFieldsAndContentProvidersForm)
|
||||||
contentProviders = ContentProviders(['organization-ms'])
|
contentProviders = ContentProviders(['organization-ms'])
|
||||||
|
|
|
@ -79,6 +79,13 @@
|
||||||
permission="cmf.AddPortalContent"
|
permission="cmf.AddPortalContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<browser:page
|
||||||
|
name="add-contact"
|
||||||
|
for="..content.position.IPosition"
|
||||||
|
class=".addcontact.AddContactFromPosition"
|
||||||
|
permission="cmf.AddPortalContent"
|
||||||
|
/>
|
||||||
|
|
||||||
<browser:page
|
<browser:page
|
||||||
name="add-organization"
|
name="add-organization"
|
||||||
for="*"
|
for="*"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from AccessControl import getSecurityManager
|
||||||
|
|
||||||
from zope.component import getUtility
|
from zope.component import getUtility
|
||||||
from zope.schema.interfaces import IVocabularyFactory
|
from zope.schema.interfaces import IVocabularyFactory
|
||||||
|
|
||||||
|
@ -6,6 +8,26 @@ from collective.contact.core.browser.utils import get_ttw_fields
|
||||||
from collective.contact.core.interfaces import IContactable
|
from collective.contact.core.interfaces import IContactable
|
||||||
|
|
||||||
|
|
||||||
|
ADDNEW_OVERLAY = """
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Position(BaseView):
|
class Position(BaseView):
|
||||||
|
|
||||||
name = ''
|
name = ''
|
||||||
|
@ -35,3 +57,7 @@ class Position(BaseView):
|
||||||
|
|
||||||
# also show fields that were added TTW
|
# also show fields that were added TTW
|
||||||
self.ttw_fields = get_ttw_fields(position)
|
self.ttw_fields = get_ttw_fields(position)
|
||||||
|
|
||||||
|
sm = getSecurityManager()
|
||||||
|
self.can_add = sm.checkPermission('Add portal content', self.context)
|
||||||
|
self.addnew_script = ADDNEW_OVERLAY
|
||||||
|
|
|
@ -64,6 +64,16 @@
|
||||||
<div id="address"
|
<div id="address"
|
||||||
tal:replace="structure view/render_address" />
|
tal:replace="structure view/render_address" />
|
||||||
|
|
||||||
|
<tal:addnew
|
||||||
|
tal:define="ajax_load request/ajax_load|nothing"
|
||||||
|
tal:condition="python: not ajax_load and view.can_add">
|
||||||
|
<a href="@@add-contact" class="addnewcontactfromposition"
|
||||||
|
i18n:translate=""
|
||||||
|
tal:attributes="href string:${context/absolute_url}/@@add-contact">
|
||||||
|
Create <tal:i18n i18n:name="name">Contact</tal:i18n></a>
|
||||||
|
<script tal:replace="structure view/addnew_script"></script>
|
||||||
|
</tal:addnew>
|
||||||
|
|
||||||
<tal:block tal:repeat="field view/ttw_fields">
|
<tal:block tal:repeat="field view/ttw_fields">
|
||||||
<div class="field" tal:define="widget python: view.widgets[field]" tal:condition="widget/value">
|
<div class="field" tal:define="widget python: view.widgets[field]" tal:condition="widget/value">
|
||||||
<label><tal:block tal:content="python: widget.label" i18n:translate="" />:</label>
|
<label><tal:block tal:content="python: widget.label" i18n:translate="" />:</label>
|
||||||
|
|
Reference in New Issue