From 9337238058c3066ab3f59bba1e9b64187e00ba74 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 15 Aug 2016 16:42:04 +0200 Subject: [PATCH 001/144] updated checkEmailAddress to not be dependend on CMFDefault --- src/collective/contact/core/behaviors.py | 32 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/collective/contact/core/behaviors.py b/src/collective/contact/core/behaviors.py index 3a933578..b22b88f5 100644 --- a/src/collective/contact/core/behaviors.py +++ b/src/collective/contact/core/behaviors.py @@ -18,27 +18,39 @@ from plone.app.textfield import RichText from plone.app.dexterity.browser.types import TypeSchemaContext -from Products.CMFDefault.utils import checkEmailAddress -from Products.CMFDefault.exceptions import EmailAddressInvalid +# from Products.CMFDefault.utils import checkEmailAddress +# from Products.CMFDefault.exceptions import EmailAddressInvalid from collective.contact.core import _ from collective.contact.core.interfaces import IContactable from collective.contact.widget.schema import ContactChoice, ContactList from collective.contact.widget.source import ContactSourceBinder +# Taken from http://www.regular-expressions.info/email.html +_isemail = r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}" +_isemail = re.compile(_isemail).match + class InvalidEmailAddress(schema.ValidationError): """Exception for invalid address""" __doc__ = _(u"Invalid email address") -def validateEmail(value): - """Simple email validator""" - try: - checkEmailAddress(value) - except EmailAddressInvalid: - raise InvalidEmailAddress(value) - return True +# def validateEmail(value): +# super(Email, self)._validate(value) +# if _isemail(value): +# return + +# raise InvalidEmail(value) + + +# def validateEmail(value): +# """Simple email validator""" +# try: +# checkEmailAddress(value) +# except EmailAddressInvalid: +# raise InvalidEmailAddress(value) +# return True class InvalidPhone(schema.ValidationError): @@ -142,7 +154,7 @@ class IContactDetails(model.Schema): email = schema.TextLine( title=_(u"Email"), - constraint=validateEmail, + # constraint=validateEmail, required=False, ) From e6b01a98298b850af4fde3de9dd2e899e0f3ebc3 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 19 Aug 2016 14:41:25 +0200 Subject: [PATCH 002/144] disable plone.app.linkintegrity subscribers --- src/collective/contact/core/configure.zcml | 8 +-- src/collective/contact/core/subscribers.py | 70 +++++++++++----------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index fbeb0e0a..be4e81fa 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -109,15 +109,15 @@ factory=".behaviors.DefaultParentAddress" name="default" /> - + handler=".subscribers.referencedObjectRemoved" /> --> - + handler=".subscribers.referenceRemoved" /> --> Date: Fri, 19 Aug 2016 14:43:15 +0200 Subject: [PATCH 003/144] disable filter function --- src/collective/contact/core/browser/organization.py | 2 +- src/collective/contact/core/browser/position.py | 2 +- src/collective/contact/core/browser/static/forms.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index e1d03a9b..ad0ff61b 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -18,7 +18,7 @@ $(document).ready(function(){ $('.addnewcontactfromorganization').prepOverlay({ subtype: 'ajax', - filter: common_content_filter, +// filter: common_content_filter, formselector: '#oform', cssclass: 'overlay-contact-addnew', closeselector: '[name="oform.buttons.cancel"]', diff --git a/src/collective/contact/core/browser/position.py b/src/collective/contact/core/browser/position.py index 2d817138..c04d45c7 100644 --- a/src/collective/contact/core/browser/position.py +++ b/src/collective/contact/core/browser/position.py @@ -12,7 +12,7 @@ $(document).ready(function(){ $('.addnewcontactfromposition').prepOverlay({ subtype: 'ajax', - filter: common_content_filter, +// filter: common_content_filter, formselector: '#oform', cssclass: 'overlay-contact-addnew', closeselector: '[name="oform.buttons.cancel"]', diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index 11ccf7a3..e9e503a0 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -168,7 +168,7 @@ $(document).ready(function(){ $('.contactoverlay').prepOverlay({ subtype: 'ajax', - filter: common_content_filter, +// filter: common_content_filter, formselector: '#form', closeselector: '[name="form.buttons.cancel"]', noform: function(el, pbo) {return 'reload';} @@ -176,7 +176,7 @@ $(document).ready(function(){ $('.deleteoverlay').prepOverlay({ subtype: 'ajax', - filter: common_content_filter, +// filter: common_content_filter, formselector: '#delete_confirmation', closeselector: '[name="form.button.Cancel"]', noform: function(el, pbo) {return 'reload';} From 390dd3a84be1edd1d68ccc9ae45c6eba0dda8889 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 19 Aug 2016 14:43:34 +0200 Subject: [PATCH 004/144] disable RelationChoiceHandler --- src/collective/contact/core/configure.zcml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index be4e81fa..34cf21da 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -56,10 +56,10 @@ provides="Products.GenericSetup.interfaces.EXTENSION" /> - + /> --> Date: Wed, 28 Sep 2016 11:15:22 +0200 Subject: [PATCH 005/144] disable postinstall --- src/collective/contact/core/configure.zcml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 34cf21da..0e4c4a07 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -26,12 +26,12 @@ - - + --> Date: Wed, 28 Sep 2016 11:16:24 +0200 Subject: [PATCH 006/144] move icons to resource directory --- .../static}/create_contact.png | Bin .../static}/directory_icon.png | Bin .../static}/directory_icon.png.metadata | 0 .../static}/held_position_icon.png | Bin .../static}/held_position_icon.png.metadata | 0 .../static}/organization_icon.png | Bin .../static}/organization_icon.png.metadata | 0 .../static}/person_icon.png | Bin .../static}/person_icon.png.metadata | 0 .../static}/position_icon.png | Bin .../static}/position_icon.png.metadata | 0 .../static}/vcard_icon.png | Bin .../static}/vcard_icon.png.metadata | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/create_contact.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/directory_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/directory_icon.png.metadata (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/held_position_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/held_position_icon.png.metadata (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/organization_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/organization_icon.png.metadata (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/person_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/person_icon.png.metadata (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/position_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/position_icon.png.metadata (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/vcard_icon.png (100%) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/vcard_icon.png.metadata (100%) diff --git a/src/collective/contact/core/skins/collective_contact_core/create_contact.png b/src/collective/contact/core/browser/static/create_contact.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/create_contact.png rename to src/collective/contact/core/browser/static/create_contact.png diff --git a/src/collective/contact/core/skins/collective_contact_core/directory_icon.png b/src/collective/contact/core/browser/static/directory_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/directory_icon.png rename to src/collective/contact/core/browser/static/directory_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/directory_icon.png.metadata b/src/collective/contact/core/browser/static/directory_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/directory_icon.png.metadata rename to src/collective/contact/core/browser/static/directory_icon.png.metadata diff --git a/src/collective/contact/core/skins/collective_contact_core/held_position_icon.png b/src/collective/contact/core/browser/static/held_position_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/held_position_icon.png rename to src/collective/contact/core/browser/static/held_position_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/held_position_icon.png.metadata b/src/collective/contact/core/browser/static/held_position_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/held_position_icon.png.metadata rename to src/collective/contact/core/browser/static/held_position_icon.png.metadata diff --git a/src/collective/contact/core/skins/collective_contact_core/organization_icon.png b/src/collective/contact/core/browser/static/organization_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/organization_icon.png rename to src/collective/contact/core/browser/static/organization_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/organization_icon.png.metadata b/src/collective/contact/core/browser/static/organization_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/organization_icon.png.metadata rename to src/collective/contact/core/browser/static/organization_icon.png.metadata diff --git a/src/collective/contact/core/skins/collective_contact_core/person_icon.png b/src/collective/contact/core/browser/static/person_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/person_icon.png rename to src/collective/contact/core/browser/static/person_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/person_icon.png.metadata b/src/collective/contact/core/browser/static/person_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/person_icon.png.metadata rename to src/collective/contact/core/browser/static/person_icon.png.metadata diff --git a/src/collective/contact/core/skins/collective_contact_core/position_icon.png b/src/collective/contact/core/browser/static/position_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/position_icon.png rename to src/collective/contact/core/browser/static/position_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/position_icon.png.metadata b/src/collective/contact/core/browser/static/position_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/position_icon.png.metadata rename to src/collective/contact/core/browser/static/position_icon.png.metadata diff --git a/src/collective/contact/core/skins/collective_contact_core/vcard_icon.png b/src/collective/contact/core/browser/static/vcard_icon.png similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/vcard_icon.png rename to src/collective/contact/core/browser/static/vcard_icon.png diff --git a/src/collective/contact/core/skins/collective_contact_core/vcard_icon.png.metadata b/src/collective/contact/core/browser/static/vcard_icon.png.metadata similarity index 100% rename from src/collective/contact/core/skins/collective_contact_core/vcard_icon.png.metadata rename to src/collective/contact/core/browser/static/vcard_icon.png.metadata From a2b11b9c44e198925790ef707a0955cbb8ee3540 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 28 Sep 2016 11:16:50 +0200 Subject: [PATCH 007/144] move styles to resource directory --- .../static}/style.css | 10 +++++++++- .../contact/core/profiles/default/cssregistry.xml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) rename src/collective/contact/core/{skins/collective_contact_core => browser/static}/style.css (86%) diff --git a/src/collective/contact/core/skins/collective_contact_core/style.css b/src/collective/contact/core/browser/static/style.css similarity index 86% rename from src/collective/contact/core/skins/collective_contact_core/style.css rename to src/collective/contact/core/browser/static/style.css index eafa49ec..2c85af6a 100644 --- a/src/collective/contact/core/skins/collective_contact_core/style.css +++ b/src/collective/contact/core/browser/static/style.css @@ -41,4 +41,12 @@ .portaltype-person #held_positions .held_position .organization #logo { float: left; padding-right: 1em; -} \ No newline at end of file +} + +/* Reset widget styling for Plone 5 */ +#formfield-form-widgets-IBirthday-birthday select { + width: unset; + display: unset; +} + + diff --git a/src/collective/contact/core/profiles/default/cssregistry.xml b/src/collective/contact/core/profiles/default/cssregistry.xml index 81a5b922..b8b56172 100644 --- a/src/collective/contact/core/profiles/default/cssregistry.xml +++ b/src/collective/contact/core/profiles/default/cssregistry.xml @@ -2,7 +2,7 @@ From ac7fa90ccbf2c0ad2e1832d42ad3c2d0194bf2c0 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 28 Sep 2016 11:17:00 +0200 Subject: [PATCH 008/144] update icon paths --- .../contact/core/browser/basefields/templates/person.pt | 2 +- src/collective/contact/core/browser/templates/contactdetails.pt | 2 +- src/collective/contact/core/browser/templates/heldpositions.pt | 2 +- src/collective/contact/core/browser/templates/organization.pt | 2 +- src/collective/contact/core/browser/templates/position.pt | 2 +- .../contact/core/profiles/default/types/directory.xml | 2 +- .../contact/core/profiles/default/types/held_position.xml | 2 +- .../contact/core/profiles/default/types/organization.xml | 2 +- src/collective/contact/core/profiles/default/types/person.xml | 2 +- src/collective/contact/core/profiles/default/types/position.xml | 2 +- src/collective/contact/core/profiles/testing/types/testtype.xml | 2 +- .../contact/core/upgrades/profiles/v2/types/directory.xml | 2 +- .../contact/core/upgrades/profiles/v2/types/held_position.xml | 2 +- .../contact/core/upgrades/profiles/v2/types/organization.xml | 2 +- .../contact/core/upgrades/profiles/v2/types/person.xml | 2 +- .../contact/core/upgrades/profiles/v2/types/position.xml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/collective/contact/core/browser/basefields/templates/person.pt b/src/collective/contact/core/browser/basefields/templates/person.pt index bf7aa969..2c07185d 100644 --- a/src/collective/contact/core/browser/basefields/templates/person.pt +++ b/src/collective/contact/core/browser/basefields/templates/person.pt @@ -9,7 +9,7 @@
Edit diff --git a/src/collective/contact/core/browser/templates/contactdetails.pt b/src/collective/contact/core/browser/templates/contactdetails.pt index 9c33ca75..3a2277be 100644 --- a/src/collective/contact/core/browser/templates/contactdetails.pt +++ b/src/collective/contact/core/browser/templates/contactdetails.pt @@ -57,7 +57,7 @@

- + Download VCard

diff --git a/src/collective/contact/core/browser/templates/heldpositions.pt b/src/collective/contact/core/browser/templates/heldpositions.pt index dd280e67..11b2fcce 100644 --- a/src/collective/contact/core/browser/templates/heldpositions.pt +++ b/src/collective/contact/core/browser/templates/heldpositions.pt @@ -23,7 +23,7 @@ tal:condition="held_position/can_edit"> Edit - + Create Contact diff --git a/src/collective/contact/core/browser/templates/position.pt b/src/collective/contact/core/browser/templates/position.pt index 1015d20f..ec1bf306 100644 --- a/src/collective/contact/core/browser/templates/position.pt +++ b/src/collective/contact/core/browser/templates/position.pt @@ -36,7 +36,7 @@ tal:condition="python: not ajax_load and view.can_add"> - + Create Contact diff --git a/src/collective/contact/core/profiles/default/types/directory.xml b/src/collective/contact/core/profiles/default/types/directory.xml index 0a7e4a20..e6a26acb 100644 --- a/src/collective/contact/core/profiles/default/types/directory.xml +++ b/src/collective/contact/core/profiles/default/types/directory.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Directory - directory_icon.png + ++resource++collective.contact.core/directory_icon.png directory string:${folder_url}/++add++directory diff --git a/src/collective/contact/core/profiles/default/types/held_position.xml b/src/collective/contact/core/profiles/default/types/held_position.xml index 8bd15b9c..a1ba2a63 100644 --- a/src/collective/contact/core/profiles/default/types/held_position.xml +++ b/src/collective/contact/core/profiles/default/types/held_position.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Held position - string:${portal_url}/held_position_icon.png + string:${portal_url}/++resource++collective.contact.core/held_position_icon.png held_position string:${folder_url}/++add++held_position diff --git a/src/collective/contact/core/profiles/default/types/organization.xml b/src/collective/contact/core/profiles/default/types/organization.xml index 5512528c..f58b3a55 100644 --- a/src/collective/contact/core/profiles/default/types/organization.xml +++ b/src/collective/contact/core/profiles/default/types/organization.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Organization - string:${portal_url}/organization_icon.png + string:${portal_url}/++resource++collective.contact.core/organization_icon.png organization string:${folder_url}/++add++organization diff --git a/src/collective/contact/core/profiles/default/types/person.xml b/src/collective/contact/core/profiles/default/types/person.xml index e13463c4..13a6fde0 100644 --- a/src/collective/contact/core/profiles/default/types/person.xml +++ b/src/collective/contact/core/profiles/default/types/person.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Person - string:${portal_url}/person_icon.png + string:${portal_url}/++resource++collective.contact.core/person_icon.png person string:${folder_url}/++add++person diff --git a/src/collective/contact/core/profiles/default/types/position.xml b/src/collective/contact/core/profiles/default/types/position.xml index 61f5b03b..1849d691 100644 --- a/src/collective/contact/core/profiles/default/types/position.xml +++ b/src/collective/contact/core/profiles/default/types/position.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Position - string:${portal_url}/position_icon.png + string:${portal_url}/++resource++collective.contact.core/position_icon.png position string:${folder_url}/++add++position diff --git a/src/collective/contact/core/profiles/testing/types/testtype.xml b/src/collective/contact/core/profiles/testing/types/testtype.xml index 78269d30..c59b72ce 100644 --- a/src/collective/contact/core/profiles/testing/types/testtype.xml +++ b/src/collective/contact/core/profiles/testing/types/testtype.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Test type None - string:${portal_url}/folder_icon.png + string:${portal_url}/++resource++collective.contact.core/folder_icon.png testtype string:${folder_url}/++add++testtype diff --git a/src/collective/contact/core/upgrades/profiles/v2/types/directory.xml b/src/collective/contact/core/upgrades/profiles/v2/types/directory.xml index 502cb0dd..ce08d0ef 100644 --- a/src/collective/contact/core/upgrades/profiles/v2/types/directory.xml +++ b/src/collective/contact/core/upgrades/profiles/v2/types/directory.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Directory - string:${portal_url}/directory_icon.png + string:${portal_url}/++resource++collective.contact.core/directory_icon.png directory string:${folder_url}/++add++directory diff --git a/src/collective/contact/core/upgrades/profiles/v2/types/held_position.xml b/src/collective/contact/core/upgrades/profiles/v2/types/held_position.xml index 9ec431dd..d9cb33ea 100644 --- a/src/collective/contact/core/upgrades/profiles/v2/types/held_position.xml +++ b/src/collective/contact/core/upgrades/profiles/v2/types/held_position.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Held position - string:${portal_url}/position_icon.png + string:${portal_url}/++resource++collective.contact.core/position_icon.png held_position string:${folder_url}/++add++held_position diff --git a/src/collective/contact/core/upgrades/profiles/v2/types/organization.xml b/src/collective/contact/core/upgrades/profiles/v2/types/organization.xml index 392bd8cb..28304c15 100644 --- a/src/collective/contact/core/upgrades/profiles/v2/types/organization.xml +++ b/src/collective/contact/core/upgrades/profiles/v2/types/organization.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Organization - string:${portal_url}/organization_icon.png + string:${portal_url}/++resource++collective.contact.core/organization_icon.png organization string:${folder_url}/++add++organization diff --git a/src/collective/contact/core/upgrades/profiles/v2/types/person.xml b/src/collective/contact/core/upgrades/profiles/v2/types/person.xml index 47b588c0..189db30d 100644 --- a/src/collective/contact/core/upgrades/profiles/v2/types/person.xml +++ b/src/collective/contact/core/upgrades/profiles/v2/types/person.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Person - string:${portal_url}/person_icon.png + string:${portal_url}/++resource++collective.contact.core/person_icon.png person string:${folder_url}/++add++person diff --git a/src/collective/contact/core/upgrades/profiles/v2/types/position.xml b/src/collective/contact/core/upgrades/profiles/v2/types/position.xml index 0c5329d3..205391dd 100644 --- a/src/collective/contact/core/upgrades/profiles/v2/types/position.xml +++ b/src/collective/contact/core/upgrades/profiles/v2/types/position.xml @@ -3,7 +3,7 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n"> Position - string:${portal_url}/position_icon.png + string:${portal_url}/++resource++collective.contact.core/position_icon.png position string:${folder_url}/++add++position From 3068384e7e591fabfa4ea5e6d3027ad488f7c212 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 09:43:52 +0200 Subject: [PATCH 009/144] replaced portal_url with actual string, degrok --- .../contact/core/browser/addcontact.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index a5374a87..a1a060a5 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -30,6 +30,10 @@ from collective.contact.core.content.person import IPerson from collective.contact.core.behaviors import IContactDetails +from zope.interface import implementer +from zope.interface import provider +from zope.component.hooks import getSite + class ICustomSettings(Interface): """You can overrides those methods by writing an adapter to IDirectory. @@ -49,9 +53,11 @@ def add_url_for_portal_type(self, directory_url, portal_type): """ +@provider(IContactWidgetSettings) +@implementer(ICustomSettings) class ContactWidgetSettings(grok.GlobalUtility): - grok.provides(IContactWidgetSettings) - grok.implements(ICustomSettings) + # grok.provides(IContactWidgetSettings) + # grok.implements(ICustomSettings) def label_for_portal_type(self, portal_type): if isinstance(portal_type, Message): @@ -156,8 +162,8 @@ def add_contact_infos(self, widget): return {'actions': actions, 'close_on_click': close_on_click, 'formatItem': """function(row, idx, count, value) { -return ' ' + row[1] }""" +return ' ' + row[1] }""" % (getSite().absolute_url()) } @@ -211,7 +217,7 @@ def render(self): add_text = addneworga.data('pbo').original_text; } else { // update add new orga link to add sub orga - add_organization_url = portal_url + orga.path + '/++add++organization'; + add_organization_url = %s + orga.path + '/++add++organization'; add_text = addneworga.data('pbo').original_text + ' dans ' + orga.title; } addneworga.data('pbo').src = add_organization_url; @@ -226,7 +232,7 @@ def render(self): .setOptions({extraParams: {path: orga.token}}).flushCache(); // update add new position url - var add_position_url = portal_url + orga.path + '/++add++position'; + var add_position_url = %s + orga.path + '/++add++position'; o.find('#oform-widgets-position-autocomplete .addnew').each(function(){ jQuery(this).data('pbo').src = add_position_url; }) @@ -258,7 +264,10 @@ def render(self): }); -""" % str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower() +""" % (str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower(), + getSite().absolute_url(), + getSite().absolute_url(), + ) class IAddHeldPosition(model.Schema): From a61ca257cedacf673392be6890826ef62ec64cf3 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 13:15:16 +0200 Subject: [PATCH 010/144] fix constraint error --- src/collective/contact/core/browser/addcontact.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index a1a060a5..3607e892 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -33,6 +33,8 @@ from zope.interface import implementer from zope.interface import provider from zope.component.hooks import getSite +from zope.interface import alsoProvides +from plone.z3cform.interfaces import IDeferSecurityCheck class ICustomSettings(Interface): @@ -374,6 +376,7 @@ def updateWidgets(self): self.widgets['parent_address'].mode = DISPLAY_MODE def update(self): + alsoProvides(self.request, IDeferSecurityCheck) super(AddContact, self).update() if self.schema != IAddHeldPosition: # revert required field changes From b235fbd40ad26eb1e14ac1702bd628580686bc9a Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 13:15:48 +0200 Subject: [PATCH 011/144] fix js url construction --- src/collective/contact/core/browser/addcontact.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 3607e892..f13ac12e 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -164,8 +164,7 @@ def add_contact_infos(self, widget): return {'actions': actions, 'close_on_click': close_on_click, 'formatItem': """function(row, idx, count, value) { -return ' ' + row[1] }""" % (getSite().absolute_url()) +return ' ' + row[1] }""" % (getSite().absolute_url()) } @@ -219,7 +218,7 @@ def render(self): add_text = addneworga.data('pbo').original_text; } else { // update add new orga link to add sub orga - add_organization_url = %s + orga.path + '/++add++organization'; + add_organization_url = "%s" + orga.path + '/++add++organization'; add_text = addneworga.data('pbo').original_text + ' dans ' + orga.title; } addneworga.data('pbo').src = add_organization_url; @@ -234,7 +233,7 @@ def render(self): .setOptions({extraParams: {path: orga.token}}).flushCache(); // update add new position url - var add_position_url = %s + orga.path + '/++add++position'; + var add_position_url = "%s" + orga.path + '/++add++position'; o.find('#oform-widgets-position-autocomplete .addnew').each(function(){ jQuery(this).data('pbo').src = add_position_url; }) From 07c187505a83d1125dcb8e0e4cc481a831c1193a Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 13:16:15 +0200 Subject: [PATCH 012/144] =?UTF-8?q?back=20to=20grok=20for=20now=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/collective/contact/core/browser/addcontact.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index f13ac12e..848b01cb 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -55,11 +55,11 @@ def add_url_for_portal_type(self, directory_url, portal_type): """ -@provider(IContactWidgetSettings) -@implementer(ICustomSettings) +# @provider(IContactWidgetSettings) +# @implementer(ICustomSettings) class ContactWidgetSettings(grok.GlobalUtility): - # grok.provides(IContactWidgetSettings) - # grok.implements(ICustomSettings) + grok.provides(IContactWidgetSettings) + grok.implements(ICustomSettings) def label_for_portal_type(self, portal_type): if isinstance(portal_type, Message): From e306e79259b9347332f4fa5e427405cd18704546 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 5 Oct 2016 10:10:34 +0200 Subject: [PATCH 013/144] plone5 form styling --- src/collective/contact/core/browser/static/style.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/static/style.css b/src/collective/contact/core/browser/static/style.css index 2c85af6a..8ae58ad6 100644 --- a/src/collective/contact/core/browser/static/style.css +++ b/src/collective/contact/core/browser/static/style.css @@ -49,4 +49,11 @@ display: unset; } - +#oform input[type="text"], +#oform input[type="email"], +#oform input[type="password"], +#oform textarea, +#oform select { + width: auto!important; + display: inline-block; +} From a986ee9f9e9848d6fc1aa99a79b398d0afd803b4 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 28 Sep 2016 11:16:50 +0200 Subject: [PATCH 014/144] move styles to resource directory --- src/collective/contact/core/browser/static/style.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/collective/contact/core/browser/static/style.css b/src/collective/contact/core/browser/static/style.css index 8ae58ad6..c4dd36df 100644 --- a/src/collective/contact/core/browser/static/style.css +++ b/src/collective/contact/core/browser/static/style.css @@ -57,3 +57,12 @@ width: auto!important; display: inline-block; } + + +/* Reset widget styling for Plone 5 */ +#formfield-form-widgets-IBirthday-birthday select { + width: unset; + display: unset; +} + + From 08fc8d7174d2b47995aee93f1f3a23777a7d48c4 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 09:43:52 +0200 Subject: [PATCH 015/144] replaced portal_url with actual string, degrok --- src/collective/contact/core/browser/addcontact.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 848b01cb..f13ac12e 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -55,11 +55,11 @@ def add_url_for_portal_type(self, directory_url, portal_type): """ -# @provider(IContactWidgetSettings) -# @implementer(ICustomSettings) +@provider(IContactWidgetSettings) +@implementer(ICustomSettings) class ContactWidgetSettings(grok.GlobalUtility): - grok.provides(IContactWidgetSettings) - grok.implements(ICustomSettings) + # grok.provides(IContactWidgetSettings) + # grok.implements(ICustomSettings) def label_for_portal_type(self, portal_type): if isinstance(portal_type, Message): From 6a36d3176a40d41eef47459a62775c626eb72d91 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 30 Sep 2016 13:16:15 +0200 Subject: [PATCH 016/144] =?UTF-8?q?back=20to=20grok=20for=20now=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/collective/contact/core/browser/addcontact.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index f13ac12e..848b01cb 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -55,11 +55,11 @@ def add_url_for_portal_type(self, directory_url, portal_type): """ -@provider(IContactWidgetSettings) -@implementer(ICustomSettings) +# @provider(IContactWidgetSettings) +# @implementer(ICustomSettings) class ContactWidgetSettings(grok.GlobalUtility): - # grok.provides(IContactWidgetSettings) - # grok.implements(ICustomSettings) + grok.provides(IContactWidgetSettings) + grok.implements(ICustomSettings) def label_for_portal_type(self, portal_type): if isinstance(portal_type, Message): From ccb9e97066e8e1309bf96b65b7d698daab8bd81c Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 5 Oct 2016 10:10:34 +0200 Subject: [PATCH 017/144] plone5 form styling --- src/collective/contact/core/browser/static/style.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/static/style.css b/src/collective/contact/core/browser/static/style.css index c4dd36df..bdef5b5d 100644 --- a/src/collective/contact/core/browser/static/style.css +++ b/src/collective/contact/core/browser/static/style.css @@ -65,4 +65,11 @@ display: unset; } - +#oform input[type="text"], +#oform input[type="email"], +#oform input[type="password"], +#oform textarea, +#oform select { + width: auto!important; + display: inline-block; +} From 7878f9a0c314e7a684948357c20303b9b9785e34 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 25 Nov 2016 11:43:41 +0100 Subject: [PATCH 018/144] remove label, already there from vocab --- src/collective/contact/core/browser/templates/othercontacts.pt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/collective/contact/core/browser/templates/othercontacts.pt b/src/collective/contact/core/browser/templates/othercontacts.pt index 448da927..83ee594c 100644 --- a/src/collective/contact/core/browser/templates/othercontacts.pt +++ b/src/collective/contact/core/browser/templates/othercontacts.pt @@ -23,7 +23,6 @@ - From 191a2afc2b3ebd08ff2f168d9148911fc5261cfc Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 25 Nov 2016 11:44:18 +0100 Subject: [PATCH 019/144] make it easier to override held position order on organisation view --- src/collective/contact/core/browser/organization.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index ad0ff61b..15cb017e 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -71,11 +71,14 @@ class OtherContacts(grok.View): held_positions = '' + def held_position_order_key(self, held_position): + return held_position_sortable_title(held_position) + def update(self): organization = self.context othercontacts = [] held_positions = organization.get_held_positions() - held_positions.sort(key=lambda x: held_position_sortable_title(x)()) + held_positions.sort(key=lambda x: self.held_position_order_key(x)) for hp in held_positions: contact = {} person = hp.get_person() From 6dc70d22ae86ca0c912bcdbca526715280eb48df Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 25 Nov 2016 13:44:26 +0100 Subject: [PATCH 020/144] added , if more than one person fills a position - avoiding extra whitespace here --- .../contact/core/browser/templates/organization.pt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index a6943e0f..ef632823 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -59,11 +59,10 @@ tal:define="person held_position/get_person" tal:attributes="href person/absolute_url"> - - - (from to ) - + i18n:translate="" + /> + (from to ) + , Not assigned From 09a583216d174cd16af0b7624f4a781c0122d383 Mon Sep 17 00:00:00 2001 From: "T. Kim Nguyen" Date: Wed, 11 Jan 2017 09:23:42 -0600 Subject: [PATCH 021/144] add Plone 5.0 classifier --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a80a7110..952d22f4 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ "Framework :: Plone", "Framework :: Plone :: 4.2", "Framework :: Plone :: 4.3", + "Framework :: Plone :: 5.0", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", From f007a28a1356cdd40ce7217b717136ac63c7fa58 Mon Sep 17 00:00:00 2001 From: "T. Kim Nguyen" Date: Wed, 11 Jan 2017 09:25:38 -0600 Subject: [PATCH 022/144] mention Plone 5 compatibility --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index e7639e27..b2f458d1 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,11 @@ This add-on is part of the ``collective.contact.*`` suite. For an overview and a A Plone add-on that provides a directory where you create persons, organizations, sub-organizations and positions. +Plone Version Compatibility +=========================== + +collective.contact.core 1.11 works with Plone 5 + How-to ====== From efbdace8c565f6b21012333b9243d7c5dd81c6b0 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 23 Jan 2017 14:35:12 +0100 Subject: [PATCH 023/144] fix translation --- .../core/locales/de/LC_MESSAGES/collective.contact.core.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po index 02e7bc18..e59ab281 100644 --- a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po @@ -371,7 +371,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:7 #: ../browser/templates/organization.pt:55 msgid "colon" -msgstr "\":\"" +msgstr ":" #: ../browser/templates/organization.pt:65 msgid "from" From 7786f47a7fdaf657ef3700d62f0f4a39b731b49e Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 23 Jan 2017 18:33:14 +0100 Subject: [PATCH 024/144] =?UTF-8?q?step=20one=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contact/core/browser/addcontact.py | 49 ++++++------- .../contact/core/browser/configure.zcml | 71 +++++++++++++++++++ .../contact/core/browser/contactable.py | 62 ++++++++-------- .../contact/core/browser/organization.py | 29 +++----- src/collective/contact/core/browser/person.py | 22 +++--- .../contact/core/browser/ttwfields.py | 19 ++--- .../contact/core/content/directory.py | 13 ++-- .../contact/core/content/held_position.py | 25 +++---- .../contact/core/content/organization.py | 31 ++++---- src/collective/contact/core/content/person.py | 32 ++++----- .../contact/core/content/position.py | 24 +++---- 11 files changed, 202 insertions(+), 175 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 848b01cb..414aaaec 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -1,19 +1,12 @@ +# -*- coding: utf-8 -*- from AccessControl import getSecurityManager -from zope.component import getUtility, queryAdapter -from zope.contentprovider.interfaces import IContentProvider -from zope.event import notify -from zope.i18n import Message -from zope.interface import implements, Interface -from zope.publisher.browser import BrowserView - -from z3c.form import field, form, button -from z3c.form.contentprovider import ContentProviders -from z3c.form.interfaces import IFieldsAndContentProvidersForm, HIDDEN_MODE,\ - DISPLAY_MODE - -from Products.statusmessages.interfaces import IStatusMessage +from collective.contact.core import _ +from collective.contact.core.behaviors import IContactDetails +from collective.contact.core.content.person import IPerson +from collective.contact.widget.interfaces import IContactWidgetSettings +from collective.contact.widget.schema import ContactChoice +from collective.contact.widget.source import ContactSourceBinder from five import grok - from plone import api from plone.dexterity.browser.add import DefaultAddForm from plone.dexterity.events import AddCancelledEvent @@ -21,20 +14,22 @@ from plone.dexterity.interfaces import IDexterityFTI from plone.dexterity.utils import addContentToContainer from plone.supermodel import model - -from collective.contact.widget.schema import ContactChoice -from collective.contact.widget.source import ContactSourceBinder -from collective.contact.widget.interfaces import IContactWidgetSettings - -from collective.contact.core import _ -from collective.contact.core.content.person import IPerson -from collective.contact.core.behaviors import IContactDetails - -from zope.interface import implementer -from zope.interface import provider +from plone.z3cform.interfaces import IDeferSecurityCheck +from Products.statusmessages.interfaces import IStatusMessage +from z3c.form import field, form, button +from z3c.form.contentprovider import ContentProviders +from z3c.form.interfaces import IFieldsAndContentProvidersForm, \ + HIDDEN_MODE, DISPLAY_MODE +from zope.component import getUtility, queryAdapter from zope.component.hooks import getSite +from zope.contentprovider.interfaces import IContentProvider +from zope.event import notify +from zope.i18n import Message from zope.interface import alsoProvides -from plone.z3cform.interfaces import IDeferSecurityCheck +from zope.interface import implementer +from zope.interface import implements, Interface +from zope.interface import provider +from zope.publisher.browser import BrowserView class ICustomSettings(Interface): @@ -55,8 +50,6 @@ def add_url_for_portal_type(self, directory_url, portal_type): """ -# @provider(IContactWidgetSettings) -# @implementer(ICustomSettings) class ContactWidgetSettings(grok.GlobalUtility): grok.provides(IContactWidgetSettings) grok.implements(ICustomSettings) diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 4ceef481..419e7eeb 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -24,6 +24,7 @@ name="view" for="..content.organization.IOrganization" class=".organization.Organization" + allowed_attributes="parent_organizations sub_organizations positions can_add addnew_script" template="templates/organization.pt" permission="zope2.View" /> @@ -36,6 +37,76 @@ permission="zope2.View" /> + + + + + + + + + + + + + + + + + + + + + + Date: Thu, 26 Jan 2017 19:11:30 +0100 Subject: [PATCH 025/144] degrok views --- .../core/browser/basefields/configure.zcml | 40 ++++++++++++++ .../contact/core/browser/basefields/views.py | 55 +++++++++---------- .../contact/core/browser/configure.zcml | 1 + .../core/browser/templates/heldpositions.pt | 5 +- 4 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 src/collective/contact/core/browser/basefields/configure.zcml diff --git a/src/collective/contact/core/browser/basefields/configure.zcml b/src/collective/contact/core/browser/basefields/configure.zcml new file mode 100644 index 00000000..5848605c --- /dev/null +++ b/src/collective/contact/core/browser/basefields/configure.zcml @@ -0,0 +1,40 @@ + + + + + + + + + + + diff --git a/src/collective/contact/core/browser/basefields/views.py b/src/collective/contact/core/browser/basefields/views.py index 2ad788b9..18be347d 100644 --- a/src/collective/contact/core/browser/basefields/views.py +++ b/src/collective/contact/core/browser/basefields/views.py @@ -1,25 +1,13 @@ +# -*- coding: utf-8 -*- from AccessControl import getSecurityManager - -from five import grok - -from zope.component import getUtility -from zope.schema.interfaces import IVocabularyFactory - from collective.contact.core.behaviors import IBirthday from collective.contact.core.browser.utils import date_to_DateTime -from collective.contact.core.content.person import IPerson -from collective.contact.core.content.organization import IOrganization -from collective.contact.core.content.position import IPosition -from collective.contact.core.content.held_position import IHeldPosition - - -grok.templatedir('templates') +from Products.Five import BrowserView +from zope.component import getUtility +from zope.schema.interfaces import IVocabularyFactory -class PersonBaseFields(grok.View): - grok.name('basefields') - grok.template('person') - grok.context(IPerson) +class PersonBaseFields(BrowserView): name = '' birthday = '' @@ -44,12 +32,12 @@ def update(self): self.gender = person.gender or '' self.can_edit = sm.checkPermission('Modify portal content', person) + def __call__(self): + self.update() + return super(PersonBaseFields, self).__call__() -class OrganizationBaseFields(grok.View): - grok.name('basefields') - grok.template('organization') - grok.context(IOrganization) +class OrganizationBaseFields(BrowserView): name = '' type = '' @@ -64,17 +52,19 @@ def update(self): factory = getUtility(IVocabularyFactory, "OrganizationTypesOrLevels") vocabulary = factory(self.context) try: - self.type = vocabulary.getTerm(organization.organization_type).title + self.type = vocabulary.getTerm( + organization.organization_type + ).title except LookupError: pass self.activity = self.context.activity + def __call__(self): + self.update() + return super(OrganizationBaseFields, self).__call__() -class PositionBaseFields(grok.View): - grok.name('basefields') - grok.template('position') - grok.context(IPosition) +class PositionBaseFields(BrowserView): name = '' type = '' @@ -87,11 +77,12 @@ def update(self): vocabulary = factory(self.context) self.type = vocabulary.getTerm(position.position_type).title + def __call__(self): + self.update() + return super(PositionBaseFields, self).__call__() -class HeldPositionBaseFields(grok.View): - grok.name('basefields') - grok.template('held_position') - grok.context(IHeldPosition) + +class HeldPositionBaseFields(BrowserView): start_date = '' end_date = '' @@ -119,3 +110,7 @@ def update(self): self.title = held_position.Title() self.position = held_position.get_position() + + def __call__(self): + self.update() + return super(HeldPositionBaseFields, self).__call__() diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 419e7eeb..19c1a1bd 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -6,6 +6,7 @@ i18n_domain="collective.contact.core"> +
@@ -11,7 +12,7 @@
-
+
View Date: Tue, 7 Feb 2017 18:16:43 +0100 Subject: [PATCH 026/144] add separate __call__ method --- src/collective/contact/core/browser/organization.py | 7 ++++++- src/collective/contact/core/browser/person.py | 6 +++++- src/collective/contact/core/browser/ttwfields.py | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index f53b67ba..7d483fa6 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -33,6 +33,7 @@ class Organization(BaseView): def update(self): + super(Organization, self).update() self.organization = self.context organization = self.organization @@ -66,7 +67,7 @@ class OtherContacts(BrowserView): def held_position_order_key(self, held_position): return held_position_sortable_title(held_position) - def __call__(self): + def update(self): organization = self.context othercontacts = [] held_positions = organization.get_held_positions() @@ -95,3 +96,7 @@ def __call__(self): self.othercontacts = othercontacts return super(OtherContacts, self).__call__() + + def __call__(self): + self.update() + return super(OtherContacts, self).__call__() diff --git a/src/collective/contact/core/browser/person.py b/src/collective/contact/core/browser/person.py index ab166b28..8806268a 100644 --- a/src/collective/contact/core/browser/person.py +++ b/src/collective/contact/core/browser/person.py @@ -28,7 +28,7 @@ class HeldPositions(BrowserView): held_positions = '' - def __call__(self): + def update(self): person = self.context sm = getSecurityManager() held_positions = [] @@ -57,3 +57,7 @@ def __call__(self): self.held_positions = held_positions return super(HeldPositions, self).__call__() + + def __call__(self): + self.update() + return super(HeldPositions, self).__call__() diff --git a/src/collective/contact/core/browser/ttwfields.py b/src/collective/contact/core/browser/ttwfields.py index 81dfb583..f80a1491 100644 --- a/src/collective/contact/core/browser/ttwfields.py +++ b/src/collective/contact/core/browser/ttwfields.py @@ -9,9 +9,13 @@ class TTWFields(BrowserView): """Show fields that were added TTW """ - def __call__(self): + def update(self): contact_view = self.context.unrestrictedTraverse('view') contact_view.update() self.widgets = contact_view.widgets ttw_fields = get_ttw_fields(self.context) self.ttw_fields = [field for field in ttw_fields if field in self.widgets.keys()] + + def __call__(self): + self.update() + return super(TTWFields, self).__call__() From 51eed48cd77e87a6778fef013bcbdd1b84002758 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Tue, 17 Jan 2017 11:04:17 +0100 Subject: [PATCH 027/144] fix space before end date --- .../contact/core/browser/templates/organization.pt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index ef632823..a6943e0f 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -59,10 +59,11 @@ tal:define="person held_position/get_person" tal:attributes="href person/absolute_url"> - (from to ) - , + i18n:translate="" /> + + + (from to ) + Not assigned From 31c730b9bac0b206ccfc50680c3c7bed8ea50e92 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 25 Nov 2016 13:44:26 +0100 Subject: [PATCH 028/144] added , if more than one person fills a position - avoiding extra whitespace here --- .../contact/core/browser/templates/organization.pt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index a6943e0f..ef632823 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -59,11 +59,10 @@ tal:define="person held_position/get_person" tal:attributes="href person/absolute_url"> - - - (from to ) - + i18n:translate="" + /> + (from to ) + , Not assigned From 87c76c760a0b98e25f5e07d6fda6b40b11eaeda1 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 1 Mar 2017 16:26:47 +0100 Subject: [PATCH 029/144] do not fail on missing get_organization --- src/collective/contact/core/browser/person.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/person.py b/src/collective/contact/core/browser/person.py index 8806268a..3fc5c41e 100644 --- a/src/collective/contact/core/browser/person.py +++ b/src/collective/contact/core/browser/person.py @@ -50,7 +50,11 @@ def update(self): # held_position['phone'] = obj.phone # held_position['email'] = obj.email held_position['object'] = obj - held_position['organization'] = obj.get_organization().get_root_organization() + # import pdb; pdb.set_trace() + if obj.get_organization(): + held_position['organization'] = obj.get_organization().get_root_organization() + else: + continue held_position['can_edit'] = sm.checkPermission('Modify portal content', obj) held_position['can_delete'] = sm.checkPermission('Delete objects', obj) held_positions.append(held_position) From b36f5a202ea75b2f8c907af19d29409a9e628c64 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 1 Mar 2017 16:38:50 +0100 Subject: [PATCH 030/144] added png icons (for now) --- .../contact/core/browser/static/delete_icon.png | Bin 0 -> 470 bytes .../core/browser/static/delete_icon.png.metadata | 2 ++ .../contact/core/browser/static/edit.png | Bin 0 -> 226 bytes .../contact/core/browser/static/edit.png.metadata | 2 ++ .../contact/core/browser/static/search_icon.png | Bin 0 -> 223 bytes .../core/browser/static/search_icon.png.metadata | 2 ++ .../core/browser/templates/heldpositions.pt | 4 ++-- 7 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/collective/contact/core/browser/static/delete_icon.png create mode 100644 src/collective/contact/core/browser/static/delete_icon.png.metadata create mode 100644 src/collective/contact/core/browser/static/edit.png create mode 100644 src/collective/contact/core/browser/static/edit.png.metadata create mode 100644 src/collective/contact/core/browser/static/search_icon.png create mode 100644 src/collective/contact/core/browser/static/search_icon.png.metadata diff --git a/src/collective/contact/core/browser/static/delete_icon.png b/src/collective/contact/core/browser/static/delete_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36594937e7c5b7924d9be23c0e1bddeaeba76a58 GIT binary patch literal 470 zcmV;{0V)28P)(5c^|1 z?o}@QS1$RIcji+r@;wmWQZCyq0n#f0-Yx<1F#+VJmE?9>`#%uzlXmGMa*<6b@QYRq%T|DDOV0d!JMQvg8b z*k%9#0E{tr{#+Sk_30gN)qKJ<>4S_?WBN!mt1 zgwr6-6G4~*s7DSVeAt#e@4{$ky+YMXiK4xnn?b`tQB(sO<~>c*WBd$QHhW8$Jos|1 z7{<4TyHl!yXa{6Dj+be^@W7kGaXS$HVE4WO5Nj@=Iu#ZCsd!=Z1doFakyEY-tpET3 M07*qoM6N<$g7+fkJpcdz literal 0 HcmV?d00001 diff --git a/src/collective/contact/core/browser/static/delete_icon.png.metadata b/src/collective/contact/core/browser/static/delete_icon.png.metadata new file mode 100644 index 00000000..855feccc --- /dev/null +++ b/src/collective/contact/core/browser/static/delete_icon.png.metadata @@ -0,0 +1,2 @@ +[default] +cache=HTTPCache diff --git a/src/collective/contact/core/browser/static/edit.png b/src/collective/contact/core/browser/static/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..e432e02970b6ef3cf21372b4349133ff04f47a50 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbK}V1Q4E>;M1%ukA7Zf5!Ms8Uv91 zWz|c6Yxk@7PMg|9FwFeFx>Nsb%bvrtIZD#=mgg^s+4;XSrW&Yq;mnqQ|LeU9rXT6r zwXlAAc}v&%W4)#}VgLWOO#HoS8&CyfNswPKgTu2MX+Vy>r;B4qMcmYrreX|+91MYv z@>Uo9Z&p*yIbQOgcf%|3uZicJ)?{xwVcGsI>Ag|a8-Fg>e@2gY&wqIFiorH%3t#i& WOonGuRF?ydV(@hJb6Mw<&;$U!>R);Q literal 0 HcmV?d00001 diff --git a/src/collective/contact/core/browser/static/edit.png.metadata b/src/collective/contact/core/browser/static/edit.png.metadata new file mode 100644 index 00000000..855feccc --- /dev/null +++ b/src/collective/contact/core/browser/static/edit.png.metadata @@ -0,0 +1,2 @@ +[default] +cache=HTTPCache diff --git a/src/collective/contact/core/browser/static/search_icon.png b/src/collective/contact/core/browser/static/search_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..eb31b322f7eb54819810f5013404c6995312ec0a GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^0w6XAGmxB~Dklb{JOX?|T>t<7@8{=t?AWmvpZ?r= z{cF#jJ@Zd~UA%bltQ3_yuYW(Qm0f-Q`^o!1zwa+SxNXUa2S1md`L_DP_x-nj05$%) zzUt(Ip9k*zIC%T#_dgu}fMzn51o;IsI6S+N2IRPUx;TbZ#P#-@3o#gS9Em94nSS|y z{VOpWJ-@qIS9H!Mrfp8P=6~__NG+q+3Dxs_!70H3ckXfdb1}$qM+W^&es^)rWO3PJ X?-{qP+1`2@Xdr{9tDnm{r-UW|&FyM1 literal 0 HcmV?d00001 diff --git a/src/collective/contact/core/browser/static/search_icon.png.metadata b/src/collective/contact/core/browser/static/search_icon.png.metadata new file mode 100644 index 00000000..855feccc --- /dev/null +++ b/src/collective/contact/core/browser/static/search_icon.png.metadata @@ -0,0 +1,2 @@ +[default] +cache=HTTPCache diff --git a/src/collective/contact/core/browser/templates/heldpositions.pt b/src/collective/contact/core/browser/templates/heldpositions.pt index 9b0b6a37..b6c0b269 100644 --- a/src/collective/contact/core/browser/templates/heldpositions.pt +++ b/src/collective/contact/core/browser/templates/heldpositions.pt @@ -16,7 +16,7 @@ View Delete
From b9f9c4b1b851a1270e97e81ea5252c092d63ffeb Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 7 Mar 2017 18:13:56 +0100 Subject: [PATCH 031/144] sort persons on sortable_title --- src/collective/contact/core/browser/directory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/directory.py b/src/collective/contact/core/browser/directory.py index 434bca98..ab57330c 100644 --- a/src/collective/contact/core/browser/directory.py +++ b/src/collective/contact/core/browser/directory.py @@ -10,6 +10,7 @@ def update(self): search_path = {'query': directory_path, 'depth': 1} catalog = api.portal.get_tool('portal_catalog') self.persons = catalog.searchResults(portal_type="person", - path=search_path) + path=search_path, + sort_on='sortable_title') self.organizations = catalog.searchResults(portal_type="organization", path=search_path) From 2f5667f8bc81f981d966560ac7596f38468de42a Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Wed, 22 Nov 2017 15:55:52 +0100 Subject: [PATCH 032/144] Prevent address field from being erased if they are changed programmaticaly before any manual edition. --- CHANGES.rst | 3 +++ src/collective/contact/core/subscribers.py | 17 +++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index c17990a4..09bb81fc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changelog 1.13 (unreleased) ----------------- +- Prevent address field from being erased if they are changed programmaticaly before any manual edition. + [thomasdesvenain] + - Avoid error in addcontact when there is no directory. [cedricmessiant] diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index 2afe1b5d..1c27db65 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -1,26 +1,19 @@ -from Acquisition import aq_get from five import grok - -from zc.relation.interfaces import ICatalog -from zope import component -from zope.lifecycleevent.interfaces import IObjectAddedEvent,\ - IObjectModifiedEvent +from z3c.form.interfaces import NO_VALUE from zope.container.contained import ContainerModifiedEvent -from zope.intid.interfaces import IIntIds +from zope.lifecycleevent.interfaces import IObjectAddedEvent, \ + IObjectModifiedEvent from zope.schema import getFields -# from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo -# from plone.app.linkintegrity.handlers import referencedObjectRemoved as \ -# baseReferencedObjectRemoved try: from plone.app.referenceablebehavior.referenceable import IReferenceable except ImportError: from zope.interface import Interface + class IReferenceable(Interface): pass -from collective.contact.widget.interfaces import IContactContent from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.held_position import IHeldPosition from collective.contact.core.content.position import IPosition @@ -121,7 +114,7 @@ def clear_fields_use_parent_address(obj, event): """If 'use parent address' has been selected, ensure content address fields are cleared """ - if obj.use_parent_address: + if obj.use_parent_address and obj.use_parent_address != NO_VALUE: upa_field = getFields(IContactDetails)['use_parent_address'] slave_ids = [f['name'] for f in upa_field.slave_fields] for field_name in slave_ids: From c1a241b440b3e9ffeff7b455ffaddf9866c12eff Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 22 Jan 2019 17:25:53 +0100 Subject: [PATCH 033/144] do not show add link if content type is disallowed on directory --- CHANGES.rst | 6 ++++++ src/collective/contact/core/browser/addcontact.py | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 09bb81fc..60100a0c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,12 @@ Changelog ========= +2.0 (unreleased) +---------------- + +- Do not show add link if content type is not allowed as directory subcontent. + [thomasdesvenain] + 1.13 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 414aaaec..3eb305a4 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -6,6 +6,8 @@ from collective.contact.widget.interfaces import IContactWidgetSettings from collective.contact.widget.schema import ContactChoice from collective.contact.widget.source import ContactSourceBinder + +from Products.CMFPlone.interfaces import IConstrainTypes from five import grok from plone import api from plone.dexterity.browser.add import DefaultAddForm @@ -90,6 +92,15 @@ def add_contact_infos(self, widget): if not sm.checkPermission("Add portal content", directory): addlink_enabled = False + allowed_types = api.portal.get_tool('portal_types').directory.allowed_content_types + portal_types = [p for p in portal_types if p in allowed_types] + constrains = IConstrainTypes(directory, None) + if constrains: + portal_types = [p for p in portal_types if p in constrains.getLocallyAllowedTypes()] + + if len(portal_types) == 0: + addlink_enabled = False + close_on_click = True if addlink_enabled: custom_settings = queryAdapter(directory, ICustomSettings, default=self) From a70bb592d3e6113400c13a2f4f2241d1d239ff39 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 22 Jan 2019 21:25:20 +0100 Subject: [PATCH 034/144] fix imports + flake8 --- .../contact/core/browser/addcontact.py | 87 +++++++++---------- .../contact/core/browser/configure.zcml | 13 ++- .../contact/core/browser/organization.py | 1 - .../contact/core/content/organization.py | 12 ++- .../contact/core/content/position.py | 11 +-- 5 files changed, 59 insertions(+), 65 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index af5ba213..40b9708c 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -1,5 +1,5 @@ import copy -from AccessControl import getSecurityManager + from collective.contact.core import _ from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.person import IPerson @@ -7,7 +7,9 @@ from collective.contact.widget.schema import ContactChoice from collective.contact.widget.source import ContactSourceBinder +from AccessControl import getSecurityManager from Products.CMFPlone.interfaces import IConstrainTypes +from Products.statusmessages.interfaces import IStatusMessage from five import grok from plone import api from plone.dexterity.browser.add import DefaultAddForm @@ -17,20 +19,17 @@ from plone.dexterity.utils import addContentToContainer from plone.supermodel import model from plone.z3cform.interfaces import IDeferSecurityCheck -from Products.statusmessages.interfaces import IStatusMessage from z3c.form import field, form, button from z3c.form.contentprovider import ContentProviders from z3c.form.interfaces import IFieldsAndContentProvidersForm, \ - HIDDEN_MODE, DISPLAY_MODE + DISPLAY_MODE from zope.component import getUtility, queryAdapter from zope.component.hooks import getSite from zope.contentprovider.interfaces import IContentProvider from zope.event import notify from zope.i18n import Message from zope.interface import alsoProvides -from zope.interface import implementer from zope.interface import implements, Interface -from zope.interface import provider from zope.publisher.browser import BrowserView @@ -125,7 +124,7 @@ def add_contact_infos(self, widget): 'position': related_to.Title()}) label = custom_settings.label_for_portal_type(type_name) url += '?oform.widgets.%s=%s' % (related_to.portal_type, - '/'.join(related_to.getPhysicalPath())) + '/'.join(related_to.getPhysicalPath())) action = {'url': url, 'label': label, @@ -142,7 +141,7 @@ def add_contact_infos(self, widget): 'url': url, 'label': label, 'prelabel': prelabel, - } + } actions.append(action) else: if len(portal_types) == 2 and \ @@ -168,7 +167,8 @@ def add_contact_infos(self, widget): return {'actions': actions, 'close_on_click': close_on_click, 'formatItem': """function(row, idx, count, value) { -return ' ' + row[1] }""" % (getSite().absolute_url()) +return ' ' + row[1] }""" % ( + getSite().absolute_url()) } @@ -271,59 +271,57 @@ def render(self): }); """ % (str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower(), - getSite().absolute_url(), - getSite().absolute_url(), - ) + getSite().absolute_url(), + getSite().absolute_url(), + ) class IAddHeldPosition(model.Schema): - """Schema to add held position Organization and person fields are required.""" organization = ContactChoice( - title=_(u"Organization"), - required=True, - description=_(u"Select the organization where the person holds the position"), - source=ContactSourceBinder(portal_type="organization")) + title=_(u"Organization"), + required=True, + description=_(u"Select the organization where the person holds the position"), + source=ContactSourceBinder(portal_type="organization")) person = ContactChoice( - title=_(u"Person"), - description=_(u"Select the person who holds the position"), - required=True, - source=ContactSourceBinder(portal_type="person")) + title=_(u"Person"), + description=_(u"Select the person who holds the position"), + required=True, + source=ContactSourceBinder(portal_type="person")) position = ContactChoice( - title=_(u"Position"), - required=False, - description=_(u"Select the position held by this person in the selected organization"), - source=ContactSourceBinder(portal_type="position")) + title=_(u"Position"), + required=False, + description=_(u"Select the position held by this person in the selected organization"), + source=ContactSourceBinder(portal_type="position")) class IAddContact(model.Schema): - """Schema to add held position, person or organization Fields are not required.""" organization = ContactChoice( - title=_(u"Organization"), - required=False, - description=_(u"Select the organization where the person holds the position"), - source=ContactSourceBinder(portal_type="organization")) + title=_(u"Organization"), + required=False, + description=_(u"Select the organization where the person holds the position"), + source=ContactSourceBinder(portal_type="organization")) person = ContactChoice( - title=_(u"Person"), - description=_(u"Select the person who holds the position"), - required=False, - source=ContactSourceBinder(portal_type="person")) + title=_(u"Person"), + description=_(u"Select the person who holds the position"), + required=False, + source=ContactSourceBinder(portal_type="person")) position = ContactChoice( - title=_(u"Position"), - required=False, - description=_(u"Select the position held by this person in the selected organization"), - source=ContactSourceBinder(portal_type="position")) + title=_(u"Position"), + required=False, + description=_(u"Select the position held by this person in the selected organization"), + source=ContactSourceBinder(portal_type="position")) class AddContact(DefaultAddForm, form.AddForm): @@ -339,7 +337,7 @@ class AddContact(DefaultAddForm, form.AddForm): """ implements(IFieldsAndContentProvidersForm) contentProviders = ContentProviders(['organization-ms']) -# contentProviders['organization-ms'] = MasterSelectAddContactProvider + # contentProviders['organization-ms'] = MasterSelectAddContactProvider contentProviders['organization-ms'].position = -1 label = _(u"Create ${name}", mapping={'name': _(u"Contact")}) description = _(u"A contact is a position held by a person in an organization") @@ -440,7 +438,6 @@ def add(self, obj): class AddHeldPosition(AddContact): - """Add an held position.""" schema = IAddHeldPosition @@ -450,7 +447,7 @@ class AddContactFromOrganization(AddContact): def updateWidgets(self): if 'oform.widgets.organization' not in self.request.form: self.request.form['oform.widgets.organization'] = '/'.join( - self.context.getPhysicalPath()) + self.context.getPhysicalPath()) super(AddContactFromOrganization, self).updateWidgets() @@ -459,11 +456,11 @@ 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()) + organization.getPhysicalPath()) if 'oform.widgets.position' not in self.request.form: self.request.form['oform.widgets.position'] = '/'.join( - self.context.getPhysicalPath()) + self.context.getPhysicalPath()) super(AddContactFromPosition, self).updateWidgets() @@ -480,9 +477,9 @@ class AddOrganization(form.AddForm): def updateWidgets(self): super(AddOrganization, self).updateWidgets() self.widgets['organization'].label = _( - 'help_add_organization_or_position_organization', - "Please fill the organization first " - "and then eventually select position") + 'help_add_organization_or_position_organization', + "Please fill the organization first " + "and then eventually select position") @button.buttonAndHandler(_('Add'), name='save') def handleAdd(self, action): diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index a56eb838..2fb8c74c 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -1,7 +1,6 @@ @@ -78,7 +77,7 @@ @@ -168,7 +167,7 @@ Date: Tue, 22 Jan 2019 21:25:46 +0100 Subject: [PATCH 035/144] flake8 --- src/collective/contact/core/browser/addcontact.py | 9 +++++---- src/collective/contact/core/content/organization.py | 1 - src/collective/contact/core/content/position.py | 1 - src/collective/contact/core/subscribers.py | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 40b9708c..36d4d7e8 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -270,10 +270,11 @@ def render(self): }); -""" % (str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower(), - getSite().absolute_url(), - getSite().absolute_url(), - ) +""" % ( + str(bool(getattr(self.__parent__.form, 'schema', None) == IAddHeldPosition)).lower(), + getSite().absolute_url(), + getSite().absolute_url(), + ) class IAddHeldPosition(model.Schema): diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index 6cebaea4..c4d9a32b 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -2,7 +2,6 @@ from collective.contact.core import _ from collective.contact.core import logger from collective.contact.core.browser.contactable import Contactable -from collective.contact.core.content.held_position import IHeldPosition from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent diff --git a/src/collective/contact/core/content/position.py b/src/collective/contact/core/content/position.py index 2cbb92db..217adfa9 100644 --- a/src/collective/contact/core/content/position.py +++ b/src/collective/contact/core/content/position.py @@ -2,7 +2,6 @@ from collective.contact.core import _ from collective.contact.core import logger from collective.contact.core.browser.contactable import Contactable -from collective.contact.core.content.held_position import IHeldPosition from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index 6b409cef..8e19a8e1 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -11,7 +11,6 @@ except ImportError: from zope.interface import Interface - class IReferenceable(Interface): pass From 067e67743086ff9bce89cc3f13e28ff6e52b626f Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 22 Jan 2019 21:26:01 +0100 Subject: [PATCH 036/144] plone 5 buildout --- base.cfg | 2 +- bootstrap.py | 78 ++++++++++++++++++++++++++++++++++++--------------- checkouts.cfg | 2 +- versions.cfg | 3 -- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/base.cfg b/base.cfg index badef9d1..7735f60b 100644 --- a/base.cfg +++ b/base.cfg @@ -2,7 +2,7 @@ package-name = collective.contact.core package-extras = [test] extends = - https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg + https://raw.github.com/collective/buildout.plonetest/master/test-5.1.x.cfg https://raw.github.com/collective/buildout.plonetest/master/qa.cfg sources.cfg checkouts.cfg diff --git a/bootstrap.py b/bootstrap.py index ed57894b..1f59b213 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -25,7 +25,10 @@ from optparse import OptionParser -tmpeggs = tempfile.mkdtemp() +__version__ = '2015-07-01' +# See zc.buildout's changelog if this version is up to date. + +tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] @@ -35,18 +38,19 @@ Simply run this script in a directory containing a buildout.cfg, using the Python that you want bin/buildout to use. -Note that by using --find-links to point to local resources, you can keep +Note that by using --find-links to point to local resources, you can keep this script from going over the network. ''' parser = OptionParser(usage=usage) -parser.add_option("-v", "--version", help="use a specific zc.buildout version") - +parser.add_option("--version", + action="store_true", default=False, + help=("Return bootstrap.py version.")) parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, - help=("Normally, if you do not specify a --version, the " - "bootstrap script and buildout gets the newest " + help=("Normally, if you do not specify a --buildout-version, " + "the bootstrap script and buildout gets the newest " "*final* versions of zc.buildout and its recipes and " "extensions for you. If you use this flag, " "bootstrap and buildout will get the newest releases " @@ -59,36 +63,57 @@ parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) - +parser.add_option("--buildout-version", + help="Use a specific zc.buildout version") +parser.add_option("--setuptools-version", + help="Use a specific setuptools version") +parser.add_option("--setuptools-to-dir", + help=("Allow for re-use of existing directory of " + "setuptools versions")) options, args = parser.parse_args() +if options.version: + print("bootstrap.py version %s" % __version__) + sys.exit(0) + ###################################################################### # load/install setuptools try: - if options.allow_site_packages: - import setuptools - import pkg_resources from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} -exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) +if os.path.exists('ez_setup.py'): + exec(open('ez_setup.py').read(), ez) +else: + exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages - # this will remove them from the path to ensure that incompatible versions + # this will remove them from the path to ensure that incompatible versions # of setuptools are not in the path import site - # inside a virtualenv, there is no 'getsitepackages'. + # inside a virtualenv, there is no 'getsitepackages'. # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): - sys.path[:] = [x for x in sys.path if sitepackage_path not in x] + # Strip all site-packages directories from sys.path that + # are not sys.prefix; this is because on Windows + # sys.prefix is a site-package directory. + if sitepackage_path != sys.prefix: + sys.path[:] = [x for x in sys.path + if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) + +if options.setuptools_version is not None: + setup_args['version'] = options.setuptools_version +if options.setuptools_to_dir is not None: + setup_args['to_dir'] = options.setuptools_to_dir + ez['use_setuptools'](**setup_args) import setuptools import pkg_resources @@ -104,7 +129,12 @@ ws = pkg_resources.working_set +setuptools_path = ws.find( + pkg_resources.Requirement.parse('setuptools')).location + +# Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', + 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] @@ -117,21 +147,23 @@ if find_links: cmd.extend(['-f', find_links]) -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - requirement = 'zc.buildout' -version = options.version +version = options.buildout_version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index _final_parts = '*final-', '*final' def _final_version(parsed_version): - for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): - return False - return True + try: + return not parsed_version.is_prerelease + except AttributeError: + # Older setuptools + for part in parsed_version: + if (part[:1] == '*') and (part not in _final_parts): + return False + return True + index = setuptools.package_index.PackageIndex( search_path=[setuptools_path]) if find_links: @@ -156,7 +188,7 @@ def _final_version(parsed_version): cmd.append(requirement) import subprocess -if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: +if subprocess.call(cmd) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) diff --git a/checkouts.cfg b/checkouts.cfg index 787d8288..6309006d 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -1,6 +1,6 @@ [buildout] extends = - https://raw.github.com/plone/buildout.coredev/4.3/sources.cfg + https://raw.github.com/plone/buildout.coredev/5.1/sources.cfg always-checkout = force auto-checkout += plone.formwidget.masterselect diff --git a/versions.cfg b/versions.cfg index ffcbc4a9..c6316f80 100644 --- a/versions.cfg +++ b/versions.cfg @@ -5,9 +5,6 @@ ecreall.helpers.upgrade = 1.3 ipdb = 0.8.1 ipython = 3.0.0 mock = 1.0.1 -plone.api = 1.4.11 -plone.app.locales = 4.3.7 -plone.formwidget.datetime = 1.2 setuptools = vobject = 0.8.1c zc.buildout = From d10dabfd9cf6d9cdf2d11f3c60e325a29fd8f2f9 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 24 Jan 2019 09:32:00 +0100 Subject: [PATCH 037/144] fix tests for plone 5 --- src/collective/contact/core/setuphandlers.py | 75 +++++++++++-------- src/collective/contact/core/testing.py | 47 +++++++----- .../contact/core/tests/test_adapters.py | 19 ++--- .../contact/core/tests/test_content_types.py | 11 +-- .../contact/core/tests/test_search.py | 13 ++-- .../contact/core/tests/test_setup.py | 9 ++- .../contact/core/tests/test_utils.py | 8 +- .../contact/core/tests/test_views.py | 3 + 8 files changed, 109 insertions(+), 76 deletions(-) diff --git a/src/collective/contact/core/setuphandlers.py b/src/collective/contact/core/setuphandlers.py index e44f185c..97fe16ce 100644 --- a/src/collective/contact/core/setuphandlers.py +++ b/src/collective/contact/core/setuphandlers.py @@ -5,6 +5,7 @@ # # GNU General Public License (GPL) # +from zope.lifecycleevent import modified __docformat__ = 'plaintext' @@ -19,6 +20,7 @@ # from plone.registry.interfaces import IRegistry import logging + logger = logging.getLogger('collective.contact.core: setuphandlers') from collective.contact.core.interfaces import IContactCoreParameters @@ -73,31 +75,31 @@ def create_test_contact_data(portal): {'name': u'Regiment', 'token': u'regiment'}, {'name': u'Squad', 'token': u'squad'}, ] -# Examples structure -# ------------------ -# organizations (* = organization, £ = position) -# * Armée de terre -# * Corps A -# * Division Alpha -# * Régiment H -# * Brigade LH -# £ Sergent -# £ Capitaine -# * Division Beta -# * Corps B -# £ Général -# -# persons (> = person, @ = held_position) -# > De Gaulle -# @ Armée de terre -# @ Général -# > Pepper -# @ Sergent -# > Rambo -# @ Brigade LH -# > Draper -# @ Capitaine -# @ Division Beta + # Examples structure + # ------------------ + # organizations (* = organization, £ = position) + # * Armée de terre + # * Corps A + # * Division Alpha + # * Régiment H + # * Brigade LH + # £ Sergent + # £ Capitaine + # * Division Beta + # * Corps B + # £ Général + # + # persons (> = person, @ = held_position) + # > De Gaulle + # @ Armée de terre + # @ Général + # > Pepper + # @ Sergent + # > Rambo + # @ Brigade LH + # > Draper + # @ Capitaine + # @ Division Beta params = {'title': u"Military directory", 'position_types': position_types, @@ -123,7 +125,6 @@ def create_test_contact_data(portal): 'website': 'www.charles-de-gaulle.org' } mydirectory.invokeFactory('person', 'degaulle', **params) - degaulle = mydirectory['degaulle'] params = {'lastname': u'Pepper', 'gender': u'M', @@ -137,7 +138,6 @@ def create_test_contact_data(portal): 'website': 'http://www.stephen-pepper.org' } mydirectory.invokeFactory('person', 'pepper', **params) - pepper = mydirectory['pepper'] params = {'lastname': u'Rambo', 'firstname': u'John', @@ -145,7 +145,6 @@ def create_test_contact_data(portal): 'use_parent_address': True, } mydirectory.invokeFactory('person', 'rambo', **params) - rambo = mydirectory['rambo'] params = {'lastname': u'Draper', 'firstname': u'John', @@ -154,7 +153,6 @@ def create_test_contact_data(portal): } mydirectory.invokeFactory('person', 'draper', **params) - draper = mydirectory['draper'] params = {'title': u"Armée de terre", 'organization_type': u'army', @@ -199,7 +197,6 @@ def create_test_contact_data(portal): corpsa.invokeFactory('organization', 'divisionbeta', **params) divisionalpha = corpsa['divisionalpha'] - divisionbeta = corpsa['divisionbeta'] params = {'title': u"Régiment H", 'organization_type': u'regiment', @@ -237,7 +234,6 @@ def create_test_contact_data(portal): 'use_parent_address': True, } divisionalpha.invokeFactory('position', 'capitaine_alpha', **params) - capitaine_alpha = divisionalpha['capitaine_alpha'] params = {'title': u"Sergent de la brigade LH", 'position_type': u'sergeant', @@ -247,15 +243,30 @@ def create_test_contact_data(portal): 'use_parent_address': True, } brigadelh.invokeFactory('position', 'sergent_lh', **params) - sergent_lh = brigadelh['sergent_lh'] + +def create_test_held_positions(portal): + mydirectory = portal['mydirectory'] + armeedeterre = mydirectory['armeedeterre'] intids = component.getUtility(IIntIds) + degaulle = mydirectory['degaulle'] + rambo = mydirectory['rambo'] + draper = mydirectory['draper'] + corpsa = armeedeterre['corpsa'] + divisionalpha = corpsa['divisionalpha'] + divisionbeta = corpsa['divisionbeta'] + capitaine_alpha = divisionalpha['capitaine_alpha'] + regimenth = divisionalpha['regimenth'] + brigadelh = regimenth['brigadelh'] + sergent_lh = brigadelh['sergent_lh'] + pepper = mydirectory['pepper'] params = {'start_date': datetime.date(1940, 5, 25), 'end_date': datetime.date(1970, 11, 9), 'position': RelationValue(intids.getId(armeedeterre)), } degaulle.invokeFactory('held_position', 'adt', **params) + modified(degaulle['adt']) general_adt = armeedeterre['general_adt'] params = {'start_date': datetime.date(1940, 5, 25), diff --git a/src/collective/contact/core/testing.py b/src/collective/contact/core/testing.py index 6955a8d2..f5892d3c 100644 --- a/src/collective/contact/core/testing.py +++ b/src/collective/contact/core/testing.py @@ -1,43 +1,56 @@ # -*- coding: utf8 -*- -from plone.app.testing import PloneWithPackageLayer -from plone.app.testing import IntegrationTesting -from plone.app.testing import FunctionalTesting -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID +import collective.contact.core +from collective.contact.core.setuphandlers import create_test_contact_data +import pkg_resources from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE - +from plone.app.testing import FunctionalTesting +from plone.app.testing import IntegrationTesting +from plone.app.testing import PloneWithPackageLayer +from plone.app.testing import TEST_USER_ID +from plone.app.testing import setRoles from plone.testing import z2 -import collective.contact.core +try: + pkg_resources.get_distribution('plone.app.contenttypes') +except pkg_resources.DistributionNotFound: + HAS_PA_CONTENTTYPES = False +else: + HAS_PA_CONTENTTYPES = True class ContactContentLayer(PloneWithPackageLayer): def setUpPloneSite(self, portal): + super(ContactContentLayer, self).setUpPloneSite(portal) + assert portal.portal_quickinstaller.isProductInstalled('collective.contact.core') + + # Plone 5 support + if HAS_PA_CONTENTTYPES: + self.applyProfile(portal, 'plone.app.contenttypes:default') + self.applyProfile(portal, 'collective.contact.core:testing') - # insert some test data - self.applyProfile(portal, 'collective.contact.core:test_data') + # # insert some test data + # self.applyProfile(portal, 'collective.contact.core:test_data') setRoles(portal, TEST_USER_ID, ['Manager']) + create_test_contact_data(portal) + # transaction.commit() + assert portal.portal_quickinstaller.isProductInstalled('collective.contact.core') -COLLECTIVE_CONTACT_CORE = ContactContentLayer( +FIXTURE = ContactContentLayer( zcml_package=collective.contact.core, zcml_filename='testing.zcml', gs_profile_id='collective.contact.core:testing', - name="COLLECTIVE_CONTACT_CORE") + name="FIXTURE") INTEGRATION = IntegrationTesting( - bases=(COLLECTIVE_CONTACT_CORE, ), + bases=(FIXTURE,), name="INTEGRATION") -FUNCTIONAL = FunctionalTesting( - bases=(COLLECTIVE_CONTACT_CORE, ), - name="FUNCTIONAL") - ACCEPTANCE = FunctionalTesting( - bases=(COLLECTIVE_CONTACT_CORE, + bases=(FIXTURE, AUTOLOGIN_LIBRARY_FIXTURE, z2.ZSERVER_FIXTURE), name="ACCEPTANCE") diff --git a/src/collective/contact/core/tests/test_adapters.py b/src/collective/contact/core/tests/test_adapters.py index 4ea932b0..2ff8f422 100644 --- a/src/collective/contact/core/tests/test_adapters.py +++ b/src/collective/contact/core/tests/test_adapters.py @@ -2,17 +2,17 @@ import datetime import unittest -from zope.intid.interfaces import IIntIds -from zope.component import getUtility +from collective.contact.core.interfaces import IVCard, IPersonHeldPositions, \ + IContactable, IContactCoreParameters +from collective.contact.core.setuphandlers import create_test_held_positions +from collective.contact.core.testing import INTEGRATION + +from ecreall.helpers.testing.base import BaseTest from plone import api from plone.app.testing.interfaces import TEST_USER_NAME from z3c.relationfield.relation import RelationValue - -from ecreall.helpers.testing.base import BaseTest - -from collective.contact.core.testing import INTEGRATION -from collective.contact.core.interfaces import IVCard, IPersonHeldPositions,\ - IContactable, IContactCoreParameters +from zope.component import getUtility +from zope.intid.interfaces import IIntIds class TestAdapters(unittest.TestCase, BaseTest): @@ -23,6 +23,7 @@ class TestAdapters(unittest.TestCase, BaseTest): def setUp(self): super(TestAdapters, self).setUp() self.portal = self.layer['portal'] + create_test_held_positions(self.portal) self.directory = self.portal['mydirectory'] self.degaulle = self.directory['degaulle'] self.pepper = self.directory['pepper'] @@ -97,7 +98,7 @@ def test_person_held_positions(self): self.assertEqual(adapter.get_main_position(), self.degaulle.president) self.assertEqual(adapter.get_current_positions(), (self.degaulle.president, - self.degaulle.gadt, )) + self.degaulle.gadt,)) self.assertEqual(adapter.get_sorted_positions(), (self.degaulle.president, self.degaulle.gadt, diff --git a/src/collective/contact/core/tests/test_content_types.py b/src/collective/contact/core/tests/test_content_types.py index b0d3131a..3209124e 100644 --- a/src/collective/contact/core/tests/test_content_types.py +++ b/src/collective/contact/core/tests/test_content_types.py @@ -1,16 +1,16 @@ # -*- coding: utf8 -*- -import unittest - import datetime - -from ecreall.helpers.testing.base import BaseTest +import unittest from collective.contact.core.interfaces import IContactCoreParameters +from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION + +from ecreall.helpers.testing.base import BaseTest from plone import api -from plone.app.testing.interfaces import TEST_USER_ID, TEST_USER_NAME from plone.app.testing.helpers import setRoles +from plone.app.testing.interfaces import TEST_USER_ID, TEST_USER_NAME class TestContentTypes(unittest.TestCase, BaseTest): @@ -21,6 +21,7 @@ class TestContentTypes(unittest.TestCase, BaseTest): def setUp(self): super(TestContentTypes, self).setUp() self.portal = self.layer['portal'] + create_test_held_positions(self.portal) self.mydirectory = self.portal['mydirectory'] self.degaulle = self.mydirectory['degaulle'] self.pepper = self.mydirectory['pepper'] diff --git a/src/collective/contact/core/tests/test_search.py b/src/collective/contact/core/tests/test_search.py index 71ca2fe8..aa89468a 100644 --- a/src/collective/contact/core/tests/test_search.py +++ b/src/collective/contact/core/tests/test_search.py @@ -3,14 +3,14 @@ import datetime import unittest -from plone import api - -from ecreall.helpers.testing.base import BaseTest - -from collective.contact.core.testing import INTEGRATION from collective.contact.core.indexers import ( held_position_searchable_text, organization_searchable_text, person_sortable_title, held_position_sortable_title, start_date, end_date) +from collective.contact.core.setuphandlers import create_test_held_positions +from collective.contact.core.testing import INTEGRATION + +from ecreall.helpers.testing.base import BaseTest +from plone import api class TestSearch(unittest.TestCase, BaseTest): @@ -21,6 +21,7 @@ class TestSearch(unittest.TestCase, BaseTest): def setUp(self): super(TestSearch, self).setUp() self.portal = self.layer['portal'] + create_test_held_positions(self.portal) self.mydirectory = self.portal['mydirectory'] self.degaulle = self.mydirectory['degaulle'] self.pepper = self.mydirectory['pepper'] @@ -47,7 +48,7 @@ def test_indexers(self): held_position_searchable_text(sergent_pepper)(), (u"Mister Pepper Sergent de la brigade LH Armée de terre Corps A " u"Division Alpha Régiment H Brigade LH sgt.pepper@armees.fr") - ) + ) pepper = self.pepper self.assertEqual(person_sortable_title(pepper)(), "pepper") diff --git a/src/collective/contact/core/tests/test_setup.py b/src/collective/contact/core/tests/test_setup.py index 03470273..b4983baa 100644 --- a/src/collective/contact/core/tests/test_setup.py +++ b/src/collective/contact/core/tests/test_setup.py @@ -10,6 +10,7 @@ class TestSetup(unittest.TestCase): layer = INTEGRATION def setUp(self): + super(TestSetup, self).setUp() self.app = self.layer['app'] self.portal = self.layer['portal'] self.qi_tool = api.portal.get_tool('portal_quickinstaller') @@ -18,7 +19,7 @@ def test_product_is_installed(self): """ Validate that our products GS profile has been run and the product installed """ - pid = 'collective.contact.core' - installed = [p['id'] for p in self.qi_tool.listInstalledProducts()] - self.assertTrue(pid in installed, - 'package appears not to have been installed') + self.assertTrue(self.qi_tool.isProductInstalled('collective.contact.core')) + + def test_test_data_created(self): + self.assertTrue('mydirectory' in self.portal) diff --git a/src/collective/contact/core/tests/test_utils.py b/src/collective/contact/core/tests/test_utils.py index 7da4b679..5535981e 100644 --- a/src/collective/contact/core/tests/test_utils.py +++ b/src/collective/contact/core/tests/test_utils.py @@ -1,21 +1,23 @@ # -*- coding: utf8 -*- +import unittest + +from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION from collective.contact.core.utils import get_gender_and_number + from ecreall.helpers.testing.base import BaseTest from plone.app.testing.interfaces import TEST_USER_NAME -import unittest - class TestUtils(unittest.TestCase, BaseTest): - layer = INTEGRATION def setUp(self): super(TestUtils, self).setUp() self.app = self.layer['app'] self.portal = self.layer['portal'] + create_test_held_positions(self.portal) mydirectory = self.portal['mydirectory'] self.degaulle = mydirectory['degaulle'] self.pepper = mydirectory['pepper'] diff --git a/src/collective/contact/core/tests/test_views.py b/src/collective/contact/core/tests/test_views.py index 9b9629b1..647b2e23 100644 --- a/src/collective/contact/core/tests/test_views.py +++ b/src/collective/contact/core/tests/test_views.py @@ -1,6 +1,8 @@ # -*- coding: utf8 -*- import unittest +from collective.contact.core.setuphandlers import create_test_held_positions + from plone.app.testing.interfaces import TEST_USER_NAME from ecreall.helpers.testing.base import BaseTest @@ -18,6 +20,7 @@ def setUp(self): self.login(TEST_USER_NAME) self.app = self.layer['app'] self.portal = self.layer['portal'] + create_test_held_positions(self.portal) mydirectory = self.portal['mydirectory'] self.degaulle = mydirectory['degaulle'] self.adt = self.degaulle['adt'] From d4ed369a2c8cca099b868e49f95a33bf2eeef9b9 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 24 Jan 2019 13:53:03 +0100 Subject: [PATCH 038/144] upgrade travis to plone 5.1 --- setup.py | 1 + travis.cfg | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 801cf0ee..82bd3626 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ "Framework :: Plone :: 4.2", "Framework :: Plone :: 4.3", "Framework :: Plone :: 5.0", + "Framework :: Plone :: 5.1", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", diff --git a/travis.cfg b/travis.cfg index d253aa19..fc4620d1 100644 --- a/travis.cfg +++ b/travis.cfg @@ -3,10 +3,10 @@ allow-hosts += code.google.com robotframework.googlecode.com extends = - https://raw.github.com/collective/buildout.plonetest/master/travis-4.3.x.cfg + https://raw.github.com/collective/buildout.plonetest/master/travis-5.1.x.cfg base.cfg parts = download install test coverage-sh createcoverage [versions] # Temporary set to avoid unified installer download error -Plone = 4.3.17 +Plone = 5.1.4 From 250044bb3ce63b899132d60549cf5a5a3763fbd3 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 25 Jan 2019 15:10:56 +0100 Subject: [PATCH 039/144] always allow adding held_position --- .../contact/core/browser/addcontact.py | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 36d4d7e8..cccf9ac7 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -74,38 +74,48 @@ def add_url_for_portal_type(self, directory_url, portal_type): url = '%s/++add++%s' % (directory_url, portal_type) return url + def get_directory(self): + catalog = api.portal.get_tool('portal_catalog') + results = catalog.searchResults(portal_type='directory') + if len(results) == 0: + return None + else: + return results[0].getObject() + def add_contact_infos(self, widget): source = widget.bound_source criteria = source.selectable_filter.criteria addlink_enabled = widget.field.addlink - portal_types = criteria.get('portal_type', []) + field_portal_types = criteria.get('portal_type', []) - catalog = api.portal.get_tool('portal_catalog') - results = catalog.unrestrictedSearchResults(portal_type='directory') actions = [] - if len(results) == 0: + directory = self.get_directory() + if not directory: addlink_enabled = False else: - directory = results[0].getObject() sm = getSecurityManager() if not sm.checkPermission("Add portal content", directory): addlink_enabled = False - allowed_types = api.portal.get_tool('portal_types').directory.allowed_content_types - portal_types = [p for p in portal_types if p in allowed_types] + allowed_directory_types = api.portal.get_tool('portal_types').directory.allowed_content_types + allowed_portal_types = set(p for p in field_portal_types if p in allowed_directory_types) constrains = IConstrainTypes(directory, None) if constrains: - portal_types = [p for p in portal_types if p in constrains.getLocallyAllowedTypes()] + allowed_portal_types = set(p for p in allowed_portal_types if p in constrains.getLocallyAllowedTypes()) + + if 'held_position' in field_portal_types: + # held position is always allowed because it has a special wizard that creates organization and person + allowed_portal_types.add('held_position') - if len(portal_types) == 0: + if len(allowed_portal_types) == 0: addlink_enabled = False close_on_click = True if addlink_enabled: custom_settings = queryAdapter(directory, ICustomSettings, default=self) directory_url = directory.absolute_url() - if len(portal_types) == 1: - portal_type = portal_types[0] + if len(allowed_portal_types) == 1: + portal_type = list(allowed_portal_types)[0] prelabel = custom_settings.prelabel_for_portal_type(portal_type) if portal_type == 'held_position' and not IPerson.providedBy(widget.context): url = "%s/@@add-held-position" % directory_url @@ -144,9 +154,7 @@ def add_contact_infos(self, widget): } actions.append(action) else: - if len(portal_types) == 2 and \ - 'organization' in portal_types and \ - 'position' in portal_types: + if allowed_portal_types == {'organization', 'person'}: url = "%s/@@add-organization" % directory_url type_name = _(u"organization/position") else: @@ -155,7 +163,7 @@ def add_contact_infos(self, widget): close_on_click = False label = custom_settings.label_for_portal_type(type_name) - prelabel = custom_settings.prelabel_for_portal_type(portal_types) + prelabel = custom_settings.prelabel_for_portal_type(allowed_portal_types) action = {'url': url, 'klass': 'addnew', 'label': label, From c753a9a1250e4ef090c7d420256c8fde3eb5c1c1 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 25 Jan 2019 15:11:21 +0100 Subject: [PATCH 040/144] upgrade: reimport types --- src/collective/contact/core/profiles/default/metadata.xml | 2 +- src/collective/contact/core/upgrades/configure.zcml | 8 ++++++++ src/collective/contact/core/upgrades/upgrades.py | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/profiles/default/metadata.xml b/src/collective/contact/core/profiles/default/metadata.xml index 7d2e497f..a173eb2f 100644 --- a/src/collective/contact/core/profiles/default/metadata.xml +++ b/src/collective/contact/core/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 13 + 14 profile-collective.contact.widget:default profile-plone.app.dexterity:default diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index 483997a0..f8fce4ed 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -141,4 +141,12 @@ handler=".upgrades.v13" profile="collective.contact.core:default" /> + + diff --git a/src/collective/contact/core/upgrades/upgrades.py b/src/collective/contact/core/upgrades/upgrades.py index 0c84f750..0b59cea3 100644 --- a/src/collective/contact/core/upgrades/upgrades.py +++ b/src/collective/contact/core/upgrades/upgrades.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent @@ -105,3 +104,7 @@ def v13(context): obj = brain.getObject() if base_hasattr(obj, 'is_created'): delattr(obj, 'is_created') + + +def v14(context): + IUpgradeTool(context).runImportStep('collective.contact.core', 'typeinfo') From 6a26541ef931e6631826eb20805d7d8d039d4eb9 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 25 Jan 2019 15:12:14 +0100 Subject: [PATCH 041/144] install doc for plone 4 --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 3a9b4700..de209e83 100644 --- a/README.rst +++ b/README.rst @@ -69,6 +69,7 @@ Installation ============ * Add collective.contact.core to your eggs. +* Under Plone 4, set collective.z3cform.datagridfield to 1.2.x * Re-run buildout. * Install the product in your plone site. From 2a48c984ef5f1212200f260e22f25471a41e709f Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 29 Jan 2019 18:20:23 +0100 Subject: [PATCH 042/144] add a note about compatibility with jqueryui --- README.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.rst b/README.rst index de209e83..c61db6e4 100644 --- a/README.rst +++ b/README.rst @@ -73,6 +73,17 @@ Installation * Re-run buildout. * Install the product in your plone site. + +IMPORTANT : Compatibility with collective.js.jqueryui +----------------------------------------------------- + +For now, collective.js.jqueryui is not compatible with plone.formwidget.autocomplete, +which is a dependency of collective.contact.core. +If collective.js.jqueryui is installed, you **must** disable jqueryui autocomplete feature +unless contact widget will not be functionnal. +You can disable the plugin in the JQuery UI configurations settings of site control panel. + + Tests ===== From c103b06efef589c6d7502cca99e0e8ca53606a7f Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 29 Jan 2019 18:20:39 +0100 Subject: [PATCH 043/144] jslint --- src/collective/contact/core/browser/static/forms.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index fd09b98b..8a6e746d 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -1,4 +1,4 @@ -contactswidget = {}; +var contactswidget = {}; /* Update person_title when gender changes (if person_title hasn't been set manually) */ contactswidget.update_person_title = function(genderInput, mapping) { @@ -46,7 +46,7 @@ contactswidget.update_token = function(){ var name = $(this).val(); var token = $(this).closest('tr').find('input[id$="-widgets-token"]'); if (token.val() === '') { - token_value = contactswidget.normalize_string(name); + var token_value = contactswidget.normalize_string(name); token.val(token_value); } }; @@ -165,7 +165,7 @@ $(document).ready(function(){ /* contactswidget.manage_directory(); Do not hide token column in edit mode */ contactswidget.manage_hide_use_parent_address(); - jQuery(document).bind('loadInsideOverlay', + $(document).bind('loadInsideOverlay', function(e, pbajax, responseText, errorText, api){ contactswidget.manage_hide_use_parent_address(); }); From bbab01b771abdc57973349cf0b9b8eaefeca4e08 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 29 Jan 2019 18:21:13 +0100 Subject: [PATCH 044/144] fix broken icon in sub organization --- .../contact/core/browser/templates/suborganizations.pt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/templates/suborganizations.pt b/src/collective/contact/core/browser/templates/suborganizations.pt index 23f3d0fa..6a33aca4 100644 --- a/src/collective/contact/core/browser/templates/suborganizations.pt +++ b/src/collective/contact/core/browser/templates/suborganizations.pt @@ -10,7 +10,7 @@

Organizations in this organization:

    -
  • +
  • From c64c8aa7d39ecf52a8fbeea7dbbf9300f648e2a7 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 29 Jan 2019 18:22:12 +0100 Subject: [PATCH 045/144] install js and css ressources the right way for plone 4 or 5 --- src/collective/contact/core/configure.zcml | 33 +------------------ .../profiles/{default => base}/catalog.xml | 0 .../profiles/{default => base}/metadata.xml | 1 - .../{default => base}/propertiestool.xml | 0 .../profiles/{default => base}/registry.xml | 0 .../profiles/{default => base}/rolemap.xml | 0 .../core/profiles/{default => base}/skins.xml | 0 .../core/profiles/{default => base}/types.xml | 0 .../{default => base}/types/directory.xml | 0 .../{default => base}/types/held_position.xml | 0 .../{default => base}/types/organization.xml | 0 .../{default => base}/types/person.xml | 0 .../{default => base}/types/position.xml | 0 .../profiles/{default => base}/workflows.xml | 0 .../definition.xml | 0 .../collective_contact_core_marker.txt | 0 .../{default => plone4}/cssregistry.xml | 0 .../{default => plone4}/jsregistry.xml | 2 +- .../contact/core/profiles/plone4/metadata.xml | 7 ++++ .../plone5/collective_contact_core_marker.txt | 1 + .../core/profiles/plone5/cssregistry.xml | 4 +++ .../core/profiles/plone5/jsregistry.xml | 4 +++ .../contact/core/profiles/plone5/metadata.xml | 7 ++++ .../contact/core/profiles/plone5/registry.xml | 9 +++++ .../contact/core/upgrades/configure.zcml | 16 +++++++++ .../contact/core/upgrades/upgrades.py | 7 ++++ 26 files changed, 57 insertions(+), 34 deletions(-) rename src/collective/contact/core/profiles/{default => base}/catalog.xml (100%) rename src/collective/contact/core/profiles/{default => base}/metadata.xml (95%) rename src/collective/contact/core/profiles/{default => base}/propertiestool.xml (100%) rename src/collective/contact/core/profiles/{default => base}/registry.xml (100%) rename src/collective/contact/core/profiles/{default => base}/rolemap.xml (100%) rename src/collective/contact/core/profiles/{default => base}/skins.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types/directory.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types/held_position.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types/organization.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types/person.xml (100%) rename src/collective/contact/core/profiles/{default => base}/types/position.xml (100%) rename src/collective/contact/core/profiles/{default => base}/workflows.xml (100%) rename src/collective/contact/core/profiles/{default => base}/workflows/collective_contact_core_workflow/definition.xml (100%) rename src/collective/contact/core/profiles/{default => plone4}/collective_contact_core_marker.txt (100%) rename src/collective/contact/core/profiles/{default => plone4}/cssregistry.xml (100%) rename src/collective/contact/core/profiles/{default => plone4}/jsregistry.xml (96%) create mode 100644 src/collective/contact/core/profiles/plone4/metadata.xml create mode 100644 src/collective/contact/core/profiles/plone5/collective_contact_core_marker.txt create mode 100644 src/collective/contact/core/profiles/plone5/cssregistry.xml create mode 100644 src/collective/contact/core/profiles/plone5/jsregistry.xml create mode 100644 src/collective/contact/core/profiles/plone5/metadata.xml create mode 100644 src/collective/contact/core/profiles/plone5/registry.xml diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index a385d67c..ab7617e8 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -2,7 +2,6 @@ xmlns="http://namespaces.zope.org/zope" xmlns:grok="http://namespaces.zope.org/grok" xmlns:i18n="http://namespaces.zope.org/i18n" - xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="collective.contact.core"> @@ -25,37 +24,7 @@ - - - - - - - - - - - + - - - + + + + + + + + diff --git a/src/collective/contact/core/profiles.zcml b/src/collective/contact/core/profiles.zcml new file mode 100644 index 00000000..78b4c797 --- /dev/null +++ b/src/collective/contact/core/profiles.zcml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index 8e19a8e1..bb817b7b 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -1,25 +1,16 @@ +from collective.contact.core.behaviors import IContactDetails +from collective.contact.core.content.organization import IOrganization +from collective.contact.core.content.person import IPerson +from collective.contact.core.content.position import IPosition +from collective.contact.core.interfaces import IHeldPosition + from five import grok from z3c.form.interfaces import NO_VALUE - from zope.container.contained import ContainerModifiedEvent from zope.lifecycleevent.interfaces import IObjectAddedEvent, \ IObjectModifiedEvent from zope.schema import getFields -try: - from plone.app.referenceablebehavior.referenceable import IReferenceable -except ImportError: - from zope.interface import Interface - - class IReferenceable(Interface): - pass - -from collective.contact.core.behaviors import IContactDetails -from collective.contact.core.content.position import IPosition -from collective.contact.core.content.person import IPerson -from collective.contact.core.content.organization import IOrganization -from collective.contact.core.interfaces import IHeldPosition - # update indexes of related content when a content is modified # you can monkey patch this value if you have an index that needs this indexes_to_update = ['SearchableText'] @@ -74,40 +65,6 @@ def update_related_with_organization(obj, event=None): update_related_with_organization(child) -# def referenceRemoved(obj, event, toInterface=IContactContent): -# """Store information about the removed link integrity reference. -# """ -# # inspired from z3c/relationfield/event.py:breakRelations -# # and plone/app/linkintegrity/handlers.py:referenceRemoved -# # if the object the event was fired on doesn't have a `REQUEST` attribute -# # we can safely assume no direct user action was involved and therefore -# # never raise a link integrity exception... -# request = aq_get(obj, 'REQUEST', None) -# if not request: -# return -# storage = ILinkIntegrityInfo(request) - -# catalog = component.queryUtility(ICatalog) -# intids = component.queryUtility(IIntIds) -# if catalog is None or intids is None: -# return - -# # find all relations that point to us -# obj_id = intids.queryId(obj) -# if obj_id is None: -# return - -# rels = list(catalog.findRelations({'to_id': obj_id})) -# for rel in rels: -# if toInterface.providedBy(rel.to_object): -# storage.addBreach(rel.from_object, rel.to_object) - - -# def referencedObjectRemoved(obj, event): -# if not IReferenceable.providedBy(obj): -# baseReferencedObjectRemoved(obj, event) - - @grok.subscribe(IContactDetails, IObjectModifiedEvent) @grok.subscribe(IContactDetails, IObjectAddedEvent) def clear_fields_use_parent_address(obj, event): From d1302b660b5496e30cfa4e52666fc66b38d9ad33 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Wed, 30 Jan 2019 18:15:32 +0100 Subject: [PATCH 049/144] enable relationchoicehandler for plone 4 cf 390dd3a84be1edd1d68ccc9ae45c6eba0dda8889 on plone 5 it is registered by plone.app.relationfield --- src/collective/contact/core/configure.zcml | 5 ----- src/collective/contact/core/fields.py | 6 ------ src/collective/contact/core/plone4.py | 8 ++++++++ src/collective/contact/core/plone4.zcml | 17 +++++++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 src/collective/contact/core/fields.py diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 0494d5c3..4926bfce 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -29,11 +29,6 @@ - - - + handler=".plone4.referencedObjectRemoved"/> - + handler=".plone4.referenceRemoved"/> + + From bf1065626b21cc6fb64f4ad7d7810662db425321 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 1 Feb 2019 10:24:43 +0100 Subject: [PATCH 050/144] remove test_data profile --- sources.cfg | 6 ++-- src/collective/contact/core/profiles.zcml | 15 ---------- ...llective_contact_core_test_data_marker.txt | 1 - .../profiles/test_data/img/sgt_pepper.jpg | Bin 3681 -> 0 bytes .../core/profiles/test_data/metadata.xml | 7 ----- src/collective/contact/core/setuphandlers.py | 26 +++--------------- 6 files changed, 7 insertions(+), 48 deletions(-) delete mode 100644 src/collective/contact/core/profiles/test_data/collective_contact_core_test_data_marker.txt delete mode 100644 src/collective/contact/core/profiles/test_data/img/sgt_pepper.jpg delete mode 100644 src/collective/contact/core/profiles/test_data/metadata.xml diff --git a/sources.cfg b/sources.cfg index 438bed72..2bb5add9 100644 --- a/sources.cfg +++ b/sources.cfg @@ -12,9 +12,9 @@ entrouvert = git://repos.entrouvert.org entrouvert_push = git+ssh://git@repos.entrouvert.org [sources] -collective.contact.core = git ${remotes:collective}/collective.contact.core.git pushurl=${remotes:collective_push}/collective.contact.core.git -collective.contact.facetednav = git ${remotes:collective}/collective.contact.facetednav.git pushurl=${remotes:collective_push}/collective.contact.facetednav.git -collective.contact.widget = git ${remotes:collective}/collective.contact.widget.git pushurl=${remotes:collective_push}/collective.contact.widget.git +collective.contact.core = git ${remotes:collective}/collective.contact.core.git pushurl=${remotes:collective_push}/collective.contact.core.git branch=plone5 +collective.contact.facetednav = git ${remotes:collective}/collective.contact.facetednav.git pushurl=${remotes:collective_push}/collective.contact.facetednav.git branch=plone5 +collective.contact.widget = git ${remotes:collective}/collective.contact.widget.git pushurl=${remotes:collective_push}/collective.contact.widget.git branch=plone5 plone.formwidget.masterselect = git ${remotes:collective}/plone.formwidget.masterselect.git pushurl=${remotes:collective_push}/plone.formwidget.masterselect.git ecreall.helpers.upgrade = git ${remotes:tdesvenain}/ecreall.helpers.upgrade.git pushurl=${remotes:tdesvenain_push}/ecreall.helpers.upgrade.git collective.excelexport = git ${remotes:collective}/collective.excelexport.git pushurl=${remotes:collective_push}/collective.excelexport.git diff --git a/src/collective/contact/core/profiles.zcml b/src/collective/contact/core/profiles.zcml index 78b4c797..8c778a05 100644 --- a/src/collective/contact/core/profiles.zcml +++ b/src/collective/contact/core/profiles.zcml @@ -27,19 +27,4 @@ provides="Products.GenericSetup.interfaces.EXTENSION" /> - - - - - diff --git a/src/collective/contact/core/profiles/test_data/collective_contact_core_test_data_marker.txt b/src/collective/contact/core/profiles/test_data/collective_contact_core_test_data_marker.txt deleted file mode 100644 index 8089e33f..00000000 --- a/src/collective/contact/core/profiles/test_data/collective_contact_core_test_data_marker.txt +++ /dev/null @@ -1 +0,0 @@ -Profile marker \ No newline at end of file diff --git a/src/collective/contact/core/profiles/test_data/img/sgt_pepper.jpg b/src/collective/contact/core/profiles/test_data/img/sgt_pepper.jpg deleted file mode 100644 index cb79876e0f38997470dbab8a83d65539b850ba7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3681 zcmb7;_dnH*`^VqMIrcG*)v@v_G-Kb|iGtOmOJx&R0Sg499k0N{Kc&;h8y z5C{ZJeKDx1scC4TbhH;@VPvF-!dTeYU@R~gI~U(2b`Bm+7z{29=i%oU6cl8?BqAmv zAjT&kDDW=?bP=Vcp=G9{V;10maR~gsb^acJ(E&z)2^b^-P{BZ880fqo-~|BiMOhFC z_)ixFAz(VHe@zuufC>Z#Q(g21QPcl>0HOjzs9`j0!T^F@L<>dB;Sj+oDzA-Ar8BSJ z-QyAySJ3e-?3ujCa)bU4{2%pV{~HC-Tv%6N7aRzf7EJx$TM!it07HbS5h%6`tV6^u zwr7PVwXl9tbnko)fPz66g~2f37O-7*6@8uA6XitefqE?`U*Q#KTRyre%y`fE+xb~G`HXne35mMm79o>^mf#vxjwVmgRpMB zxP01_QrV4(!m!ahE)8e4$9LM>WfjH`lZvE>W|wG{#WSI-=o-YRk3xz*Ll?@aSlWQh zHjENul2g-WgMQ?mQ~0=^6zRc;`T15)ZZJDW#nxD^N3>PteJtc!LybfX%{Y(YHGP1cw+=&?&$Okt$_$nBW4dJS3|N@jjyYUE7o}@ zRYZBZE^?+kU=4^$^ZSU+d!<`mz{9YjO_DQ3sUx5BP4+{v#dU*g<6)g8k;#a`AlicI zIG)g_?FD!bvXfaAsqr91lr}sD6ytjW9)V*i&xK%7=!pu6Qgh9E58T)Zky94X#ufSg zoqtvRuMDxNK{A6+{#C^kRsEERe^%NE4yiMt#v?rO>KJ{FY73*JvAi2Ehx%`1Qa!o( zb3b*y_EnqZ^z~+jd9#|PnJx_b-+cq}$_Yw*(yA#ZCcNAe6+`MqJC79;Lv0h#r0ID^ zz4U{_qH71W=Ba6WoL*G0VRM?#Wx2}-75U~Q6C41w*&^gUAxKGEL({8X`uv%Fax&0o zO76oLLqA%-2};v<5c7W4uNmE#h9xdD9o055&8wK^=V#X$4W_`OjD0R>v=U6(w8DJ2YF&^zh5!SU3ej za6&Ff;B{d@0%#;6S!*Ws_87{n{{5DE`@Vc+Sz<}>DgnO)@i|$4h~Ho`EU)@2rE3{o zIs}8fbry+svMW_shx;JLZ@3;sGI_{J2iKN&Zt}FcRFs$F-M$HzzVhh5*6Ny^w+tu` z1AFrowSAnW)icdDGACn?iR2>o4uH+4xPH)Navo3CtA1%tw)fH(S0P(l*UgO6Io(p3h7>76Rz=m-FUXBID2p~m#jBXioY_- z6gXx<9`I5Xjq|yoHmLLImGYqNA-IRY_{)Ra{a?3yO747W-Y`r3k^mkEc@ zx-xuqsp!^=(=Oy!F@Jxv!u>l44YugD-8ZZ{tXe+^Mw~5>qHebhZ_ckaStL~pIxE~A z@lomCaK>H4(CU08F@1;O^|AhXIn`3Dr#a>-?2~?g3>f!py|&YdWaG7!-n_}}?H7X& zw$ool%IJa~4Kg4W0${_yTBHi&p3VGquKZ+u+a27j9N7xKBO!H~jJ*1+e6)^Dsd;;~ z`PvhTA5l^9FdMhnf{81@$lc!4u8j<6moPzu-$=W)z3J^unj&u+R`y+X-&P&gbsb95 zD;CQf-hLgQTn@O_eHTe9G-#ln@_UKcJ4NV9>&1n9(U*Dr=l-o1n3-uARsK!RmM(kD z<{!FUQ-OKm4acT53X!k8_oB)?RvQ-+>v%$Z?gXi8nR6 zdsds^O=I6;2i2d&(ch#^2>9$#w%uS9oyV2JYB1QUv2b(_D1X<@4tXUc<9c?c%j6Dg z3}8zB4A+oqx?>X4XtycjT(!F?fK$v}yImE%+x^rxSXofpnYlw0xyKprI--#AC#3q+ zN=Ad*Z9BD<$qb&RUi^Ue_)w|x?Lsvcg|U;{NwFMQHP52Oq5tgmY)_zxQeM9^xBdyp z9JJ9KRWydIIIG^Zb4AoWItT74{Q5pQ=V4(hQ*~r0k<&;@2Tv&>xtwxl!HHpgz<+M{+6<>F5UC1tSJjem%Pii<|*=H2>UQB6z+Ep7{R{h z*P=c*e#=fN`PmWX(72x==Mb+&$&ay8iQ~y0EDi};%oSvf1<`4z4TQgkd+9--e7UO% z)fQUE%mob=Xh>{DMx0s#DAnLkQP8lM-y!ADhs18P>4iVE@ zuC2EOnfQtFh0(Ihil6C;`smk+587H{SdrZA#Bj0PG#&nM0mRD<()4-|KD#J~fM)Ge zYY=lsB>rfNxD~cPVbrpHOU;Hk`7X+CdrbHo@Xve2Mn7&#WyCRCx5h%wL-JGfgI#J7 z;uvio4yFRAl$l1>O#*syO2k@*?=1f}?F+O_Q822l!_fJb{?L+i+|X9*m$eYzUBsl^_=#2J(7|U$%bzKrTXGg zLR4==0z=CKdMBrIAg6aq(rxhv+sJo;B6l8}oF=2*jEL-P<+97%V8}xJucIv%8-M>F+Xs=P%R%uU$K$R4N`gy&WrRBS_0V;1a#eB38~C^oSTpyNMvo7uXTsET|#i?tu{!j)J;f&lSR6 zytUJ~GW*@!pl#cLOq9wvI%cMOGLT`nmTctg+kx!1=zbBXn$*?SgYs>)-6o}f&vb*u z(?$7ijRm{jI$3797j7?86SmbPA7w<|hwah@Q;UZS^ixgtigs=6R*)R=40P&X9J4P(O3} zzF;N;qcY#Zb(dcG0IxG7H$TOw$!$&+<9{@RvPW70WjSk`8Ckdg+?NJN-W*c&oJ;N4rYg(t;p!ppTvrEjxzgDr67`M zbk#%sC!0Zf8fyO5K`W?x4xe6EQH~;)7^_s~4g*Tdh?i{G<+`TV`Ajh@qK5Q8-%SsG z<*j1@{DuzgNh&7Wt_JQgF(t$TCHVW{1c3$0ujSA{b&vZw&F<1Q2#nyXpf~#BFlqs3 z8BBVh>i;~))+P_e7OBMD1Fd=AZPl!V<19Z%ef zy`p75?skG=&a9?1T!`jxpDt3E7<2L_Z|?NBXed@o9*qj}9aao2ah4SF{?UUGod*I| z3n=b)rCqX1x%sV;_2~!@xueoC*GGlhIkY8E^!^L=gQi*!=a`fa-lsO%MR6PaOyWA` zA2_x-YB*h_La)Jpr1`yHUR8S>Qo9;cSy5b5kUira5__swoTdlvlp-o*HrJ_!FQ5ZN zrwYigEULK3i z%`@3MI;}_-8 zOO7vp`yz51uJ&&xvKa4fO*%20c)!*T34BjGN_|*SZ|ZImK_O&xoz-jb+)3a6SSXo zU?#wCqE_(xjAS`ZpK)kwTyvP;v&}+>->AN5MF&vcCft=lIVPzW^M*@O{L53A`nk^B Kp - - 0001 - - profile-collective.contact.core:default - - diff --git a/src/collective/contact/core/setuphandlers.py b/src/collective/contact/core/setuphandlers.py index 97fe16ce..40eadf10 100644 --- a/src/collective/contact/core/setuphandlers.py +++ b/src/collective/contact/core/setuphandlers.py @@ -1,26 +1,16 @@ # -*- coding: utf-8 -*- -# -# File: setuphandlers.py -# -# # GNU General Public License (GPL) -# -from zope.lifecycleevent import modified - -__docformat__ = 'plaintext' - import datetime +import logging +from plone import api +from z3c.relationfield.relation import RelationValue from zope import component from zope.intid.interfaces import IIntIds +from zope.lifecycleevent import modified -from z3c.relationfield.relation import RelationValue - -from plone import api # from plone.registry.interfaces import IRegistry -import logging - logger = logging.getLogger('collective.contact.core: setuphandlers') from collective.contact.core.interfaces import IContactCoreParameters @@ -307,11 +297,3 @@ def create_test_held_positions(portal): 'use_parent_address': True, } rambo.invokeFactory('held_position', 'brigadelh', **params) - - -def createTestData(context): - """Create test data for collective.contact.core""" - if isNotTestDataProfile(context): - return - portal = context.getSite() - create_test_contact_data(portal) From 493206ce8a7c3cb7209327a4211d5ff0cfe1d0eb Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Mon, 4 Feb 2019 11:08:07 +0100 Subject: [PATCH 051/144] rename base profile: install-base so it is after "default" in alphabetical order --- src/collective/contact/core/profiles.zcml | 2 +- src/collective/contact/core/profiles/plone4/metadata.xml | 2 +- src/collective/contact/core/profiles/plone5/metadata.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/collective/contact/core/profiles.zcml b/src/collective/contact/core/profiles.zcml index 8c778a05..61df783a 100644 --- a/src/collective/contact/core/profiles.zcml +++ b/src/collective/contact/core/profiles.zcml @@ -13,7 +13,7 @@ 15 - profile-collective.contact.core:base + profile-collective.contact.core:install-base diff --git a/src/collective/contact/core/profiles/plone5/metadata.xml b/src/collective/contact/core/profiles/plone5/metadata.xml index 667af66d..e7714196 100644 --- a/src/collective/contact/core/profiles/plone5/metadata.xml +++ b/src/collective/contact/core/profiles/plone5/metadata.xml @@ -2,6 +2,6 @@ 15 - profile-collective.contact.core:base + profile-collective.contact.core:install-base From 6928915ecb295ca3d8d03db6ccba8374598c83c9 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Mon, 4 Feb 2019 11:08:29 +0100 Subject: [PATCH 052/144] fix content filter cf 3b55c59cfd4bed11c4d1a9dd7917e6bc4e288a73 --- src/collective/contact/core/browser/organization.py | 2 +- src/collective/contact/core/browser/position.py | 2 +- src/collective/contact/core/browser/static/forms.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index 82923970..b1abd2cc 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -16,7 +16,7 @@ $(document).ready(function(){ $('.addnewcontactfromorganization').prepOverlay({ subtype: 'ajax', -// filter: common_content_filter, + filter: '#content', formselector: '#oform', cssclass: 'overlay-contact-addnew', closeselector: '[name="oform.buttons.cancel"]', diff --git a/src/collective/contact/core/browser/position.py b/src/collective/contact/core/browser/position.py index c04d45c7..4b5b0799 100644 --- a/src/collective/contact/core/browser/position.py +++ b/src/collective/contact/core/browser/position.py @@ -12,7 +12,7 @@ $(document).ready(function(){ $('.addnewcontactfromposition').prepOverlay({ subtype: 'ajax', -// filter: common_content_filter, + filter: '#content', formselector: '#oform', cssclass: 'overlay-contact-addnew', closeselector: '[name="oform.buttons.cancel"]', diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index 8a6e746d..ab3bd87a 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -172,7 +172,7 @@ $(document).ready(function(){ $('.contactoverlay').prepOverlay({ subtype: 'ajax', -// filter: common_content_filter, + filter: '#content', formselector: '#form', closeselector: '[name="form.buttons.cancel"]', noform: function(el, pbo) {return 'reload';} @@ -180,7 +180,7 @@ $(document).ready(function(){ $('.deleteoverlay').prepOverlay({ subtype: 'ajax', -// filter: common_content_filter, + filter: '#content', formselector: '#delete_confirmation', closeselector: '[name="form.button.Cancel"]', noform: function(el, pbo) {return 'reload';} From fe60a64944159b581da1fb035beec27a9291ae61 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Tue, 5 Feb 2019 10:31:34 +0100 Subject: [PATCH 053/144] use mockup for create contact overlay --- checkouts.cfg | 4 + .../core/browser/templates/organization.pt | 135 ++++++++++-------- 2 files changed, 79 insertions(+), 60 deletions(-) diff --git a/checkouts.cfg b/checkouts.cfg index 6309006d..886143cf 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -6,3 +6,7 @@ auto-checkout += plone.formwidget.masterselect collective.contact.widget collective.excelexport + mockup + +[sources] +mockup = git git@github.com:plone/mockup.git branch=thomasdesvenain diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index 501b3559..293243af 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -3,81 +3,96 @@ xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" - metal:use-macro="context/main_template/macros/master" - i18n:domain="collective.contact.core"> + metal:use-macro="context/main_template/macros/master" + i18n:domain="collective.contact.core">
    -
    -
    +
    +
    -
    - - +
    -
    +
    -
    +
    - + -
    +
    -
    -

    Positions in this organization:

    - +
    -
    +
    - - - - - Create Contact - - - - + + + + + Create + Contact + + + + -
    +
    From 76bdd5ee4242b3ff54573a328298be7db6769be7 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 14 Feb 2019 16:52:09 +0100 Subject: [PATCH 054/144] fix: address is back on organization view --- src/collective/contact/core/browser/contactable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/contactable.py b/src/collective/contact/core/browser/contactable.py index d5dc403d..2e85f6b0 100644 --- a/src/collective/contact/core/browser/contactable.py +++ b/src/collective/contact/core/browser/contactable.py @@ -71,7 +71,7 @@ def update(self): self.contact_details = contactable.get_contact_details() def render_address(self): - return self.address_template() + return self.address_template(self.contact_details['address']) class NoFallbackContactDetails(ContactDetails): From c1e4cce57939c8daf74b98a39165370b48e1e1c6 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 14 Feb 2019 18:43:39 +0100 Subject: [PATCH 055/144] use mockup modal instead of overlay --- .../browser/basefields/templates/person.pt | 8 +++-- .../contact/core/browser/configure.zcml | 2 +- .../contact/core/browser/organization.py | 20 ----------- .../contact/core/browser/position.py | 20 ----------- .../contact/core/browser/static/forms.js | 33 ++++--------------- .../contact/core/browser/templates/address.pt | 2 +- .../core/browser/templates/heldpositions.pt | 10 ++++-- .../core/browser/templates/organization.pt | 1 - .../core/browser/templates/position.pt | 6 ++-- 9 files changed, 24 insertions(+), 78 deletions(-) diff --git a/src/collective/contact/core/browser/basefields/templates/person.pt b/src/collective/contact/core/browser/basefields/templates/person.pt index 38e0100b..6a792635 100644 --- a/src/collective/contact/core/browser/basefields/templates/person.pt +++ b/src/collective/contact/core/browser/basefields/templates/person.pt @@ -7,10 +7,12 @@ i18n:domain="collective.contact.core" tal:omit-tag="">
    - + Edit @@ -36,4 +38,4 @@ tal:on-error="string:Bad signature format" />
    - \ No newline at end of file + diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 2fb8c74c..f18551a3 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -24,7 +24,7 @@ name="view" for="..content.organization.IOrganization" class=".organization.Organization" - allowed_attributes="parent_organizations sub_organizations positions can_add addnew_script" + allowed_attributes="parent_organizations sub_organizations positions can_add" template="templates/organization.pt" permission="zope2.View" /> diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index b1abd2cc..c818e939 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -11,25 +11,6 @@ from Products.Five import BrowserView from plone import api -ADDNEW_OVERLAY = """ - -""" - class Organization(BaseView): @@ -52,7 +33,6 @@ def update(self): self.positions = self.context.get_positions() sm = getSecurityManager() self.can_add = sm.checkPermission('Add portal content', self.context) - self.addnew_script = ADDNEW_OVERLAY def display_date(self, date): """Display date nicely in template.""" diff --git a/src/collective/contact/core/browser/position.py b/src/collective/contact/core/browser/position.py index 4b5b0799..1c328089 100644 --- a/src/collective/contact/core/browser/position.py +++ b/src/collective/contact/core/browser/position.py @@ -7,25 +7,6 @@ from collective.contact.core.interfaces import IContactable -ADDNEW_OVERLAY = """ - -""" - class Position(BaseView): @@ -42,4 +23,3 @@ def update(self): 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/static/forms.js b/src/collective/contact/core/browser/static/forms.js index ab3bd87a..f1a76aba 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -5,7 +5,7 @@ contactswidget.update_person_title = function(genderInput, mapping) { var gender = $(genderInput).val(); var person_title = $('#form-widgets-person_title').val(); var values = Object.values(mapping); - if (person_title === '' || values.indexOf(person_title) !== -1) { + if (person_title === "" || values.indexOf(person_title) !== -1) { $('#form-widgets-person_title').val(mapping[gender]); } }; @@ -44,8 +44,8 @@ contactswidget.serialize_form = function(form) { /* Update the token which matches the input*/ contactswidget.update_token = function(){ var name = $(this).val(); - var token = $(this).closest('tr').find('input[id$="-widgets-token"]'); - if (token.val() === '') { + var token = $(this).closest("tr").find('input[id$="-widgets-token"]'); + if (token.val() === "") { var token_value = contactswidget.normalize_string(name); token.val(token_value); } @@ -68,7 +68,7 @@ contactswidget.manage_directory = function(){ contactswidget.manage_hide_use_parent_address = function(){ if ($("#form-widgets-IContactDetails-parent_address").text().trim().length === 0) { if($('#form-widgets-IContactDetails-use_parent_address-0').length > 0 - && $('#form-widgets-IContactDetails-use_parent_address-0:checked').length == 0) { + && $('#form-widgets-IContactDetails-use_parent_address-0:checked').length === 0) { if($('#formfield-form-widgets-position').length === 0){ /* except on held position form because, there, * actual parent address can change during edition @@ -110,7 +110,7 @@ contactswidget.setup_relation_dependency = function(master_field, slave_field, r /* change create link so that master field selection is selected by default */ var add_link = $('#formfield-' + slave_field.replace(/\./g, '-')).find('.addnew'); - if(add_link.length == 1){ + if(add_link.length === 1){ var orig_href = add_link.attr('href'); var key; if(orig_href.indexOf('@add-contact') > -1) { @@ -134,7 +134,6 @@ contactswidget.setup_relation_dependency = function(master_field, slave_field, r } else { add_link.text(text_wo_company + ' (' + selected.title + ')'); } - } } } @@ -158,32 +157,14 @@ $(document).ready(function(){ $(document).on( 'change', '#formfield-form-widgets-gender input', - function () { contactswidget.update_person_title(this, mapping) } + function () { contactswidget.update_person_title(this, mapping); } ); }); /* contactswidget.manage_directory(); Do not hide token column in edit mode */ contactswidget.manage_hide_use_parent_address(); - $(document).bind('loadInsideOverlay', - function(e, pbajax, responseText, errorText, api){ + $(document).bind('after-render', function() { contactswidget.manage_hide_use_parent_address(); }); - - $('.contactoverlay').prepOverlay({ - subtype: 'ajax', - filter: '#content', - formselector: '#form', - closeselector: '[name="form.buttons.cancel"]', - noform: function(el, pbo) {return 'reload';} - }); - - $('.deleteoverlay').prepOverlay({ - subtype: 'ajax', - filter: '#content', - formselector: '#delete_confirmation', - closeselector: '[name="form.button.Cancel"]', - noform: function(el, pbo) {return 'reload';} - }); - }); diff --git a/src/collective/contact/core/browser/templates/address.pt b/src/collective/contact/core/browser/templates/address.pt index d12a23c6..977218e9 100644 --- a/src/collective/contact/core/browser/templates/address.pt +++ b/src/collective/contact/core/browser/templates/address.pt @@ -23,4 +23,4 @@
    -
    \ No newline at end of file +
    diff --git a/src/collective/contact/core/browser/templates/heldpositions.pt b/src/collective/contact/core/browser/templates/heldpositions.pt index aed1de35..147de2a9 100644 --- a/src/collective/contact/core/browser/templates/heldpositions.pt +++ b/src/collective/contact/core/browser/templates/heldpositions.pt @@ -13,22 +13,26 @@
    - + View - Edit - DeleteContact -
    diff --git a/src/collective/contact/core/browser/templates/position.pt b/src/collective/contact/core/browser/templates/position.pt index 97b2eaf8..4016a294 100644 --- a/src/collective/contact/core/browser/templates/position.pt +++ b/src/collective/contact/core/browser/templates/position.pt @@ -34,14 +34,14 @@ - + Create Contact -
    From f94ff83e8603796fba1e78278f27c7409b876cda Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 15 Feb 2019 10:39:34 +0100 Subject: [PATCH 056/144] add a bundle + compile js --- .gitattributes | 1 + .gitignore | 3 ++- .jshintrc | 7 ++++++ package.json | 25 +++++++++++++++++++ .../contact/core/browser/static/forms.js | 5 ++-- .../contact/core/browser/static/forms.min.js | 1 + .../contact/core/profiles/plone5/registry.xml | 12 +++++++++ 7 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 .gitattributes create mode 100644 .jshintrc create mode 100644 package.json create mode 100644 src/collective/contact/core/browser/static/forms.min.js diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..e2a85884 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.min.js binary diff --git a/.gitignore b/.gitignore index 2232c825..f88508cb 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ htmlcov *.log output.xml *.swp -/.idea \ No newline at end of file +/.idea +node_modules diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..ee2b3f89 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,7 @@ +{ + "browser": true, + "globals": { + "$": false, + "window": false + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..bd9351ac --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "collective.contact.core", + "version": "1.0.0", + "description": ".. contents::", + "main": "index.js", + "directories": { + "doc": "docs" + }, + "scripts": { + "minify": "uglifyjs src/collective/contact/core/browser/static/forms.js > src/collective/contact/core/browser/static/forms.min.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/collective/collective.contact.core.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/collective/collective.contact.core/issues" + }, + "homepage": "https://github.com/collective/collective.contact.core#readme", + "dependencies": { + "uglify-js": "^3.4.9" + } +} diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index f1a76aba..4b02b385 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -1,3 +1,4 @@ +'use strict'; var contactswidget = {}; /* Update person_title when gender changes (if person_title hasn't been set manually) */ @@ -67,8 +68,8 @@ contactswidget.manage_directory = function(){ use_parent_address is not checked */ contactswidget.manage_hide_use_parent_address = function(){ if ($("#form-widgets-IContactDetails-parent_address").text().trim().length === 0) { - if($('#form-widgets-IContactDetails-use_parent_address-0').length > 0 - && $('#form-widgets-IContactDetails-use_parent_address-0:checked').length === 0) { + if($('#form-widgets-IContactDetails-use_parent_address-0').length > 0 && + $('#form-widgets-IContactDetails-use_parent_address-0:checked').length === 0) { if($('#formfield-form-widgets-position').length === 0){ /* except on held position form because, there, * actual parent address can change during edition diff --git a/src/collective/contact/core/browser/static/forms.min.js b/src/collective/contact/core/browser/static/forms.min.js new file mode 100644 index 00000000..88d122b5 --- /dev/null +++ b/src/collective/contact/core/browser/static/forms.min.js @@ -0,0 +1 @@ +"use strict";var contactswidget={};contactswidget.update_person_title=function(genderInput,mapping){var gender=$(genderInput).val();var person_title=$("#form-widgets-person_title").val();var values=Object.values(mapping);if(person_title===""||values.indexOf(person_title)!==-1){$("#form-widgets-person_title").val(mapping[gender])}};contactswidget.normalize_string=function(s){var rules={a:/[àáâãäå]/g,ae:/[æ]/g,c:/[ç]/g,e:/[èéêë]/g,i:/[ìíîï]/g,n:/[ñ]/g,o:/[òóôõö]/g,oe:/[œ]/g,u:/[ùúûü]/g,y:/[ýÿ]/g,th:/[ðþ]/g,ss:/[ß]/g,_:/[\s\\]+/g};s=s.toLowerCase();for(var r in rules)s=s.replace(rules[r],r);return s};contactswidget.serialize_form=function(form){var viewArr=$(form).serializeArray();var view={};for(var i in viewArr){view[viewArr[i].name]=viewArr[i].value}return view};contactswidget.update_token=function(){var name=$(this).val();var token=$(this).closest("tr").find('input[id$="-widgets-token"]');if(token.val()===""){var token_value=contactswidget.normalize_string(name);token.val(token_value)}};contactswidget.manage_directory=function(){$('input[id$="-widgets-token"]').hide();$("#formfield-form-widgets-position_types thead").hide();$("#formfield-form-widgets-organization_types thead").hide();$("#formfield-form-widgets-organization_levels thead").hide();$(".portaltype-directory .datagridwidget-table-view thead").hide();$('input[id$="-widgets-name"]').blur(contactswidget.update_token)};contactswidget.manage_hide_use_parent_address=function(){if($("#form-widgets-IContactDetails-parent_address").text().trim().length===0){if($("#form-widgets-IContactDetails-use_parent_address-0").length>0&&$("#form-widgets-IContactDetails-use_parent_address-0:checked").length===0){if($("#formfield-form-widgets-position").length===0){$("#formfield-form-widgets-IContactDetails-use_parent_address").hide()}}}};contactswidget.get_selected_contact=function(form,field_id){var view=contactswidget.serialize_form(form);var token=view[field_id];if(token===undefined){return undefined}var input=form.find("#"+field_id.replace(/\./g,"-")+'-input-fields input[value="'+token+'"]');var title=input.siblings(".label").find("a").first().text();var path="/"+token.split("/").slice(2).join("/");return{token:token,title:title,path:path}};contactswidget.setup_relation_dependency=function(master_field,slave_field,relation){function apply_relation_dependency(input,master_field,slave_field,relation){var form=input.parents("form").first();var selected=contactswidget.get_selected_contact(form,master_field);var relations={};if(selected!==undefined){relations["relations."+relation+":record"]=selected.token}var slave_field_query=$("#"+slave_field.replace(/\./g,"-")+"-widgets-query");slave_field_query.setOptions({extraParams:relations}).flushCache();var add_link=$("#formfield-"+slave_field.replace(/\./g,"-")).find(".addnew");if(add_link.length===1){var orig_href=add_link.attr("href");var key;if(orig_href.indexOf("@add-contact")>-1){key="@add-contact"}if(orig_href.indexOf("@add-held-position")>-1){key="@add-held-position"}if(key){var base_add_url=orig_href.substr(0,orig_href.indexOf(key)+key.length);var new_url=base_add_url+"?oform.widgets.organization="+selected.token;new_url+="&oform.widgets.position="+selected.token;if(add_link.orig_text===undefined){add_link.orig_text=add_link.text()}add_link.attr("href",new_url);add_link.data("pbo").src=new_url;var text_wo_company=add_link.orig_text.replace(/ *\([^)]*\) */g,"");if(selected.token==="--NOVALUE--"){add_link.text(text_wo_company)}else{add_link.text(text_wo_company+" ("+selected.title+")")}}}}var selector="#"+master_field.replace(/\./g,"-")+"-input-fields input";$("body").on("change",selector,function(){apply_relation_dependency($(this),master_field,slave_field,relation)});$(document).ready(function(){$("body").find(selector).each(function(){apply_relation_dependency($(this),master_field,slave_field,relation)})})};$(document).ready(function(){var url="gender_person_title_mapping.json";$.get(url,function(mapping){$(document).on("change","#formfield-form-widgets-gender input",function(){contactswidget.update_person_title(this,mapping)})});contactswidget.manage_hide_use_parent_address();$(document).bind("after-render",function(){contactswidget.manage_hide_use_parent_address()})}); diff --git a/src/collective/contact/core/profiles/plone5/registry.xml b/src/collective/contact/core/profiles/plone5/registry.xml index 45c6a921..4554f011 100644 --- a/src/collective/contact/core/profiles/plone5/registry.xml +++ b/src/collective/contact/core/profiles/plone5/registry.xml @@ -6,4 +6,16 @@ ++resource++collective.contact.core/style.css + + + + collective.contact.core + + True + plone + False + ++resource++collective.contact.core/forms.min.js + 2019-02-15 10:32:00 + From ca2ba1bce94eed4427c020ec1cafd7d79520184e Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 21 Feb 2019 13:41:34 +0100 Subject: [PATCH 057/144] replace jquerytools tooltip by mockup tooltip needs mockup with https://github.com/plone/mockup/issues/893 --- .../basefields/templates/held_position.pt | 16 +++--- .../contact/core/browser/static/style.css | 16 +++++- .../contact/core/browser/templates/contact.pt | 10 +++- .../core/browser/templates/directory.pt | 51 +++++++++++-------- .../core/browser/templates/organization.pt | 39 +++++++++----- .../core/browser/templates/position.pt | 10 +++- .../browser/templates/suborganizations.pt | 14 +++-- 7 files changed, 107 insertions(+), 49 deletions(-) diff --git a/src/collective/contact/core/browser/basefields/templates/held_position.pt b/src/collective/contact/core/browser/basefields/templates/held_position.pt index 24b9d5c6..2d6483c1 100644 --- a/src/collective/contact/core/browser/basefields/templates/held_position.pt +++ b/src/collective/contact/core/browser/basefields/templates/held_position.pt @@ -10,12 +10,16 @@
    -
    +
    - - - + + + + + +
    @@ -30,4 +34,4 @@ i18n:translate="" />
    - \ No newline at end of file + diff --git a/src/collective/contact/core/browser/static/style.css b/src/collective/contact/core/browser/static/style.css index 27d4e94c..87a9e6cb 100644 --- a/src/collective/contact/core/browser/static/style.css +++ b/src/collective/contact/core/browser/static/style.css @@ -64,6 +64,20 @@ h3 img, h4 img { vertical-align: baseline; } -#content a:link.link-tooltip { +#content .pat-tooltip a { border-bottom: 1px dotted; } + +/* + tooltip + */ + +.contact-tooltip.mockup-tooltip.tooltip.in { + opacity: 99%; +} + +.contact-tooltip.mockup-tooltip .tooltip-inner { + max-width: 100%; + text-align: inherit; + padding: 12px; +} diff --git a/src/collective/contact/core/browser/templates/contact.pt b/src/collective/contact/core/browser/templates/contact.pt index 86defb43..43221d33 100644 --- a/src/collective/contact/core/browser/templates/contact.pt +++ b/src/collective/contact/core/browser/templates/contact.pt @@ -17,10 +17,16 @@
    diff --git a/src/collective/contact/core/browser/templates/directory.pt b/src/collective/contact/core/browser/templates/directory.pt index 8b242eca..7d136fbc 100644 --- a/src/collective/contact/core/browser/templates/directory.pt +++ b/src/collective/contact/core/browser/templates/directory.pt @@ -1,6 +1,5 @@ Organizations: -
    - -
    -

    Persons:

    -
    +
    +

    + Persons + : +

    + +
    - \ No newline at end of file + diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index 368a6fe3..3ca6a8d2 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -21,11 +21,16 @@ :
    @@ -46,19 +51,25 @@
    • - - - : + + + + + :
      • - - - + + + + + + ( from diff --git a/src/collective/contact/core/browser/templates/position.pt b/src/collective/contact/core/browser/templates/position.pt index 4016a294..b1c37688 100644 --- a/src/collective/contact/core/browser/templates/position.pt +++ b/src/collective/contact/core/browser/templates/position.pt @@ -17,10 +17,16 @@
    diff --git a/src/collective/contact/core/browser/templates/suborganizations.pt b/src/collective/contact/core/browser/templates/suborganizations.pt index 6a33aca4..876c2414 100644 --- a/src/collective/contact/core/browser/templates/suborganizations.pt +++ b/src/collective/contact/core/browser/templates/suborganizations.pt @@ -10,10 +10,16 @@

    Organizations in this organization:

    From a3040ecfb3e116ea3baac29e62f01dc509b35f95 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 21 Feb 2019 14:51:59 +0100 Subject: [PATCH 058/144] doc: remove plone 4 compatibility --- CHANGES.rst | 4 ++++ setup.py | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1ced9bfc..bc03fd4d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,10 @@ Changelog 2.0 (unreleased) ---------------- +- Use mockup for tooltips, modals and date widget. + This removes Plone 4 compatibility. + [thomasdesvenain] + - Do not show add link if content type is not allowed as directory subcontent. [thomasdesvenain] diff --git a/setup.py b/setup.py index 82bd3626..16f69c79 100644 --- a/setup.py +++ b/setup.py @@ -22,9 +22,6 @@ classifiers=[ "Environment :: Web Environment", "Framework :: Plone", - "Framework :: Plone :: 4.2", - "Framework :: Plone :: 4.3", - "Framework :: Plone :: 5.0", "Framework :: Plone :: 5.1", "Operating System :: OS Independent", "Programming Language :: Python", From 5fd52357d46b77ff902ac71ff2d3ff1c90571482 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Thu, 21 Feb 2019 14:52:33 +0100 Subject: [PATCH 059/144] use mockup widget for date. remove plone.formwidget.datetime dependency --- setup.py | 1 - src/collective/contact/core/behaviors.py | 12 +----------- src/collective/contact/core/configure.zcml | 1 - .../contact/core/profiles/base/metadata.xml | 1 - 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/setup.py b/setup.py index 16f69c79..f187c9d8 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,6 @@ 'plone.app.relationfield', 'plone.app.textfield!=1.2.8', 'plone.autoform', - 'plone.formwidget.datetime', 'plone.formwidget.masterselect>=1.3', 'plone.supermodel', 'Products.CMFPlone', diff --git a/src/collective/contact/core/behaviors.py b/src/collective/contact/core/behaviors.py index b22b88f5..4a41c35d 100644 --- a/src/collective/contact/core/behaviors.py +++ b/src/collective/contact/core/behaviors.py @@ -1,20 +1,18 @@ import re -import datetime +from plone.app.z3cform.widget import DateFieldWidget from zope.interface import alsoProvides from zope.interface import Interface from zope import schema from Acquisition import aq_base from z3c.form.widget import ComputedWidgetAttribute -from z3c.form.widget import FieldWidget from plone.supermodel import model from plone.supermodel.directives import fieldset from plone.autoform.interfaces import IFormFieldProvider from plone.autoform import directives as form from plone.formwidget.masterselect import MasterSelectBoolField -from plone.formwidget.datetime.z3cform import DateWidget from plone.app.textfield import RichText from plone.app.dexterity.browser.types import TypeSchemaContext @@ -323,14 +321,6 @@ def default_use_parent_address(adapter): field=IContactDetails['parent_address'], view=Interface) -def DateFieldWidget(field, request): - """IFieldWidget factory for DatetimeWidget.""" - widget = FieldWidget(field, DateWidget(request)) - currentYear = datetime.date.today().year - minimumYearRange = currentYear - 1900 # don't display dates before 1900 - widget.years_range = (-minimumYearRange, 1) - return widget - class IBirthday(model.Schema): diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 4926bfce..ac53c86e 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -15,7 +15,6 @@ - diff --git a/src/collective/contact/core/profiles/base/metadata.xml b/src/collective/contact/core/profiles/base/metadata.xml index 59fbc4e2..f57f7fd3 100644 --- a/src/collective/contact/core/profiles/base/metadata.xml +++ b/src/collective/contact/core/profiles/base/metadata.xml @@ -3,7 +3,6 @@ profile-collective.contact.widget:default profile-plone.app.dexterity:default - profile-plone.formwidget.datetime:default profile-plone.formwidget.masterselect:default profile-plone.app.relationfield:default profile-collective.z3cform.datagridfield:default From b601e1c77b64b84e5e93c8059e3495daca1988af Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 17:02:36 +0100 Subject: [PATCH 060/144] Update package and test structure (based on bobtemplates.plone) --- .coveragerc | 2 +- .gitignore | 47 ++++-- .travis.yml | 111 +++++++++---- CONTRIBUTORS.rst | 5 +- DEVELOP.rst | 41 +++++ LICENSE.GPL | 339 ++++++++++++++++++++++++++++++++++++++++ LICENSE.rst | 15 ++ MANIFEST.in | 8 +- base.cfg | 117 ++++++++++++-- buildout.cfg | 10 +- checkouts.cfg | 3 +- constraints.txt | 1 + constraints_plone50.txt | 3 + constraints_plone51.txt | 3 + constraints_plone52.txt | 3 + requirements.txt | 3 + setup.cfg | 19 +++ setup.py | 4 +- test_plone50.cfg | 11 ++ test_plone51.cfg | 41 +++++ test_plone52.cfg | 11 ++ tox.ini | 174 +++++++++++++++++++++ versions.cfg | 64 ++++---- 23 files changed, 936 insertions(+), 99 deletions(-) create mode 100644 DEVELOP.rst create mode 100644 LICENSE.GPL create mode 100644 LICENSE.rst create mode 100644 constraints.txt create mode 100644 constraints_plone50.txt create mode 100644 constraints_plone51.txt create mode 100644 constraints_plone52.txt create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 test_plone50.cfg create mode 100644 test_plone51.cfg create mode 100644 test_plone52.cfg create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc index 93b8d443..f66a2b6c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [report] include = src/collective/* - src/collective.contact.widget/* omit = */test* + */upgrades/* diff --git a/.gitignore b/.gitignore index f88508cb..200dbdb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,42 @@ +.coverage* *.egg-info +*.log *.mo -*.pyc -.installed.cfg -.mr.developer.cfg -.project -.pydevproject -.settings/ +*.py? +*.swp +# dirs bin/ +buildout-cache/ develop-eggs/ +eggs/ +htmlcov/ include/ lib/ +local/ +node_modules/ parts/ src/* -!src/collective/ +dist/* +test.plone_addon/ var/ -buildout-cache/ -htmlcov -.coverage -*.html -*.log +# files +.installed.cfg +.mr.developer.cfg +lib64 +log.html output.xml -*.swp -/.idea -node_modules +pip-selfcheck.json +report.html +.vscode/ +.tox/ +reports/ + +# excludes +!.coveragerc +!.editorconfig +!.gitattributes +!.gitignore +!.gitkeep +!.travis.yml +!src/collective +.python-version diff --git a/.travis.yml b/.travis.yml index 3c3efd34..d23ddf51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,88 @@ +dist: bionic language: python +sudo: false +cache: + pip: true + directories: + - eggs python: -- 2.7 + - "2.7" +matrix: + include: + - python: "2.7" + env: PLONE_VERSION=51 + - python: "2.7" + env: PLONE_VERSION=52 + - python: "3.7" + env: PLONE_VERSION=52 + sudo: true + fast_finish: true +before_install: + - sudo apt-get install -y firefox-geckodriver + - virtualenv -p `which python` . + - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt + - cp test_plone$PLONE_VERSION.cfg buildout.cfg + install: -- mkdir -p buildout-cache/{eggs,downloads} -- python bootstrap.py -c travis.cfg -- bin/buildout -c travis.cfg -N -q -t 3 -- pip install coverage -- curl -O https://saucelabs.com/downloads/sc-4.4.11-linux.tar.gz -- tar xzvf sc-4.4.11-linux.tar.gz -- ./sc-4.4.11-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TRAVIS_JOB_ID -f CONNECTED & -- JAVA_PID=$! -- bash -c "while [ ! -f CONNECTED ]; do sleep 2; done" + - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate + - bin/buildout -N -t 3 code-analysis:return-status-codes=True + +before_script: +- 'export DISPLAY=:99.0' +- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & +- sleep 3 +- firefox -v + script: -- bin/test -- coverage run ./bin/test -t \!robot +# Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout. + - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis + - bin/test --all + after_success: -- pip install coveralls -- coveralls -after_script: -- kill $JAVA_PID -notifications: - email: - - prive-ged@listes.entrouvert.com - - travis-reports@ecreall.com - - devs@imio.be -env: - global: - - secure: vUcL3IrMd2Wc2fEnrIR6jD/e1tqnNKiJHKy83EPJM08xLPUghDbx5VoGtfrIur4GN22Ov+nCIH3U6n4BMrsaIj7KGSrOS31tY+UDQHpiu9t03oCfg5e7wHi1/4tn6aVN5UZI1A8a4xJO4S+ziXkM/VbOk2Ln5Petpsck/c2I9ps= - - secure: coD6Bmb6pK+dfbUj49Rmi7XNj1QCGYTECmZvpRWeJs2HFaYceb6Bc+yJI2hFc06P6XUwUoPOS52rn6C/JOcOFXdCuwSSXxKBVgXdt9jDTDYRumbhUqEJfLLqd012gfs10cZDE09uH0W+FPpLaD3Ft71JLhf9WzjXwgO6EVxFp/8= - - ROBOT_BUILD_NUMBER=travis-$TRAVIS_BUILD_NUMBER - - ROBOT_REMOTE_URL=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@ondemand.saucelabs.com:80/wd/hub - - ROBOT_DESIRED_CAPABILITIES=tunnel-identifier:$TRAVIS_JOB_ID + - bin/createcoverage --output-dir=parts/test/coverage + - bin/pip install coverage + - bin/python -m coverage.pickle2json + - bin/pip install -q coveralls + - bin/coveralls + + + + + + + + + +# language: python +# python: +# - 2.7 +# install: +# - mkdir -p buildout-cache/{eggs,downloads} +# - python bootstrap.py -c travis.cfg +# - bin/buildout -c travis.cfg -N -q -t 3 +# - pip install coverage +# - curl -O https://saucelabs.com/downloads/sc-4.4.11-linux.tar.gz +# - tar xzvf sc-4.4.11-linux.tar.gz +# - ./sc-4.4.11-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TRAVIS_JOB_ID -f CONNECTED & +# - JAVA_PID=$! +# - bash -c "while [ ! -f CONNECTED ]; do sleep 2; done" +# script: +# - bin/test +# - coverage run ./bin/test -t \!robot +# after_success: +# - pip install coveralls +# - coveralls +# after_script: +# - kill $JAVA_PID +# notifications: +# email: +# - prive-ged@listes.entrouvert.com +# - travis-reports@ecreall.com +# - devs@imio.be +# env: +# global: +# - secure: vUcL3IrMd2Wc2fEnrIR6jD/e1tqnNKiJHKy83EPJM08xLPUghDbx5VoGtfrIur4GN22Ov+nCIH3U6n4BMrsaIj7KGSrOS31tY+UDQHpiu9t03oCfg5e7wHi1/4tn6aVN5UZI1A8a4xJO4S+ziXkM/VbOk2Ln5Petpsck/c2I9ps= +# - secure: coD6Bmb6pK+dfbUj49Rmi7XNj1QCGYTECmZvpRWeJs2HFaYceb6Bc+yJI2hFc06P6XUwUoPOS52rn6C/JOcOFXdCuwSSXxKBVgXdt9jDTDYRumbhUqEJfLLqd012gfs10cZDE09uH0W+FPpLaD3Ft71JLhf9WzjXwgO6EVxFp/8= +# - ROBOT_BUILD_NUMBER=travis-$TRAVIS_BUILD_NUMBER +# - ROBOT_REMOTE_URL=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@ondemand.saucelabs.com:80/wd/hub +# - ROBOT_DESIRED_CAPABILITIES=tunnel-identifier:$TRAVIS_JOB_ID diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index f52d0e50..d35817ad 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -1,7 +1,10 @@ +Contributors +============ + - Gauthier Bastien, IMIO - Vincent Fretin, Ecreall - Stéphan Geulette, IMIO - Cédric Messiant, Ecreall - Frédéric Peters, Entr'ouvert - Thomas Desvenain, Ecreall - +- Peter Holzer, peter.holzer@agitator.com diff --git a/DEVELOP.rst b/DEVELOP.rst new file mode 100644 index 00000000..15c691f4 --- /dev/null +++ b/DEVELOP.rst @@ -0,0 +1,41 @@ +Using the development buildout +============================== + +Create a virtualenv in the package:: + + $ virtualenv --clear . + +Install requirements with pip:: + + $ ./bin/pip install -r requirements.txt + +Run buildout:: + + $ ./bin/buildout + +Start Plone in foreground: + + $ ./bin/instance fg + + +Running tests +------------- + + $ tox + +list all tox environments: + + $ tox -l + py27-Plone51 + py27-Plone52 + py37-Plone52 + build_instance + code-analysis + lint-py27 + lint-py37 + coverage-report + +run a specific tox env: + + $ tox -e py37-Plone52 + diff --git a/LICENSE.GPL b/LICENSE.GPL new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/LICENSE.GPL @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/LICENSE.rst b/LICENSE.rst new file mode 100644 index 00000000..768b2ba5 --- /dev/null +++ b/LICENSE.rst @@ -0,0 +1,15 @@ +collective.contact.core Copyright 2020, Peter Holzer + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, +MA 02111-1307 USA. diff --git a/MANIFEST.in b/MANIFEST.in index b7b33abc..5a15789b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ -recursive-include src/collective * -recursive-include docs * -include * +graft src/collective +graft docs +include *.rst +global-exclude *.pyc exclude .installed.cfg exclude .mr.developer.cfg -global-exclude *pyc diff --git a/base.cfg b/base.cfg index 7735f60b..29b78571 100644 --- a/base.cfg +++ b/base.cfg @@ -1,23 +1,116 @@ [buildout] -package-name = collective.contact.core -package-extras = [test] extends = - https://raw.github.com/collective/buildout.plonetest/master/test-5.1.x.cfg - https://raw.github.com/collective/buildout.plonetest/master/qa.cfg sources.cfg checkouts.cfg versions.cfg + +show-picked-versions = true extensions = mr.developer -show-picked-versions = true -[test] -eggs += - ipdb +index = https://pypi.python.org/simple/ + +parts = + instance + test + code-analysis + coverage + test-coverage + createcoverage + releaser + i18ndude + omelette + robot + plone-helper-scripts +develop = . + + +[instance] +recipe = plone.recipe.zope2instance +user = admin:admin +http-address = 8080 +environment-vars = + zope_i18n_compile_mo_files true +eggs = + Plone + Pillow + collective.contact.core [test] + [code-analysis] recipe = plone.recipe.codeanalysis -directory = src/collective -# ignore lines too long and indentation warnings -# todo: remove C901,F401 -flake8-ignore = E123,E124,E402,E501,E126,E127,E128,C901,F401 +directory = ${buildout:directory}/src/collective +return-status-codes = False + + +[omelette] +recipe = collective.recipe.omelette +eggs = ${instance:eggs} + + +[test] +recipe = zc.recipe.testrunner +eggs = ${instance:eggs} +initialization = + os.environ['TZ'] = 'UTC' +defaults = ['-s', 'collective.contact.core', '--auto-color', '--auto-progress'] + + +[coverage] +recipe = zc.recipe.egg +eggs = coverage + + +[test-coverage] +recipe = collective.recipe.template +input = inline: + #!/bin/bash + export TZ=UTC + ${buildout:directory}/bin/coverage run bin/test $* + ${buildout:directory}/bin/coverage html + ${buildout:directory}/bin/coverage report -m --fail-under=90 + # Fail (exit status 1) if coverage returns exit status 2 (this happens + # when test coverage is below 100%. +output = ${buildout:directory}/bin/test-coverage +mode = 755 + + +[createcoverage] +recipe = zc.recipe.egg +eggs = createcoverage + + +[robot] +recipe = zc.recipe.egg +eggs = + ${test:eggs} + plone.app.robotframework[debug,reload] + + +[releaser] +recipe = zc.recipe.egg +eggs = zest.releaser + + +[i18ndude] +recipe = zc.recipe.egg +eggs = i18ndude + +[plone-helper-scripts] +recipe = zc.recipe.egg +eggs = + Products.CMFPlone + ${instance:eggs} +interpreter = zopepy +scripts = + zopepy + plone-compile-resources + +[versions] +# Don't use a released version of collective.contact.core +collective.contact.core = + + + + + diff --git a/buildout.cfg b/buildout.cfg index e1834a52..18b90557 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,6 +1,8 @@ [buildout] + +# use this extend one of the buildout configuration: extends = - base.cfg -parts += - createcoverage -sources = sources +# -*- mrbob: extra extends -*- +# test_plone50.cfg +# test_plone51.cfg + test_plone52.cfg diff --git a/checkouts.cfg b/checkouts.cfg index 886143cf..05126cad 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -1,6 +1,7 @@ [buildout] extends = - https://raw.github.com/plone/buildout.coredev/5.1/sources.cfg + https://raw.github.com/plone/buildout.coredev/5.2/sources.cfg +sources-dir = ${buildout:directory}/devsrc always-checkout = force auto-checkout += plone.formwidget.masterselect diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..24cbf877 --- /dev/null +++ b/constraints.txt @@ -0,0 +1 @@ +-c constraints_plone52.txt diff --git a/constraints_plone50.txt b/constraints_plone50.txt new file mode 100644 index 00000000..9852be62 --- /dev/null +++ b/constraints_plone50.txt @@ -0,0 +1,3 @@ +-c https://dist.plone.org/release/5.0-latest/requirements.txt +# setuptools==33.1.1 +# zc.buildout==2.9.5 diff --git a/constraints_plone51.txt b/constraints_plone51.txt new file mode 100644 index 00000000..8dcbff18 --- /dev/null +++ b/constraints_plone51.txt @@ -0,0 +1,3 @@ +-c https://dist.plone.org/release/5.1-latest/requirements.txt +# setuptools==39.1.0 +# zc.buildout==2.11.4 diff --git a/constraints_plone52.txt b/constraints_plone52.txt new file mode 100644 index 00000000..d96fee01 --- /dev/null +++ b/constraints_plone52.txt @@ -0,0 +1,3 @@ +-c https://dist.plone.org/release/5.2-latest/requirements.txt +# setuptools==40.2.0 +# zc.buildout==2.12.2 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..fa2f6147 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-c constraints_plone52.txt +setuptools +zc.buildout diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..e920041b --- /dev/null +++ b/setup.cfg @@ -0,0 +1,19 @@ +[check-manifest] +ignore = + *.cfg + .coveragerc + .editorconfig + .gitattributes + +[isort] +# for details see +# http://docs.plone.org/develop/styleguide/python.html#grouping-and-sorting +force_alphabetical_sort = True +force_single_line = True +lines_after_imports = 2 +line_length = 200 +not_skip = __init__.py + +[flake8] +exclude = bootstrap.py,docs,*.egg.,omelette +max-complexity = 15 diff --git a/setup.py b/setup.py index f187c9d8..2f769e3a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,9 @@ classifiers=[ "Environment :: Web Environment", "Framework :: Plone", + "Framework :: Plone :: 5.0", "Framework :: Plone :: 5.1", + "Framework :: Plone :: 5.2", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", @@ -33,7 +35,7 @@ author='"Cedric Messiant"', author_email='cedricmessiant@ecreall.com', url='http://svn.plone.org/svn/collective/', - license='gpl', + license='GPL version 2', packages=find_packages('src'), package_dir={'': 'src'}, namespace_packages=['collective', 'collective.contact'], diff --git a/test_plone50.cfg b/test_plone50.cfg new file mode 100644 index 00000000..88b13202 --- /dev/null +++ b/test_plone50.cfg @@ -0,0 +1,11 @@ +[buildout] + +extends = + https://raw.github.com/collective/buildout.plonetest/master/test-5.0.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone50.cfg + +[versions] +plone.schemaeditor = >=2.0.18 diff --git a/test_plone51.cfg b/test_plone51.cfg new file mode 100644 index 00000000..82dd94fb --- /dev/null +++ b/test_plone51.cfg @@ -0,0 +1,41 @@ +[buildout] + +extends = + https://raw.github.com/collective/buildout.plonetest/master/test-5.1.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone51.cfg + +[versions] +plone.testing = 5.0.0 + +# Added by buildout at 2020-01-06 16:41:12.265037 +PyYAML = 5.2 +argh = 0.26.2 +chardet = 3.0.4 +createcoverage = 1.2 +ecreall.helpers.testing = 1.4 +ecreall.helpers.upgrade = 1.3 +flake8 = 2.5.2 +idna = 2.8 +mccabe = 0.4.0 +pathtools = 0.1.2 +pep8 = 1.7.0 +pkginfo = 1.5.0.1 +plone.recipe.codeanalysis = 2.1 +pyflakes = 1.0.0 +requests-toolbelt = 0.9.1 +watchdog = 0.9.0 + +# Required by: +# plone.recipe.codeanalysis==2.1 +check-manifest = 0.31 + +# Required by: +# zest.releaser==6.17.2 +colorama = 0.4.3 + +# Required by: +# collective.contact.core==1.24.dev0 +vobject = 0.8.1rc0 diff --git a/test_plone52.cfg b/test_plone52.cfg new file mode 100644 index 00000000..f8a7c224 --- /dev/null +++ b/test_plone52.cfg @@ -0,0 +1,11 @@ +[buildout] + +extends = + https://raw.github.com/collective/buildout.plonetest/master/test-5.2.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone52.cfg + +[versions] +plone.testing = 7.0.1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..e8b3ad71 --- /dev/null +++ b/tox.ini @@ -0,0 +1,174 @@ +[tox] +envlist = + {py27,py37}-lint, + py{27}-Plone{51}, + py{27,37}-Plone{52}, + build_instance, +# docs, +# coverage-report, + +skip_missing_interpreters = True + +[testenv] +skip_install = true + +extras = + develop + test + +commands = + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot code-analysis + coverage run {envbindir}/test -v1 --auto-color {posargs} + # coverage run {envbindir}/test -v --all -t robot {posargs} + {envbindir}/code-analysis + +setenv = + COVERAGE_FILE=.coverage.{envname} + version_file=test_plone51.cfg + Plone50: version_file=test_plone50.cfg + Plone51: version_file=test_plone51.cfg + Plone52: version_file=test_plone52.cfg + +deps = + -rrequirements.txt + Plone50: -cconstraints_plone50.txt + Plone51: -cconstraints_plone51.txt + Plone52: -cconstraints_plone52.txt + coverage + +[testenv:coverage-report] +skip_install = true +usedevelop = True +basepython = python2.7 + +deps = + coverage + -cconstraints_plone51.txt + +setenv = + COVERAGE_FILE=.coverage + +commands = + coverage erase + coverage combine + coverage html + coverage xml + coverage report + + +[lint] +skip_install = true + +deps = + isort + flake8 + # helper to generate HTML reports: + flake8-html + # Useful flake8 plugins that are Python and Plone specific: + flake8-coding + flake8-debugger + flake8-deprecated + flake8-print + #flake8-pytest + flake8-todo + flake8-isort + mccabe + # Potential flake8 plugins that should be used: # TBD + #flake8-blind-except + #flake8-commas + #flake8-docstrings + #flake8-mypy + #flake8-pep3101 + #flake8-plone-hasattr + #flake8-string-format + #flake8_strict + #flake8-quotes + #flake8-polyfill + +commands = + mkdir -p {toxinidir}/reports/flake8 + - flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src setup.py + flake8 --doctests src tests setup.py + isort --check-only --recursive {toxinidir}/src + +whitelist_externals = + mkdir + +[testenv:isort-apply] +skip_install = true + +deps = + isort + +commands = + isort --apply --recursive {toxinidir}/src + +[testenv:py27-lint] +basepython = python2.7 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + +[testenv:py35-lint] +basepython = python3.5 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + +[testenv:py36-lint] +basepython = python3.6 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + +[testenv:py37-lint] +basepython = python3.7 +skip_install = true +deps = {[lint]deps} +commands = {[lint]commands} +whitelist_externals = {[lint]whitelist_externals} + +[testenv:docs] +skip_install = true + +deps = + Sphinx + +commands = + sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html + +[testenv:update_translation] +skip_install = true + +deps = + i18ndude + +commands = + i18ndude find-untranslated + i18ndude rebuild-pot + i18ndude merge + i18ndude sync + i18ndude list + +[testenv:release] +skip_install = true + +deps = + zest.releaser[recommended] + +commands = + fullrelease --no-input -v + +[testenv:build_instance] +basepython = python2.7 +skip_install = true + +commands = + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} bootstrap + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} annotate + {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} diff --git a/versions.cfg b/versions.cfg index c6316f80..2e20bb72 100644 --- a/versions.cfg +++ b/versions.cfg @@ -1,37 +1,37 @@ [versions] -collective.z3cform.datagridfield = 1.1 -ecreall.helpers.testing = 1.4 -ecreall.helpers.upgrade = 1.3 -ipdb = 0.8.1 -ipython = 3.0.0 -mock = 1.0.1 -setuptools = -vobject = 0.8.1c -zc.buildout = -zc.recipe.egg = 2.0.3 +# collective.z3cform.datagridfield = 1.1 +# ecreall.helpers.testing = 1.4 +# ecreall.helpers.upgrade = 1.3 +# ipdb = 0.8.1 +# ipython = 3.0.0 +# mock = 1.0.1 +# setuptools = +# vobject = 0.8.1c +# zc.buildout = +# zc.recipe.egg = 2.0.3 -# robot -plone.app.robotframework = 1.2.0 -robotframework = 3.0.2 -robotframework-debuglibrary = 1.1.2 -robotframework-seleniumlibrary = 3.1.1 -robotframework-selenium2library = 3.0.0 -robotframework-selenium2screenshots = 0.8.1 -robotsuite = 2.0.0 -selenium = 3.11.0 -sphinxcontrib-robotframework = 0.7.0 +# # robot +# plone.app.robotframework = 1.2.0 +# robotframework = 3.0.2 +# robotframework-debuglibrary = 1.1.2 +# robotframework-seleniumlibrary = 3.1.1 +# robotframework-selenium2library = 3.0.0 +# robotframework-selenium2screenshots = 0.8.1 +# robotsuite = 2.0.0 +# selenium = 3.11.0 +# sphinxcontrib-robotframework = 0.7.0 -PyYAML = 3.11 -argh = 0.26.1 -pathtools = 0.1.2 -watchdog = 0.8.3 +# PyYAML = 3.11 +# argh = 0.26.1 +# pathtools = 0.1.2 +# watchdog = 0.8.3 -# coverage -createcoverage = 1.2 -mccabe = 0.4.0 -pep8 = 1.7.0 -plone.recipe.codeanalysis = 2.1 -pyflakes = 1.0.0 -flake8 = 2.5.2 +# # coverage +# createcoverage = 1.2 +# mccabe = 0.4.0 +# pep8 = 1.7.0 +# plone.recipe.codeanalysis = 2.1 +# pyflakes = 1.0.0 +# flake8 = 2.5.2 -check-manifest = 0.31 +# check-manifest = 0.31 From 1e33dbc1a7dfad549f9f9371aa84511ff906fd26 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 17:42:01 +0100 Subject: [PATCH 061/144] disable code-analysis for now --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d23ddf51..c457dff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,9 @@ before_install: - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt - cp test_plone$PLONE_VERSION.cfg buildout.cfg -install: - - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate - - bin/buildout -N -t 3 code-analysis:return-status-codes=True +#install: +# - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate +# - bin/buildout -N -t 3 code-analysis:return-status-codes=True before_script: - 'export DISPLAY=:99.0' @@ -35,7 +35,7 @@ before_script: script: # Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout. - - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis +# - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis - bin/test --all after_success: From f40a9bbd44e17438bcd5bb0bd62aaded6db47554 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 17:58:07 +0100 Subject: [PATCH 062/144] reenable code-analysis --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c457dff9..d23ddf51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,9 @@ before_install: - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt - cp test_plone$PLONE_VERSION.cfg buildout.cfg -#install: -# - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate -# - bin/buildout -N -t 3 code-analysis:return-status-codes=True +install: + - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate + - bin/buildout -N -t 3 code-analysis:return-status-codes=True before_script: - 'export DISPLAY=:99.0' @@ -35,7 +35,7 @@ before_script: script: # Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout. -# - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis + - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis - bin/test --all after_success: From 6e15f57beb8501084f2e3ee62d5c219270652d0a Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 18:03:48 +0100 Subject: [PATCH 063/144] isort --- src/collective/contact/core/__init__.py | 2 ++ src/collective/contact/core/adapters.py | 25 ++++++++------- src/collective/contact/core/behaviors.py | 32 +++++++++---------- .../contact/core/browser/addcontact.py | 25 ++++++++------- .../contact/core/browser/address.py | 10 +++--- .../contact/core/browser/basefields/views.py | 3 +- .../contact/core/browser/contact.py | 5 ++- .../contact/core/browser/contactable.py | 15 +++++---- .../contact/core/browser/directory.py | 2 +- .../contact/core/browser/excelexport.py | 14 ++++---- .../contact/core/browser/organization.py | 7 ++-- src/collective/contact/core/browser/person.py | 4 +-- .../core/browser/person_title_mapping.py | 5 ++- .../contact/core/browser/position.py | 7 ++-- src/collective/contact/core/browser/utils.py | 16 ++++------ .../contact/core/browser/vcard_export.py | 3 +- .../contact/core/content/directory.py | 6 ++-- .../contact/core/content/held_position.py | 4 +-- .../contact/core/content/organization.py | 7 ++-- src/collective/contact/core/content/person.py | 5 ++- .../contact/core/content/position.py | 1 - src/collective/contact/core/fti.py | 8 ++--- src/collective/contact/core/indexers.py | 13 ++++---- src/collective/contact/core/interfaces.py | 10 +++--- src/collective/contact/core/schema.py | 3 +- src/collective/contact/core/setuphandlers.py | 9 +++--- src/collective/contact/core/subscribers.py | 6 ++-- src/collective/contact/core/testing.py | 9 +++--- .../contact/core/tests/test_adapters.py | 13 ++++---- .../contact/core/tests/test_behaviors.py | 23 +++++++------ .../contact/core/tests/test_content_types.py | 10 +++--- .../contact/core/tests/test_related.py | 10 +++--- .../contact/core/tests/test_robot.py | 8 ++--- .../contact/core/tests/test_search.py | 16 ++++++---- .../contact/core/tests/test_setup.py | 5 ++- .../contact/core/tests/test_utils.py | 5 ++- .../contact/core/tests/test_views.py | 11 +++---- .../contact/core/tests/test_workflow.py | 5 ++- src/collective/contact/core/vocabulary.py | 11 +++---- 39 files changed, 182 insertions(+), 191 deletions(-) diff --git a/src/collective/contact/core/__init__.py b/src/collective/contact/core/__init__.py index 6bd5e916..0b33d70d 100644 --- a/src/collective/contact/core/__init__.py +++ b/src/collective/contact/core/__init__.py @@ -1,6 +1,8 @@ from zope.i18nmessageid import MessageFactory import logging + + logger = logging.getLogger('collective.contact.core') _ = MessageFactory("collective.contact.core") diff --git a/src/collective/contact/core/adapters.py b/src/collective/contact/core/adapters.py index c94aa7ca..52a59052 100644 --- a/src/collective/contact/core/adapters.py +++ b/src/collective/contact/core/adapters.py @@ -1,18 +1,19 @@ -import datetime -import vobject - -from zope.interface import Interface, implements +from collective.contact.core.behaviors import IBirthday +from collective.contact.core.content.held_position import HeldPosition +from collective.contact.core.content.organization import IOrganization +from collective.contact.core.content.organization import Organization +from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IHeldPosition +from collective.contact.core.interfaces import IPersonHeldPositions +from collective.contact.core.interfaces import IVCard from five import grok - -from Products.CMFPlone.utils import safe_unicode from plone import api +from Products.CMFPlone.utils import safe_unicode +from zope.interface import implements +from zope.interface import Interface -from collective.contact.core.interfaces import IVCard, IContactable,\ - IPersonHeldPositions, IHeldPosition -from collective.contact.core.content.held_position import HeldPosition -from collective.contact.core.content.organization import IOrganization,\ - Organization -from collective.contact.core.behaviors import IBirthday +import datetime +import vobject class ContactableVCard: diff --git a/src/collective/contact/core/behaviors.py b/src/collective/contact/core/behaviors.py index 4a41c35d..97ddd178 100644 --- a/src/collective/contact/core/behaviors.py +++ b/src/collective/contact/core/behaviors.py @@ -1,28 +1,28 @@ -import re - +from Acquisition import aq_base +from collective.contact.core import _ +from collective.contact.core.interfaces import IContactable +from collective.contact.widget.schema import ContactChoice +from collective.contact.widget.schema import ContactList +from collective.contact.widget.source import ContactSourceBinder +from plone.app.dexterity.browser.types import TypeSchemaContext +from plone.app.textfield import RichText from plone.app.z3cform.widget import DateFieldWidget +from plone.autoform import directives as form +from plone.autoform.interfaces import IFormFieldProvider +from plone.formwidget.masterselect import MasterSelectBoolField +from plone.supermodel import model +from plone.supermodel.directives import fieldset +from z3c.form.widget import ComputedWidgetAttribute +from zope import schema from zope.interface import alsoProvides from zope.interface import Interface -from zope import schema -from Acquisition import aq_base -from z3c.form.widget import ComputedWidgetAttribute -from plone.supermodel import model +import re -from plone.supermodel.directives import fieldset -from plone.autoform.interfaces import IFormFieldProvider -from plone.autoform import directives as form -from plone.formwidget.masterselect import MasterSelectBoolField -from plone.app.textfield import RichText -from plone.app.dexterity.browser.types import TypeSchemaContext # from Products.CMFDefault.utils import checkEmailAddress # from Products.CMFDefault.exceptions import EmailAddressInvalid -from collective.contact.core import _ -from collective.contact.core.interfaces import IContactable -from collective.contact.widget.schema import ContactChoice, ContactList -from collective.contact.widget.source import ContactSourceBinder # Taken from http://www.regular-expressions.info/email.html _isemail = r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}" diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index cccf9ac7..76aa2ebd 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -1,15 +1,10 @@ -import copy - +from AccessControl import getSecurityManager from collective.contact.core import _ from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.person import IPerson from collective.contact.widget.interfaces import IContactWidgetSettings from collective.contact.widget.schema import ContactChoice from collective.contact.widget.source import ContactSourceBinder - -from AccessControl import getSecurityManager -from Products.CMFPlone.interfaces import IConstrainTypes -from Products.statusmessages.interfaces import IStatusMessage from five import grok from plone import api from plone.dexterity.browser.add import DefaultAddForm @@ -19,19 +14,27 @@ from plone.dexterity.utils import addContentToContainer from plone.supermodel import model from plone.z3cform.interfaces import IDeferSecurityCheck -from z3c.form import field, form, button +from Products.CMFPlone.interfaces import IConstrainTypes +from Products.statusmessages.interfaces import IStatusMessage +from z3c.form import button +from z3c.form import field +from z3c.form import form from z3c.form.contentprovider import ContentProviders -from z3c.form.interfaces import IFieldsAndContentProvidersForm, \ - DISPLAY_MODE -from zope.component import getUtility, queryAdapter +from z3c.form.interfaces import DISPLAY_MODE +from z3c.form.interfaces import IFieldsAndContentProvidersForm +from zope.component import getUtility +from zope.component import queryAdapter from zope.component.hooks import getSite from zope.contentprovider.interfaces import IContentProvider from zope.event import notify from zope.i18n import Message from zope.interface import alsoProvides -from zope.interface import implements, Interface +from zope.interface import implements +from zope.interface import Interface from zope.publisher.browser import BrowserView +import copy + class ICustomSettings(Interface): """You can overrides those methods by writing an adapter to IDirectory. diff --git a/src/collective/contact/core/browser/address.py b/src/collective/contact/core/browser/address.py index 1e373313..e56c7084 100644 --- a/src/collective/contact/core/browser/address.py +++ b/src/collective/contact/core/browser/address.py @@ -1,12 +1,12 @@ from Acquisition import aq_base - +from collective.contact.core.behaviors import ADDRESS_FIELDS +from collective.contact.core.behaviors import IContactDetails +from collective.contact.core.browser import TEMPLATES_DIR +from collective.contact.core.interfaces import IContactCoreParameters +from collective.contact.core.interfaces import IHeldPosition from five import grok from plone import api -from collective.contact.core.behaviors import IContactDetails -from collective.contact.core.browser import TEMPLATES_DIR -from collective.contact.core.behaviors import ADDRESS_FIELDS -from collective.contact.core.interfaces import IHeldPosition, IContactCoreParameters grok.templatedir(TEMPLATES_DIR) diff --git a/src/collective/contact/core/browser/basefields/views.py b/src/collective/contact/core/browser/basefields/views.py index 48bbef9f..15e09438 100644 --- a/src/collective/contact/core/browser/basefields/views.py +++ b/src/collective/contact/core/browser/basefields/views.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- +from AccessControl import getSecurityManager from collective.contact.core.behaviors import IBirthday from collective.contact.core.browser.utils import date_to_DateTime - -from AccessControl import getSecurityManager from Products.Five import BrowserView from zope.component import getUtility from zope.schema.interfaces import IVocabularyFactory diff --git a/src/collective/contact/core/browser/contact.py b/src/collective/contact/core/browser/contact.py index 96133b69..28931591 100644 --- a/src/collective/contact/core/browser/contact.py +++ b/src/collective/contact/core/browser/contact.py @@ -1,8 +1,7 @@ -from plone import api - +from collective.contact.core.behaviors import IBirthday from collective.contact.core.browser.contactable import BaseView from collective.contact.core.browser.utils import date_to_DateTime -from collective.contact.core.behaviors import IBirthday +from plone import api class Contact(BaseView): diff --git a/src/collective/contact/core/browser/contactable.py b/src/collective/contact/core/browser/contactable.py index 2e85f6b0..35224f2a 100644 --- a/src/collective/contact/core/browser/contactable.py +++ b/src/collective/contact/core/browser/contactable.py @@ -1,23 +1,24 @@ # -*- coding: utf-8 -*- -import os.path - +from Acquisition import aq_base from collective.contact.core.behaviors import CONTACT_DETAILS_FIELDS from collective.contact.core.behaviors import IContactDetails from collective.contact.core.browser import TEMPLATES_DIR from collective.contact.core.browser.address import get_address from collective.contact.core.browser.utils import get_valid_url -from collective.contact.core.interfaces import IContactable, IContactCoreParameters - -from Acquisition import aq_base -from Products.Five import BrowserView -from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile +from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IContactCoreParameters from five import grok from plone import api from plone.dexterity.browser.view import DefaultView from plone.dexterity.utils import getAdditionalSchemata +from Products.Five import BrowserView +from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from zope.globalrequest import getRequest from zope.interface import implementer +import os.path + + grok.templatedir(TEMPLATES_DIR) diff --git a/src/collective/contact/core/browser/directory.py b/src/collective/contact/core/browser/directory.py index ab57330c..af4835e7 100644 --- a/src/collective/contact/core/browser/directory.py +++ b/src/collective/contact/core/browser/directory.py @@ -1,5 +1,5 @@ -from plone.dexterity.browser.view import DefaultView from plone import api +from plone.dexterity.browser.view import DefaultView class Directory(DefaultView): diff --git a/src/collective/contact/core/browser/excelexport.py b/src/collective/contact/core/browser/excelexport.py index 56312c4c..2db9823e 100644 --- a/src/collective/contact/core/browser/excelexport.py +++ b/src/collective/contact/core/browser/excelexport.py @@ -1,11 +1,16 @@ +from collective.contact.core.behaviors import ADDRESS_FIELDS +from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IHeldPosition +from collective.contact.widget.interfaces import IContactChoice +from collective.contact.widget.interfaces import IContactContent +from plone import api +from plone.dexterity.interfaces import IDexterityFTI from zope.component import adapts from zope.component import getMultiAdapter from zope.component.interfaces import ComponentLookupError -from zope.interface import Interface from zope.interface import implements +from zope.interface import Interface -from plone.dexterity.interfaces import IDexterityFTI -from plone import api try: from collective.excelexport.exportables.dexterityfields import BaseFieldRenderer @@ -17,9 +22,6 @@ except ImportError: HAS_EXCELEXPORT = False -from collective.contact.widget.interfaces import IContactChoice, IContactContent -from collective.contact.core.interfaces import IContactable, IHeldPosition -from collective.contact.core.behaviors import ADDRESS_FIELDS if HAS_EXCELEXPORT: diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index c818e939..d340d01c 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- +from AccessControl import getSecurityManager from collective.contact.core.behaviors import IContactDetails from collective.contact.core.browser.contactable import BaseView from collective.contact.core.browser.utils import date_to_DateTime from collective.contact.core.browser.utils import get_valid_url from collective.contact.core.indexers import held_position_sortable_title -from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IContactable - -from AccessControl import getSecurityManager -from Products.Five import BrowserView +from collective.contact.core.interfaces import IContactCoreParameters from plone import api +from Products.Five import BrowserView class Organization(BaseView): diff --git a/src/collective/contact/core/browser/person.py b/src/collective/contact/core/browser/person.py index fca7e402..f8c6d844 100644 --- a/src/collective/contact/core/browser/person.py +++ b/src/collective/contact/core/browser/person.py @@ -5,8 +5,8 @@ from collective.contact.core.browser.contactable import BaseView from collective.contact.core.browser.utils import date_to_DateTime from collective.contact.core.content.person import IPerson -from collective.contact.core.interfaces import IContactable, \ - IPersonHeldPositions +from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IPersonHeldPositions from Products.Five import BrowserView diff --git a/src/collective/contact/core/browser/person_title_mapping.py b/src/collective/contact/core/browser/person_title_mapping.py index 83a6a94f..11f168c5 100644 --- a/src/collective/contact/core/browser/person_title_mapping.py +++ b/src/collective/contact/core/browser/person_title_mapping.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -import json - +from collective.contact.core import _ from five import grok from zope.i18n import translate from zope.interface import Interface -from collective.contact.core import _ +import json class GenderPersonTitleMapping(grok.View): diff --git a/src/collective/contact/core/browser/position.py b/src/collective/contact/core/browser/position.py index 1c328089..d7d63497 100644 --- a/src/collective/contact/core/browser/position.py +++ b/src/collective/contact/core/browser/position.py @@ -1,11 +1,8 @@ from AccessControl import getSecurityManager - -from zope.component import getUtility -from zope.schema.interfaces import IVocabularyFactory - from collective.contact.core.browser.contactable import BaseView from collective.contact.core.interfaces import IContactable - +from zope.component import getUtility +from zope.schema.interfaces import IVocabularyFactory class Position(BaseView): diff --git a/src/collective/contact/core/browser/utils.py b/src/collective/contact/core/browser/utils.py index 9870a7b7..4dac09a9 100644 --- a/src/collective/contact/core/browser/utils.py +++ b/src/collective/contact/core/browser/utils.py @@ -1,16 +1,14 @@ +from collective.contact.core.behaviors import IBirthday +from collective.contact.core.behaviors import IContactDetails from DateTime import DateTime -from zope.component import getUtility -from zope import schema - -from plone.supermodel.interfaces import ISchemaPolicy +from plone.app.dexterity.behaviors.metadata import IBasic from plone.autoform.interfaces import IFormFieldProvider from plone.behavior.interfaces import IBehavior -from plone.schemaeditor.utils import non_fieldset_fields from plone.dexterity.interfaces import IDexterityFTI -from plone.app.dexterity.behaviors.metadata import IBasic - -from collective.contact.core.behaviors import IBirthday -from collective.contact.core.behaviors import IContactDetails +from plone.schemaeditor.utils import non_fieldset_fields +from plone.supermodel.interfaces import ISchemaPolicy +from zope import schema +from zope.component import getUtility IGNORED_BEHAVIORS = [IContactDetails, IBasic, IBirthday] diff --git a/src/collective/contact/core/browser/vcard_export.py b/src/collective/contact/core/browser/vcard_export.py index 570c435f..352369f2 100644 --- a/src/collective/contact/core/browser/vcard_export.py +++ b/src/collective/contact/core/browser/vcard_export.py @@ -1,7 +1,6 @@ -from five import grok - from collective.contact.core.interfaces import IVCard from collective.contact.widget.interfaces import IContactContent +from five import grok class ContactVCF(grok.View): diff --git a/src/collective/contact/core/content/directory.py b/src/collective/contact/core/content/directory.py index 5deb5a08..71e56938 100644 --- a/src/collective/contact/core/content/directory.py +++ b/src/collective/contact/core/content/directory.py @@ -1,13 +1,15 @@ # -*- coding: utf-8 -*- from collective.contact.core import _ -from collective.z3cform.datagridfield import DataGridFieldFactory, DictRow +from collective.z3cform.datagridfield import DataGridFieldFactory +from collective.z3cform.datagridfield import DictRow from five import grok from plone.autoform.directives import widget from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy from plone.supermodel import model from zope import schema -from zope.interface import Interface, implements +from zope.interface import implements +from zope.interface import Interface class INameTokenTableRowSchema(Interface): diff --git a/src/collective/contact/core/content/held_position.py b/src/collective/contact/core/content/held_position.py index b0897db0..0e13c9ab 100644 --- a/src/collective/contact/core/content/held_position.py +++ b/src/collective/contact/core/content/held_position.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition - from ComputedAttribute import ComputedAttribute -from Products.CMFPlone.utils import normalizeString, safe_unicode from five import grok from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy +from Products.CMFPlone.utils import normalizeString +from Products.CMFPlone.utils import safe_unicode from z3c.form.interfaces import NO_VALUE from zope.interface import implements diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index c4d9a32b..8644f7d1 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -1,13 +1,11 @@ # -*- coding: utf-8 -*- +from Acquisition import aq_chain +from Acquisition import aq_inner from collective.contact.core import _ from collective.contact.core import logger from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent - -from Acquisition import aq_chain -from Acquisition import aq_inner -from Products.CMFPlone.utils import base_hasattr from five import grok from plone import api from plone.app.textfield import RichText @@ -15,6 +13,7 @@ from plone.dexterity.schema import DexteritySchemaPolicy from plone.namedfile.field import NamedImage from plone.supermodel import model +from Products.CMFPlone.utils import base_hasattr from zc.relation.interfaces import ICatalog from zope import schema from zope.component import getUtility diff --git a/src/collective/contact/core/content/person.py b/src/collective/contact/core/content/person.py index 79fe53c7..ad7ba1e2 100644 --- a/src/collective/contact/core/content/person.py +++ b/src/collective/contact/core/content/person.py @@ -1,13 +1,11 @@ # -*- coding: utf-8 -*- from collective.contact.core import _ from collective.contact.core.browser.contactable import Contactable -from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IHeldPosition from collective.contact.core.interfaces import IPersonHeldPositions from collective.contact.widget.interfaces import IContactContent - -from Products.CMFPlone.utils import normalizeString from five import grok from plone.autoform import directives as form from plone.dexterity.content import Container @@ -15,6 +13,7 @@ from plone.namedfile.field import NamedImage from plone.registry.interfaces import IRegistry from plone.supermodel import model +from Products.CMFPlone.utils import normalizeString from z3c.form.browser.radio import RadioFieldWidget from z3c.form.interfaces import NO_VALUE from zope import schema diff --git a/src/collective/contact/core/content/position.py b/src/collective/contact/core/content/position.py index 217adfa9..80afbd18 100644 --- a/src/collective/contact/core/content/position.py +++ b/src/collective/contact/core/content/position.py @@ -4,7 +4,6 @@ from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent - from five import grok from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy diff --git a/src/collective/contact/core/fti.py b/src/collective/contact/core/fti.py index 84827110..6457db42 100644 --- a/src/collective/contact/core/fti.py +++ b/src/collective/contact/core/fti.py @@ -1,9 +1,9 @@ -from zope.interface import implements - -from plone.dexterity.interfaces import IDexterityFTI from plone.dexterity.fti import DexterityFTI -from plone.supermodel import loadString, loadFile +from plone.dexterity.interfaces import IDexterityFTI +from plone.supermodel import loadFile +from plone.supermodel import loadString from plone.supermodel.model import Model +from zope.interface import implements class DexterityConfigurablePolicyFTI(DexterityFTI): diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index c13bcd1e..0e7707cf 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -1,15 +1,14 @@ +from collective.contact.core.behaviors import IContactDetails +from collective.contact.core.behaviors import IRelatedOrganizations +from collective.contact.core.content.organization import IOrganization +from collective.contact.core.content.person import IPerson +from collective.contact.core.content.position import IPosition +from collective.contact.core.interfaces import IHeldPosition from datetime import date from plone import api from plone.indexer import indexer from Products.CMFPlone.utils import safe_unicode -from collective.contact.core.content.organization import IOrganization -from collective.contact.core.content.position import IPosition -from collective.contact.core.content.person import IPerson -from collective.contact.core.behaviors import IContactDetails -from collective.contact.core.behaviors import IRelatedOrganizations -from collective.contact.core.interfaces import IHeldPosition - @indexer(IOrganization) def organization_searchable_text(organization): diff --git a/src/collective/contact/core/interfaces.py b/src/collective/contact/core/interfaces.py index 41f43124..e0335945 100755 --- a/src/collective/contact/core/interfaces.py +++ b/src/collective/contact/core/interfaces.py @@ -1,13 +1,11 @@ -from zope.interface import Interface -from zope import schema - -from plone.namedfile.field import NamedImage -from plone.supermodel import model - from collective.contact.core import _ from collective.contact.core.schema import ContactChoice from collective.contact.widget.interfaces import IContactContent from collective.contact.widget.source import ContactSourceBinder +from plone.namedfile.field import NamedImage +from plone.supermodel import model +from zope import schema +from zope.interface import Interface class IContactable(Interface): diff --git a/src/collective/contact/core/schema.py b/src/collective/contact/core/schema.py index 1be2b3d6..cc3be3d2 100755 --- a/src/collective/contact/core/schema.py +++ b/src/collective/contact/core/schema.py @@ -1 +1,2 @@ -from collective.contact.widget.schema import ContactList, ContactChoice +from collective.contact.widget.schema import ContactChoice +from collective.contact.widget.schema import ContactList diff --git a/src/collective/contact/core/setuphandlers.py b/src/collective/contact/core/setuphandlers.py index 40eadf10..080a9fa8 100644 --- a/src/collective/contact/core/setuphandlers.py +++ b/src/collective/contact/core/setuphandlers.py @@ -1,19 +1,20 @@ # -*- coding: utf-8 -*- # GNU General Public License (GPL) -import datetime -import logging - +from collective.contact.core.interfaces import IContactCoreParameters from plone import api from z3c.relationfield.relation import RelationValue from zope import component from zope.intid.interfaces import IIntIds from zope.lifecycleevent import modified +import datetime +import logging + + # from plone.registry.interfaces import IRegistry logger = logging.getLogger('collective.contact.core: setuphandlers') -from collective.contact.core.interfaces import IContactCoreParameters def isNotCollectiveContactContentProfile(context): diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index bb817b7b..5276dc4e 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -3,14 +3,14 @@ from collective.contact.core.content.person import IPerson from collective.contact.core.content.position import IPosition from collective.contact.core.interfaces import IHeldPosition - from five import grok from z3c.form.interfaces import NO_VALUE from zope.container.contained import ContainerModifiedEvent -from zope.lifecycleevent.interfaces import IObjectAddedEvent, \ - IObjectModifiedEvent +from zope.lifecycleevent.interfaces import IObjectAddedEvent +from zope.lifecycleevent.interfaces import IObjectModifiedEvent from zope.schema import getFields + # update indexes of related content when a content is modified # you can monkey patch this value if you have an index that needs this indexes_to_update = ['SearchableText'] diff --git a/src/collective/contact/core/testing.py b/src/collective/contact/core/testing.py index f5892d3c..41e8cf94 100644 --- a/src/collective/contact/core/testing.py +++ b/src/collective/contact/core/testing.py @@ -1,17 +1,18 @@ # -*- coding: utf8 -*- -import collective.contact.core from collective.contact.core.setuphandlers import create_test_contact_data - -import pkg_resources from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PloneWithPackageLayer -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from plone.testing import z2 +import collective.contact.core +import pkg_resources + + try: pkg_resources.get_distribution('plone.app.contenttypes') except pkg_resources.DistributionNotFound: diff --git a/src/collective/contact/core/tests/test_adapters.py b/src/collective/contact/core/tests/test_adapters.py index 2ff8f422..78fd4ef7 100644 --- a/src/collective/contact/core/tests/test_adapters.py +++ b/src/collective/contact/core/tests/test_adapters.py @@ -1,12 +1,10 @@ # -*- coding: utf8 -*- -import datetime -import unittest - -from collective.contact.core.interfaces import IVCard, IPersonHeldPositions, \ - IContactable, IContactCoreParameters +from collective.contact.core.interfaces import IContactable +from collective.contact.core.interfaces import IContactCoreParameters +from collective.contact.core.interfaces import IPersonHeldPositions +from collective.contact.core.interfaces import IVCard from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION - from ecreall.helpers.testing.base import BaseTest from plone import api from plone.app.testing.interfaces import TEST_USER_NAME @@ -14,6 +12,9 @@ from zope.component import getUtility from zope.intid.interfaces import IIntIds +import datetime +import unittest + class TestAdapters(unittest.TestCase, BaseTest): """Tests adapters""" diff --git a/src/collective/contact/core/tests/test_behaviors.py b/src/collective/contact/core/tests/test_behaviors.py index 4886f7b4..238f4a49 100644 --- a/src/collective/contact/core/tests/test_behaviors.py +++ b/src/collective/contact/core/tests/test_behaviors.py @@ -1,20 +1,19 @@ # -*- coding: utf8 -*- -import unittest - +from collective.contact.core.behaviors import IBirthday +from collective.contact.core.behaviors import IContactDetails +from collective.contact.core.behaviors import IGlobalPositioning +from collective.contact.core.testing import INTEGRATION +from ecreall.helpers.testing.base import BaseTest +from plone.app.testing.helpers import setRoles +from plone.app.testing.interfaces import TEST_USER_ID +from plone.app.testing.interfaces import TEST_USER_NAME +from plone.autoform.interfaces import IFormFieldProvider +from plone.behavior.interfaces import IBehavior from zope.component import getUtility from zope.event import notify from zope.lifecycleevent import ObjectModifiedEvent -from plone.behavior.interfaces import IBehavior -from plone.autoform.interfaces import IFormFieldProvider -from plone.app.testing.helpers import setRoles -from plone.app.testing.interfaces import TEST_USER_NAME, TEST_USER_ID - -from ecreall.helpers.testing.base import BaseTest - -from collective.contact.core.testing import INTEGRATION -from collective.contact.core.behaviors import IContactDetails,\ - IGlobalPositioning, IBirthday +import unittest class TestBehaviors(unittest.TestCase, BaseTest): diff --git a/src/collective/contact/core/tests/test_content_types.py b/src/collective/contact/core/tests/test_content_types.py index 3209124e..8a50e298 100644 --- a/src/collective/contact/core/tests/test_content_types.py +++ b/src/collective/contact/core/tests/test_content_types.py @@ -1,16 +1,16 @@ # -*- coding: utf8 -*- -import datetime -import unittest - from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION - from ecreall.helpers.testing.base import BaseTest from plone import api from plone.app.testing.helpers import setRoles -from plone.app.testing.interfaces import TEST_USER_ID, TEST_USER_NAME +from plone.app.testing.interfaces import TEST_USER_ID +from plone.app.testing.interfaces import TEST_USER_NAME + +import datetime +import unittest class TestContentTypes(unittest.TestCase, BaseTest): diff --git a/src/collective/contact/core/tests/test_related.py b/src/collective/contact/core/tests/test_related.py index dfcc54b1..c0daa96c 100644 --- a/src/collective/contact/core/tests/test_related.py +++ b/src/collective/contact/core/tests/test_related.py @@ -1,16 +1,16 @@ # -*- coding: utf8 -*- +from collective.contact.core.behaviors import IRelatedOrganizations +from collective.contact.core.indexers import organization_searchable_text +from collective.contact.core.testing import INTEGRATION from ecreall.helpers.testing.base import BaseTest from plone import api -import unittest from z3c.relationfield.relation import RelationValue -from zope.intid.interfaces import IIntIds from zope.component import getUtility from zope.interface import alsoProvides +from zope.intid.interfaces import IIntIds -from collective.contact.core.behaviors import IRelatedOrganizations -from collective.contact.core.testing import INTEGRATION -from collective.contact.core.indexers import organization_searchable_text +import unittest class TestSearch(unittest.TestCase, BaseTest): diff --git a/src/collective/contact/core/tests/test_robot.py b/src/collective/contact/core/tests/test_robot.py index 12bd187c..e4c277ce 100644 --- a/src/collective/contact/core/tests/test_robot.py +++ b/src/collective/contact/core/tests/test_robot.py @@ -1,9 +1,9 @@ -import os -import unittest -import robotsuite +from ..testing import ACCEPTANCE from plone.testing import layered -from ..testing import ACCEPTANCE +import os +import robotsuite +import unittest def test_suite(): diff --git a/src/collective/contact/core/tests/test_search.py b/src/collective/contact/core/tests/test_search.py index aa89468a..8138e5f0 100644 --- a/src/collective/contact/core/tests/test_search.py +++ b/src/collective/contact/core/tests/test_search.py @@ -1,17 +1,19 @@ # -*- coding: utf8 -*- -import datetime -import unittest - -from collective.contact.core.indexers import ( - held_position_searchable_text, organization_searchable_text, - person_sortable_title, held_position_sortable_title, start_date, end_date) +from collective.contact.core.indexers import end_date +from collective.contact.core.indexers import held_position_searchable_text +from collective.contact.core.indexers import held_position_sortable_title +from collective.contact.core.indexers import organization_searchable_text +from collective.contact.core.indexers import person_sortable_title +from collective.contact.core.indexers import start_date from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION - from ecreall.helpers.testing.base import BaseTest from plone import api +import datetime +import unittest + class TestSearch(unittest.TestCase, BaseTest): """Tests search""" diff --git a/src/collective/contact/core/tests/test_setup.py b/src/collective/contact/core/tests/test_setup.py index b4983baa..57304a1c 100644 --- a/src/collective/contact/core/tests/test_setup.py +++ b/src/collective/contact/core/tests/test_setup.py @@ -1,8 +1,7 @@ -import unittest - +from collective.contact.core.testing import INTEGRATION from plone import api -from collective.contact.core.testing import INTEGRATION +import unittest class TestSetup(unittest.TestCase): diff --git a/src/collective/contact/core/tests/test_utils.py b/src/collective/contact/core/tests/test_utils.py index 5535981e..f661b05a 100644 --- a/src/collective/contact/core/tests/test_utils.py +++ b/src/collective/contact/core/tests/test_utils.py @@ -1,14 +1,13 @@ # -*- coding: utf8 -*- -import unittest - from collective.contact.core.setuphandlers import create_test_held_positions from collective.contact.core.testing import INTEGRATION from collective.contact.core.utils import get_gender_and_number - from ecreall.helpers.testing.base import BaseTest from plone.app.testing.interfaces import TEST_USER_NAME +import unittest + class TestUtils(unittest.TestCase, BaseTest): layer = INTEGRATION diff --git a/src/collective/contact/core/tests/test_views.py b/src/collective/contact/core/tests/test_views.py index 647b2e23..be9ee61e 100644 --- a/src/collective/contact/core/tests/test_views.py +++ b/src/collective/contact/core/tests/test_views.py @@ -1,14 +1,11 @@ # -*- coding: utf8 -*- -import unittest - +from collective.contact.core.behaviors import ADDRESS_FIELDS from collective.contact.core.setuphandlers import create_test_held_positions - -from plone.app.testing.interfaces import TEST_USER_NAME - +from collective.contact.core.testing import INTEGRATION from ecreall.helpers.testing.base import BaseTest +from plone.app.testing.interfaces import TEST_USER_NAME -from collective.contact.core.testing import INTEGRATION -from collective.contact.core.behaviors import ADDRESS_FIELDS +import unittest class TestView(unittest.TestCase, BaseTest): diff --git a/src/collective/contact/core/tests/test_workflow.py b/src/collective/contact/core/tests/test_workflow.py index ee5a0654..bfa7f4c5 100644 --- a/src/collective/contact/core/tests/test_workflow.py +++ b/src/collective/contact/core/tests/test_workflow.py @@ -1,11 +1,10 @@ # -*- coding: utf8 -*- -import unittest - +from collective.contact.core.testing import INTEGRATION from ecreall.helpers.testing import member as memberhelpers from ecreall.helpers.testing.workflow import BaseWorkflowTest -from collective.contact.core.testing import INTEGRATION +import unittest USERDEFS = [ diff --git a/src/collective/contact/core/vocabulary.py b/src/collective/contact/core/vocabulary.py index 136f3c56..a685432f 100644 --- a/src/collective/contact/core/vocabulary.py +++ b/src/collective/contact/core/vocabulary.py @@ -1,12 +1,9 @@ -from Acquisition import aq_parent - -from zope.schema.vocabulary import SimpleVocabulary -from zope.schema.interfaces import IVocabularyFactory - -from five import grok - from . import _ +from Acquisition import aq_parent from collective.contact.core import logger +from five import grok +from zope.schema.interfaces import IVocabularyFactory +from zope.schema.vocabulary import SimpleVocabulary class NoDirectoryFound(Exception): From cb1e73b6ab2036335a5cd555e16cbb0684c743f1 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 18:30:59 +0100 Subject: [PATCH 064/144] make code-analysis happy --- src/collective/contact/core/behaviors.py | 133 +++++++++--------- .../contact/core/browser/addcontact.py | 2 +- .../contact/core/browser/excelexport.py | 13 +- src/collective/contact/core/browser/person.py | 2 - .../contact/core/browser/ttwfields.py | 2 - .../contact/core/content/directory.py | 6 +- .../contact/core/content/organization.py | 10 +- src/collective/contact/core/content/person.py | 12 +- src/collective/contact/core/fti.py | 2 +- src/collective/contact/core/plone4.py | 1 - src/collective/contact/core/schema.py | 4 +- src/collective/contact/core/setuphandlers.py | 1 - .../contact/core/tests/test_behaviors.py | 6 +- .../contact/core/tests/test_related.py | 5 +- .../contact/core/tests/test_workflow.py | 43 +++--- 15 files changed, 118 insertions(+), 124 deletions(-) diff --git a/src/collective/contact/core/behaviors.py b/src/collective/contact/core/behaviors.py index 97ddd178..583247a8 100644 --- a/src/collective/contact/core/behaviors.py +++ b/src/collective/contact/core/behaviors.py @@ -86,37 +86,37 @@ class IGlobalPositioning(model.Schema): 'global_positioning', label=_(u'Global positioning'), fields=('latitude', 'longitude') - ) + ) latitude = schema.Float( - title=_('Latitude'), - description=_('Latitude'), - min=-90.0, - max=90.0, - required=False, - ) + title=_('Latitude'), + description=_('Latitude'), + min=-90.0, + max=90.0, + required=False, + ) longitude = schema.Float( - title=_('Longitude'), - description=_('Longitude'), - min=-90.0, - max=90.0, - required=False, - ) + title=_('Longitude'), + description=_('Longitude'), + min=-90.0, + max=90.0, + required=False, + ) alsoProvides(IGlobalPositioning, IFormFieldProvider) # must stay a list so it can be patched ADDRESS_FIELDS = [ - 'street', - 'number', - 'additional_address_details', - 'zip_code', - 'city', - 'region', - 'country', - ] + 'street', + 'number', + 'additional_address_details', + 'zip_code', + 'city', + 'region', + 'country', +] # must stay a list so it can be patched @@ -126,13 +126,13 @@ class IGlobalPositioning(model.Schema): CONTACT_DETAILS_FIELDS = ( - 'phone', - 'cell_phone', - 'fax', - 'email', - 'im_handle', - 'website', - ) + 'phone', + 'cell_phone', + 'fax', + 'email', + 'im_handle', + 'website', +) class IContactDetails(model.Schema): @@ -142,45 +142,45 @@ class IContactDetails(model.Schema): 'contact_details', label=_(u'Contact details'), fields=CONTACT_DETAILS_FIELDS - ) + ) fieldset( 'address', label=_(u'Address'), fields=ADDRESS_FIELDS_PLUS_PARENT - ) + ) email = schema.TextLine( title=_(u"Email"), # constraint=validateEmail, required=False, - ) + ) phone = schema.TextLine( title=_(u"Phone"), required=False, constraint=validatePhone, - ) + ) cell_phone = schema.TextLine( title=_(u"Cell phone"), required=False, - ) + ) fax = schema.TextLine( title=_(u"Fax"), required=False, - ) + ) website = schema.TextLine( title=_(u"Website"), required=False, - ) + ) im_handle = schema.TextLine( title=_('Instant messenger handle'), required=False, - ) + ) use_parent_address = MasterSelectBoolField( title=_("Use the belonging entity address"), @@ -190,50 +190,50 @@ class IContactDetails(model.Schema): 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'region', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'zip_code', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'city', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'number', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'street', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'additional_address_details', 'action': 'show', 'hide_values': 0, 'siblings': True, - }, + }, {'masterSelector': '#form-widgets-IContactDetails-use_parent_address-0, #oform-widgets-use_parent_address-0', 'name': 'parent_address', 'action': 'hide', 'hide_values': 0, 'siblings': True, - }, + }, ), default=True, required=False, @@ -243,43 +243,43 @@ class IContactDetails(model.Schema): default_mime_type='text/html', output_mime_type='text/html', required=False, - ) + ) form.mode(parent_address='display') country = schema.TextLine( title=_('Country'), required=False, - ) + ) zip_code = schema.TextLine( title=_('Zip Code'), required=False, - ) + ) city = schema.TextLine( title=_('City'), required=False, - ) + ) street = schema.TextLine( title=_('Street'), required=False, - ) + ) number = schema.TextLine( title=_('Number'), required=False, - ) + ) region = schema.TextLine( - title=_('Region'), - required=False, - ) + title=_('Region'), + required=False, + ) additional_address_details = schema.TextLine( - title=_('Additional address details'), - required=False, - ) + title=_('Additional address details'), + required=False, + ) alsoProvides(IContactDetails, IFormFieldProvider) @@ -304,8 +304,8 @@ def default_use_parent_address(adapter): if parent_type == 'person': return False elif parent_type == 'organization' \ - and not IOrganization.providedBy(adapter.context) \ - and not IPosition.providedBy(adapter.context): + and not IOrganization.providedBy(adapter.context) \ + and not IPosition.providedBy(adapter.context): return False else: return True @@ -321,14 +321,14 @@ def default_use_parent_address(adapter): field=IContactDetails['parent_address'], view=Interface) - class IBirthday(model.Schema): form.widget(birthday=DateFieldWidget) birthday = schema.Date( title=_("Birthday"), required=False, - ) + ) + alsoProvides(IBirthday, IFormFieldProvider) @@ -341,14 +341,15 @@ class IRelatedOrganizations(model.Schema): 'related_organizations', label=_(u'Related organizations'), fields=('related_organizations',), - ) + ) related_organizations = ContactList( - value_type=ContactChoice( - description=_("Search and attach organizations related to this one"), - source=ContactSourceBinder(portal_type=("organization",)),), - required=False, - addlink=False, + value_type=ContactChoice( + description=_( + "Search and attach organizations related to this one"), + source=ContactSourceBinder(portal_type=("organization",)),), + required=False, + addlink=False, ) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 76aa2ebd..d0541b40 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -85,7 +85,7 @@ def get_directory(self): else: return results[0].getObject() - def add_contact_infos(self, widget): + def add_contact_infos(self, widget): # noqa for now 'is too complex' source = widget.bound_source criteria = source.selectable_filter.criteria addlink_enabled = widget.field.addlink diff --git a/src/collective/contact/core/browser/excelexport.py b/src/collective/contact/core/browser/excelexport.py index 2db9823e..87e0d3e6 100644 --- a/src/collective/contact/core/browser/excelexport.py +++ b/src/collective/contact/core/browser/excelexport.py @@ -23,8 +23,7 @@ HAS_EXCELEXPORT = False - -if HAS_EXCELEXPORT: +if HAS_EXCELEXPORT: # noqa for now 'is too complex' class ContactFieldRenderer(BaseFieldRenderer): adapts(IContactChoice, Interface, Interface) @@ -58,14 +57,14 @@ def get_exportables(self): try: # check if there is a specific adapter for the field name exportable = getMultiAdapter( - (field, self.context, self.request), - interface=IExportable, - name=field_name) + (field, self.context, self.request), + interface=IExportable, + name=field_name) except ComponentLookupError: # get the generic adapter for the field exportable = getMultiAdapter( - (field, self.context, self.request), - interface=IExportable) + (field, self.context, self.request), + interface=IExportable) exportables.append(exportable) diff --git a/src/collective/contact/core/browser/person.py b/src/collective/contact/core/browser/person.py index f8c6d844..8ac15a7d 100644 --- a/src/collective/contact/core/browser/person.py +++ b/src/collective/contact/core/browser/person.py @@ -1,10 +1,8 @@ # -*- coding: utf-8 -*- from AccessControl import getSecurityManager from collective.contact.core.behaviors import IContactDetails -from collective.contact.core.browser import TEMPLATES_DIR from collective.contact.core.browser.contactable import BaseView from collective.contact.core.browser.utils import date_to_DateTime -from collective.contact.core.content.person import IPerson from collective.contact.core.interfaces import IContactable from collective.contact.core.interfaces import IPersonHeldPositions from Products.Five import BrowserView diff --git a/src/collective/contact/core/browser/ttwfields.py b/src/collective/contact/core/browser/ttwfields.py index f80a1491..d2dd31d2 100644 --- a/src/collective/contact/core/browser/ttwfields.py +++ b/src/collective/contact/core/browser/ttwfields.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -from collective.contact.core.browser import TEMPLATES_DIR from collective.contact.core.browser.utils import get_ttw_fields from Products.Five import BrowserView -from zope.interface import Interface class TTWFields(BrowserView): diff --git a/src/collective/contact/core/content/directory.py b/src/collective/contact/core/content/directory.py index 71e56938..8e87d91d 100644 --- a/src/collective/contact/core/content/directory.py +++ b/src/collective/contact/core/content/directory.py @@ -28,21 +28,21 @@ class IDirectory(model.Schema): title=_("Position types"), value_type=DictRow(title=_(u'Position'), schema=INameTokenTableRowSchema) - ) + ) widget('position_types', DataGridFieldFactory, allow_reorder=True) organization_types = schema.List( title=_("Organization types"), value_type=DictRow(title=_(u'Organization'), schema=INameTokenTableRowSchema) - ) + ) widget('organization_types', DataGridFieldFactory, allow_reorder=True) organization_levels = schema.List( title=_("Organization levels"), value_type=DictRow(title=_(u'Organization level'), schema=INameTokenTableRowSchema) - ) + ) widget('organization_levels', DataGridFieldFactory, allow_reorder=True) diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index 8644f7d1..9166e35b 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -27,7 +27,7 @@ class IOrganization(model.Schema, IContactContent): activity = RichText( title=_("Activity"), required=False, - ) + ) organization_type = schema.Choice( title=_("Type or level"), @@ -37,7 +37,7 @@ class IOrganization(model.Schema, IContactContent): logo = NamedImage( title=_("Logo"), required=False, - ) + ) def get_organizations_chain(self): """Returns the list of organizations and sub-organizations in this organization @@ -143,9 +143,9 @@ def get_held_positions(self): catalog = getUtility(ICatalog) orga_intid = intids.getId(self) contact_relations = catalog.findRelations( - {'to_id': orga_intid, - 'from_interfaces_flattened': IHeldPosition, - 'from_attribute': 'position'}) + {'to_id': orga_intid, + 'from_interfaces_flattened': IHeldPosition, + 'from_attribute': 'position'}) held_positions = [] for relation in contact_relations: held_position = relation.from_object diff --git a/src/collective/contact/core/content/person.py b/src/collective/contact/core/content/person.py index ad7ba1e2..bd647af8 100644 --- a/src/collective/contact/core/content/person.py +++ b/src/collective/contact/core/content/person.py @@ -28,32 +28,32 @@ class IPerson(model.Schema, IContactContent): lastname = schema.TextLine( title=_("Lastname"), required=True - ) + ) firstname = schema.TextLine( title=_("Firstname"), required=False, - ) + ) gender = schema.Choice( title=_("Gender"), vocabulary="Genders", required=False, - ) + ) form.widget(gender=RadioFieldWidget) person_title = schema.TextLine( title=_("Person title"), description=_('help_person_title', u"Doctor, Mrs..."), required=False, - ) + ) photo = NamedImage( title=_("Photo"), required=False, - ) + ) signature = NamedImage( title=_("Signature"), description=_("Scanned signature"), required=False, - ) + ) def get_held_positions(self): """Returns held positions of this person diff --git a/src/collective/contact/core/fti.py b/src/collective/contact/core/fti.py index 6457db42..6e2b59c6 100644 --- a/src/collective/contact/core/fti.py +++ b/src/collective/contact/core/fti.py @@ -20,7 +20,7 @@ class DexterityConfigurablePolicyFTI(DexterityFTI): 'mode': 'w', 'label': 'Schema policy', 'description': 'Schema policy' - }, + }, ) schema_policy = u'dexterity' diff --git a/src/collective/contact/core/plone4.py b/src/collective/contact/core/plone4.py index 6ad6b89c..a35f16a3 100644 --- a/src/collective/contact/core/plone4.py +++ b/src/collective/contact/core/plone4.py @@ -18,7 +18,6 @@ except ImportError: from zope.interface import Interface - class IReferenceable(Interface): pass diff --git a/src/collective/contact/core/schema.py b/src/collective/contact/core/schema.py index cc3be3d2..6aaf9e37 100755 --- a/src/collective/contact/core/schema.py +++ b/src/collective/contact/core/schema.py @@ -1,2 +1,2 @@ -from collective.contact.widget.schema import ContactChoice -from collective.contact.widget.schema import ContactList +from collective.contact.widget.schema import ContactChoice # noqa for now +from collective.contact.widget.schema import ContactList # noqa for now diff --git a/src/collective/contact/core/setuphandlers.py b/src/collective/contact/core/setuphandlers.py index 080a9fa8..5ba3df8b 100644 --- a/src/collective/contact/core/setuphandlers.py +++ b/src/collective/contact/core/setuphandlers.py @@ -16,7 +16,6 @@ logger = logging.getLogger('collective.contact.core: setuphandlers') - def isNotCollectiveContactContentProfile(context): return context.readDataFile("collective_contact_core_marker.txt") is None diff --git a/src/collective/contact/core/tests/test_behaviors.py b/src/collective/contact/core/tests/test_behaviors.py index 238f4a49..f5cd04c2 100644 --- a/src/collective/contact/core/tests/test_behaviors.py +++ b/src/collective/contact/core/tests/test_behaviors.py @@ -31,11 +31,11 @@ def setUp(self): def test_behaviors_installation(self): contact_details_behavior = getUtility(IBehavior, - name='collective.contact.core.behaviors.IContactDetails') + name='collective.contact.core.behaviors.IContactDetails') global_positioning_behavior = getUtility(IBehavior, - name='collective.contact.core.behaviors.IGlobalPositioning') + name='collective.contact.core.behaviors.IGlobalPositioning') birthday_behavior = getUtility(IBehavior, - name='collective.contact.core.behaviors.IBirthday') + name='collective.contact.core.behaviors.IBirthday') self.assertEqual(contact_details_behavior.interface, IContactDetails) self.assertEqual(global_positioning_behavior.interface, IGlobalPositioning) diff --git a/src/collective/contact/core/tests/test_related.py b/src/collective/contact/core/tests/test_related.py index c0daa96c..0af98934 100644 --- a/src/collective/contact/core/tests/test_related.py +++ b/src/collective/contact/core/tests/test_related.py @@ -4,7 +4,6 @@ from collective.contact.core.indexers import organization_searchable_text from collective.contact.core.testing import INTEGRATION from ecreall.helpers.testing.base import BaseTest -from plone import api from z3c.relationfield.relation import RelationValue from zope.component import getUtility from zope.interface import alsoProvides @@ -29,7 +28,7 @@ def setUp(self): def test_related_searchable_text(self): self.assertEqual(organization_searchable_text(self.divisionalpha)(), - u"Armée de terre Corps A Division Alpha") + u"Armée de terre Corps A Division Alpha") intids = getUtility(IIntIds) alsoProvides(self.divisionalpha, IRelatedOrganizations) @@ -37,4 +36,4 @@ def test_related_searchable_text(self): RelationValue(intids.getId(self.divisionbeta)), ] self.assertEqual(organization_searchable_text(self.divisionalpha)(), - u'Armée de terre Corps A Division Beta Armée de terre Corps A Division Alpha') + u'Armée de terre Corps A Division Beta Armée de terre Corps A Division Alpha') diff --git a/src/collective/contact/core/tests/test_workflow.py b/src/collective/contact/core/tests/test_workflow.py index bfa7f4c5..db550e62 100644 --- a/src/collective/contact/core/tests/test_workflow.py +++ b/src/collective/contact/core/tests/test_workflow.py @@ -8,35 +8,36 @@ USERDEFS = [ - {'user': 'manager', 'roles': ('Manager', 'Member',), 'groups': ()}, - {'user': 'contributor', 'roles': ('Contributor', 'Member',), 'groups': ()}, - {'user': 'member', 'roles': ('Member',), 'groups': ()}, - ] + {'user': 'manager', 'roles': ('Manager', 'Member',), 'groups': ()}, + {'user': 'contributor', 'roles': ( + 'Contributor', 'Member',), 'groups': ()}, + {'user': 'member', 'roles': ('Member',), 'groups': ()}, +] PERSON_PERMISSIONS = {'active': - {'Access contents information': - ('manager', 'contributor', 'member'), - 'Modify portal content': - ('manager', 'contributor'), - 'View': - ('manager', 'contributor', 'member'), - }, - 'deactivated': - {'Access contents information': - ('manager', 'contributor'), - 'Modify portal content': - ('manager', 'contributor'), - 'View': - ('manager', 'contributor'), - }, - } + {'Access contents information': + ('manager', 'contributor', 'member'), + 'Modify portal content': + ('manager', 'contributor'), + 'View': + ('manager', 'contributor', 'member'), + }, + 'deactivated': + {'Access contents information': + ('manager', 'contributor'), + 'Modify portal content': + ('manager', 'contributor'), + 'View': + ('manager', 'contributor'), + }, + } WORKFLOW_TRACK = [('', 'active'), ('deactivate', 'deactivated'), ('activate', 'active'), - ] + ] class TestSecurity(unittest.TestCase, BaseWorkflowTest): From 1ba0b58b12f57a5e941103668d2ba156abea3761 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 6 Jan 2020 18:39:17 +0100 Subject: [PATCH 065/144] update checkouts --- checkouts.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/checkouts.cfg b/checkouts.cfg index 05126cad..daac3330 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -8,6 +8,8 @@ auto-checkout += collective.contact.widget collective.excelexport mockup + collective.z3cform.datagridfield [sources] mockup = git git@github.com:plone/mockup.git branch=thomasdesvenain +collective.z3cform.datagridfield = git git@github.com:collective/collective.z3cform.datagridfield.git From e78f33f1a7e842247ecec4321a42436b7c3f4357 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 7 Jan 2020 09:04:42 +0100 Subject: [PATCH 066/144] update sources for travis --- checkouts.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkouts.cfg b/checkouts.cfg index daac3330..d0f141ec 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -11,5 +11,5 @@ auto-checkout += collective.z3cform.datagridfield [sources] -mockup = git git@github.com:plone/mockup.git branch=thomasdesvenain -collective.z3cform.datagridfield = git git@github.com:collective/collective.z3cform.datagridfield.git +mockup = git https://github.com/plone/mockup.git branch=thomasdesvenain +collective.z3cform.datagridfield = git https://github.com/collective/collective.z3cform.datagridfield.git From 07194eb1d730bd9c7935593a2d0b71253b838f75 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 9 Jan 2020 10:27:05 +0100 Subject: [PATCH 067/144] remove Plone4 profile and cleanup --- src/collective/contact/core/configure.zcml | 2 - src/collective/contact/core/plone4.py | 60 ------------------- src/collective/contact/core/plone4.zcml | 30 ---------- src/collective/contact/core/profiles.zcml | 9 +-- .../contact/core/profiles/base/registry.xml | 3 - .../profiles/{base => default}/catalog.xml | 0 .../collective_contact_core_marker.txt | 0 .../{plone5 => default}/cssregistry.xml | 0 .../{plone5 => default}/jsregistry.xml | 0 .../profiles/{base => default}/metadata.xml | 1 + .../{base => default}/propertiestool.xml | 4 +- .../profiles/{plone5 => default}/registry.xml | 10 ++++ .../profiles/{base => default}/rolemap.xml | 0 .../core/profiles/{base => default}/skins.xml | 0 .../core/profiles/{base => default}/types.xml | 0 .../{base => default}/types/directory.xml | 0 .../{base => default}/types/held_position.xml | 0 .../{base => default}/types/organization.xml | 0 .../{base => default}/types/person.xml | 0 .../{base => default}/types/position.xml | 0 .../profiles/{base => default}/workflows.xml | 0 .../definition.xml | 0 .../core/profiles/plone4/cssregistry.xml | 10 ---- .../core/profiles/plone4/jsregistry.xml | 9 --- .../contact/core/profiles/plone4/metadata.xml | 7 --- .../plone5/collective_contact_core_marker.txt | 1 - .../contact/core/profiles/plone5/metadata.xml | 7 --- 27 files changed, 14 insertions(+), 139 deletions(-) delete mode 100644 src/collective/contact/core/plone4.py delete mode 100644 src/collective/contact/core/plone4.zcml delete mode 100644 src/collective/contact/core/profiles/base/registry.xml rename src/collective/contact/core/profiles/{base => default}/catalog.xml (100%) rename src/collective/contact/core/profiles/{plone4 => default}/collective_contact_core_marker.txt (100%) rename src/collective/contact/core/profiles/{plone5 => default}/cssregistry.xml (100%) rename src/collective/contact/core/profiles/{plone5 => default}/jsregistry.xml (100%) rename src/collective/contact/core/profiles/{base => default}/metadata.xml (94%) rename src/collective/contact/core/profiles/{base => default}/propertiestool.xml (79%) rename src/collective/contact/core/profiles/{plone5 => default}/registry.xml (72%) rename src/collective/contact/core/profiles/{base => default}/rolemap.xml (100%) rename src/collective/contact/core/profiles/{base => default}/skins.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types/directory.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types/held_position.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types/organization.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types/person.xml (100%) rename src/collective/contact/core/profiles/{base => default}/types/position.xml (100%) rename src/collective/contact/core/profiles/{base => default}/workflows.xml (100%) rename src/collective/contact/core/profiles/{base => default}/workflows/collective_contact_core_workflow/definition.xml (100%) delete mode 100644 src/collective/contact/core/profiles/plone4/cssregistry.xml delete mode 100644 src/collective/contact/core/profiles/plone4/jsregistry.xml delete mode 100644 src/collective/contact/core/profiles/plone4/metadata.xml delete mode 100644 src/collective/contact/core/profiles/plone5/collective_contact_core_marker.txt delete mode 100644 src/collective/contact/core/profiles/plone5/metadata.xml diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index ac53c86e..b050c76a 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -26,8 +26,6 @@ - - - - - - - - - - - - diff --git a/src/collective/contact/core/profiles.zcml b/src/collective/contact/core/profiles.zcml index 61df783a..e7f1d565 100644 --- a/src/collective/contact/core/profiles.zcml +++ b/src/collective/contact/core/profiles.zcml @@ -12,17 +12,10 @@ - - diff --git a/src/collective/contact/core/profiles/base/registry.xml b/src/collective/contact/core/profiles/base/registry.xml deleted file mode 100644 index e2693b16..00000000 --- a/src/collective/contact/core/profiles/base/registry.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/collective/contact/core/profiles/base/catalog.xml b/src/collective/contact/core/profiles/default/catalog.xml similarity index 100% rename from src/collective/contact/core/profiles/base/catalog.xml rename to src/collective/contact/core/profiles/default/catalog.xml diff --git a/src/collective/contact/core/profiles/plone4/collective_contact_core_marker.txt b/src/collective/contact/core/profiles/default/collective_contact_core_marker.txt similarity index 100% rename from src/collective/contact/core/profiles/plone4/collective_contact_core_marker.txt rename to src/collective/contact/core/profiles/default/collective_contact_core_marker.txt diff --git a/src/collective/contact/core/profiles/plone5/cssregistry.xml b/src/collective/contact/core/profiles/default/cssregistry.xml similarity index 100% rename from src/collective/contact/core/profiles/plone5/cssregistry.xml rename to src/collective/contact/core/profiles/default/cssregistry.xml diff --git a/src/collective/contact/core/profiles/plone5/jsregistry.xml b/src/collective/contact/core/profiles/default/jsregistry.xml similarity index 100% rename from src/collective/contact/core/profiles/plone5/jsregistry.xml rename to src/collective/contact/core/profiles/default/jsregistry.xml diff --git a/src/collective/contact/core/profiles/base/metadata.xml b/src/collective/contact/core/profiles/default/metadata.xml similarity index 94% rename from src/collective/contact/core/profiles/base/metadata.xml rename to src/collective/contact/core/profiles/default/metadata.xml index f57f7fd3..9155f07a 100644 --- a/src/collective/contact/core/profiles/base/metadata.xml +++ b/src/collective/contact/core/profiles/default/metadata.xml @@ -1,5 +1,6 @@ + 15 profile-collective.contact.widget:default profile-plone.app.dexterity:default diff --git a/src/collective/contact/core/profiles/base/propertiestool.xml b/src/collective/contact/core/profiles/default/propertiestool.xml similarity index 79% rename from src/collective/contact/core/profiles/base/propertiestool.xml rename to src/collective/contact/core/profiles/default/propertiestool.xml index e6378bf5..7ac769b9 100644 --- a/src/collective/contact/core/profiles/base/propertiestool.xml +++ b/src/collective/contact/core/profiles/default/propertiestool.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/collective/contact/core/profiles/plone5/registry.xml b/src/collective/contact/core/profiles/default/registry.xml similarity index 72% rename from src/collective/contact/core/profiles/plone5/registry.xml rename to src/collective/contact/core/profiles/default/registry.xml index 4554f011..acac234e 100644 --- a/src/collective/contact/core/profiles/plone5/registry.xml +++ b/src/collective/contact/core/profiles/default/registry.xml @@ -1,4 +1,13 @@ + + + + + + directory + + + ++resource++collective.contact.core/forms.js @@ -18,4 +27,5 @@ ++resource++collective.contact.core/forms.min.js 2019-02-15 10:32:00 + diff --git a/src/collective/contact/core/profiles/base/rolemap.xml b/src/collective/contact/core/profiles/default/rolemap.xml similarity index 100% rename from src/collective/contact/core/profiles/base/rolemap.xml rename to src/collective/contact/core/profiles/default/rolemap.xml diff --git a/src/collective/contact/core/profiles/base/skins.xml b/src/collective/contact/core/profiles/default/skins.xml similarity index 100% rename from src/collective/contact/core/profiles/base/skins.xml rename to src/collective/contact/core/profiles/default/skins.xml diff --git a/src/collective/contact/core/profiles/base/types.xml b/src/collective/contact/core/profiles/default/types.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types.xml rename to src/collective/contact/core/profiles/default/types.xml diff --git a/src/collective/contact/core/profiles/base/types/directory.xml b/src/collective/contact/core/profiles/default/types/directory.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types/directory.xml rename to src/collective/contact/core/profiles/default/types/directory.xml diff --git a/src/collective/contact/core/profiles/base/types/held_position.xml b/src/collective/contact/core/profiles/default/types/held_position.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types/held_position.xml rename to src/collective/contact/core/profiles/default/types/held_position.xml diff --git a/src/collective/contact/core/profiles/base/types/organization.xml b/src/collective/contact/core/profiles/default/types/organization.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types/organization.xml rename to src/collective/contact/core/profiles/default/types/organization.xml diff --git a/src/collective/contact/core/profiles/base/types/person.xml b/src/collective/contact/core/profiles/default/types/person.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types/person.xml rename to src/collective/contact/core/profiles/default/types/person.xml diff --git a/src/collective/contact/core/profiles/base/types/position.xml b/src/collective/contact/core/profiles/default/types/position.xml similarity index 100% rename from src/collective/contact/core/profiles/base/types/position.xml rename to src/collective/contact/core/profiles/default/types/position.xml diff --git a/src/collective/contact/core/profiles/base/workflows.xml b/src/collective/contact/core/profiles/default/workflows.xml similarity index 100% rename from src/collective/contact/core/profiles/base/workflows.xml rename to src/collective/contact/core/profiles/default/workflows.xml diff --git a/src/collective/contact/core/profiles/base/workflows/collective_contact_core_workflow/definition.xml b/src/collective/contact/core/profiles/default/workflows/collective_contact_core_workflow/definition.xml similarity index 100% rename from src/collective/contact/core/profiles/base/workflows/collective_contact_core_workflow/definition.xml rename to src/collective/contact/core/profiles/default/workflows/collective_contact_core_workflow/definition.xml diff --git a/src/collective/contact/core/profiles/plone4/cssregistry.xml b/src/collective/contact/core/profiles/plone4/cssregistry.xml deleted file mode 100644 index b8b56172..00000000 --- a/src/collective/contact/core/profiles/plone4/cssregistry.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/collective/contact/core/profiles/plone4/jsregistry.xml b/src/collective/contact/core/profiles/plone4/jsregistry.xml deleted file mode 100644 index 234e5d84..00000000 --- a/src/collective/contact/core/profiles/plone4/jsregistry.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/src/collective/contact/core/profiles/plone4/metadata.xml b/src/collective/contact/core/profiles/plone4/metadata.xml deleted file mode 100644 index e7714196..00000000 --- a/src/collective/contact/core/profiles/plone4/metadata.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 15 - - profile-collective.contact.core:install-base - - diff --git a/src/collective/contact/core/profiles/plone5/collective_contact_core_marker.txt b/src/collective/contact/core/profiles/plone5/collective_contact_core_marker.txt deleted file mode 100644 index 8089e33f..00000000 --- a/src/collective/contact/core/profiles/plone5/collective_contact_core_marker.txt +++ /dev/null @@ -1 +0,0 @@ -Profile marker \ No newline at end of file diff --git a/src/collective/contact/core/profiles/plone5/metadata.xml b/src/collective/contact/core/profiles/plone5/metadata.xml deleted file mode 100644 index e7714196..00000000 --- a/src/collective/contact/core/profiles/plone5/metadata.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 15 - - profile-collective.contact.core:install-base - - From a9bc5afeb6f91149c2c6a81582cf3badd885c99f Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 9 Jan 2020 11:06:09 +0100 Subject: [PATCH 068/144] degrok vcard export --- src/collective/contact/core/browser/configure.zcml | 7 +++++++ src/collective/contact/core/browser/vcard_export.py | 9 +++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index f18551a3..2dfed1cf 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -173,6 +173,13 @@ permission="zope2.View" /> + + diff --git a/src/collective/contact/core/browser/vcard_export.py b/src/collective/contact/core/browser/vcard_export.py index 352369f2..c85b9eab 100644 --- a/src/collective/contact/core/browser/vcard_export.py +++ b/src/collective/contact/core/browser/vcard_export.py @@ -1,14 +1,11 @@ from collective.contact.core.interfaces import IVCard from collective.contact.widget.interfaces import IContactContent -from five import grok +from Products.Five import BrowserView -class ContactVCF(grok.View): - grok.name('contact.vcf') - grok.context(IContactContent) - grok.require("zope2.View") +class ContactVCF(BrowserView): - def render(self): + def __call__(self): self.request.response.setHeader( 'Content-type', "text/x-vCard; charset=utf-8") content_disposition = 'attachment; filename=%s.vcf' % (self.context.id) From 87531e91206f82fe9c005e343ffbd4477423d81a Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 9 Jan 2020 11:14:53 +0100 Subject: [PATCH 069/144] degrok address view --- src/collective/contact/core/browser/address.py | 11 ++--------- src/collective/contact/core/browser/configure.zcml | 8 ++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/collective/contact/core/browser/address.py b/src/collective/contact/core/browser/address.py index e56c7084..e1a8d9e5 100644 --- a/src/collective/contact/core/browser/address.py +++ b/src/collective/contact/core/browser/address.py @@ -4,13 +4,10 @@ from collective.contact.core.browser import TEMPLATES_DIR from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IHeldPosition -from five import grok +from Products.Five import BrowserView from plone import api -grok.templatedir(TEMPLATES_DIR) - - def get_address(obj): """Returns a dictionary which contains address fields""" if aq_base(obj).use_parent_address is True: @@ -41,11 +38,7 @@ def get_address(obj): return address -class Address(grok.View): - grok.name('address') - grok.context(IContactDetails) - grok.require("zope2.View") - grok.template('address') +class Address(BrowserView): def namespace(self): return get_address(self.context) diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 2dfed1cf..f09a120e 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -12,6 +12,14 @@ directory="static" /> + + Date: Thu, 9 Jan 2020 15:18:07 +0100 Subject: [PATCH 070/144] degrok gender_person_title_mapping.json --- src/collective/contact/core/browser/configure.zcml | 9 +++++++++ .../contact/core/browser/person_title_mapping.py | 10 +++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index f09a120e..01ee07af 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -99,6 +99,15 @@ permission="zope2.View" /> + + + + Date: Thu, 9 Jan 2020 16:00:41 +0100 Subject: [PATCH 071/144] degrok .content --- src/collective/contact/core/configure.zcml | 1 + .../contact/core/content/configure.zcml | 27 +++++++++++++++++++ .../contact/core/content/directory.py | 5 +--- .../contact/core/content/held_position.py | 6 +---- .../contact/core/content/organization.py | 6 +---- src/collective/contact/core/content/person.py | 6 +---- .../contact/core/content/position.py | 6 +---- 7 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 src/collective/contact/core/content/configure.zcml diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index b050c76a..2caa06e0 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -21,6 +21,7 @@ + diff --git a/src/collective/contact/core/content/configure.zcml b/src/collective/contact/core/content/configure.zcml new file mode 100644 index 00000000..bf3b8b42 --- /dev/null +++ b/src/collective/contact/core/content/configure.zcml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/src/collective/contact/core/content/directory.py b/src/collective/contact/core/content/directory.py index 8e87d91d..28a2da01 100644 --- a/src/collective/contact/core/content/directory.py +++ b/src/collective/contact/core/content/directory.py @@ -2,7 +2,6 @@ from collective.contact.core import _ from collective.z3cform.datagridfield import DataGridFieldFactory from collective.z3cform.datagridfield import DictRow -from five import grok from plone.autoform.directives import widget from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy @@ -51,10 +50,8 @@ class Directory(Container): implements(IDirectory) -class DirectorySchemaPolicy(grok.GlobalUtility, - DexteritySchemaPolicy): +class DirectorySchemaPolicy(DexteritySchemaPolicy): """Schema policy for Directory content type""" - grok.name("schema_policy_directory") def bases(self, schemaName, tree): return (IDirectory, ) diff --git a/src/collective/contact/core/content/held_position.py b/src/collective/contact/core/content/held_position.py index 0e13c9ab..d5f19f4a 100644 --- a/src/collective/contact/core/content/held_position.py +++ b/src/collective/contact/core/content/held_position.py @@ -2,7 +2,6 @@ from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition from ComputedAttribute import ComputedAttribute -from five import grok from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy from Products.CMFPlone.utils import normalizeString @@ -137,11 +136,8 @@ def photo(self): return person.photo -class HeldPositionSchemaPolicy(grok.GlobalUtility, - DexteritySchemaPolicy): +class HeldPositionSchemaPolicy(DexteritySchemaPolicy): """Schema policy for HeldPosition content type""" - grok.name("schema_policy_held_position") - def bases(self, schemaName, tree): return (IHeldPosition,) diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index 9166e35b..8f2793e1 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -6,7 +6,6 @@ from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent -from five import grok from plone import api from plone.app.textfield import RichText from plone.dexterity.content import Container @@ -158,11 +157,8 @@ def get_held_positions(self): return held_positions -class OrganizationSchemaPolicy(grok.GlobalUtility, - DexteritySchemaPolicy): +class OrganizationSchemaPolicy(DexteritySchemaPolicy): """Schema policy for Organization content type""" - grok.name("schema_policy_organization") - def bases(self, schemaName, tree): return (IOrganization,) diff --git a/src/collective/contact/core/content/person.py b/src/collective/contact/core/content/person.py index bd647af8..a067009d 100644 --- a/src/collective/contact/core/content/person.py +++ b/src/collective/contact/core/content/person.py @@ -6,7 +6,6 @@ from collective.contact.core.interfaces import IHeldPosition from collective.contact.core.interfaces import IPersonHeldPositions from collective.contact.widget.interfaces import IContactContent -from five import grok from plone.autoform import directives as form from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy @@ -141,11 +140,8 @@ def get_full_name(self): return u' '.join([x for x in (self.firstname, self.lastname) if x]) -class PersonSchemaPolicy(grok.GlobalUtility, - DexteritySchemaPolicy): +class PersonSchemaPolicy(DexteritySchemaPolicy): """Schema policy for Person content type""" - grok.name("schema_policy_person") - def bases(self, schemaName, tree): return (IPerson, ) diff --git a/src/collective/contact/core/content/position.py b/src/collective/contact/core/content/position.py index 80afbd18..61c0f379 100644 --- a/src/collective/contact/core/content/position.py +++ b/src/collective/contact/core/content/position.py @@ -4,7 +4,6 @@ from collective.contact.core.browser.contactable import Contactable from collective.contact.core.interfaces import IHeldPosition from collective.contact.widget.interfaces import IContactContent -from five import grok from plone.dexterity.content import Container from plone.dexterity.schema import DexteritySchemaPolicy from plone.supermodel import model @@ -97,11 +96,8 @@ def get_held_positions(self): return held_positions -class PositionSchemaPolicy(grok.GlobalUtility, - DexteritySchemaPolicy): +class PositionSchemaPolicy(DexteritySchemaPolicy): """Schema policy for Position content type""" - grok.name("schema_policy_position") - def bases(self, schemaName, tree): return (IPosition,) From ee0115fa33fc73c58273aa47560cb35ceab68122 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 9 Jan 2020 16:16:49 +0100 Subject: [PATCH 072/144] degrok subscribers --- src/collective/contact/core/configure.zcml | 1 + src/collective/contact/core/subscribers.py | 8 ---- src/collective/contact/core/subscribers.zcml | 47 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/collective/contact/core/subscribers.zcml diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 2caa06e0..843f75f3 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -26,6 +26,7 @@ + + + + + + + + + + + + + + + From e5bcbab2acfae1348c15bd660e6d97cee36a1846 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 9 Jan 2020 16:40:40 +0100 Subject: [PATCH 073/144] degrok vocabularies --- src/collective/contact/core/configure.zcml | 1 + .../core/{vocabulary.py => vocabularies.py} | 45 +++++++++---------- src/collective/contact/core/vocabularies.zcml | 22 +++++++++ 3 files changed, 45 insertions(+), 23 deletions(-) rename src/collective/contact/core/{vocabulary.py => vocabularies.py} (68%) create mode 100644 src/collective/contact/core/vocabularies.zcml diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 843f75f3..218e1e81 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -27,6 +27,7 @@ + + + + + + + + + From 412b72d425cfaedc9ea67ff478311573403a9d14 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 10 Jan 2020 09:46:29 +0100 Subject: [PATCH 074/144] degrok addcontact --- src/collective/contact/core/browser/addcontact.py | 9 ++++----- src/collective/contact/core/browser/configure.zcml | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index d0541b40..1fe32dc8 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -5,7 +5,6 @@ from collective.contact.widget.interfaces import IContactWidgetSettings from collective.contact.widget.schema import ContactChoice from collective.contact.widget.source import ContactSourceBinder -from five import grok from plone import api from plone.dexterity.browser.add import DefaultAddForm from plone.dexterity.events import AddCancelledEvent @@ -31,6 +30,8 @@ from zope.interface import alsoProvides from zope.interface import implements from zope.interface import Interface +from zope.interface import implementer +from zope.interface import provider from zope.publisher.browser import BrowserView import copy @@ -53,10 +54,8 @@ def add_url_for_portal_type(self, directory_url, portal_type): """Return add url for the specified portal_type. """ - -class ContactWidgetSettings(grok.GlobalUtility): - grok.provides(IContactWidgetSettings) - grok.implements(ICustomSettings) +@implementer(ICustomSettings) +class ContactWidgetSettings(object): def label_for_portal_type(self, portal_type): if isinstance(portal_type, Message): diff --git a/src/collective/contact/core/browser/configure.zcml b/src/collective/contact/core/browser/configure.zcml index 01ee07af..cd4608bb 100644 --- a/src/collective/contact/core/browser/configure.zcml +++ b/src/collective/contact/core/browser/configure.zcml @@ -140,6 +140,12 @@ permission="zope2.View" /> + + + Date: Mon, 13 Jan 2020 15:19:59 +0100 Subject: [PATCH 075/144] readd IPerson --- src/collective/contact/core/browser/person.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/collective/contact/core/browser/person.py b/src/collective/contact/core/browser/person.py index 8ac15a7d..d42d26d8 100644 --- a/src/collective/contact/core/browser/person.py +++ b/src/collective/contact/core/browser/person.py @@ -3,6 +3,7 @@ from collective.contact.core.behaviors import IContactDetails from collective.contact.core.browser.contactable import BaseView from collective.contact.core.browser.utils import date_to_DateTime +from collective.contact.core.content.person import IPerson # noqa from collective.contact.core.interfaces import IContactable from collective.contact.core.interfaces import IPersonHeldPositions from Products.Five import BrowserView From 0ba7c8a4884306626ec555f9a170101763090d4b Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 13 Jan 2020 15:21:40 +0100 Subject: [PATCH 076/144] remove grok leftovers --- src/collective/contact/core/behaviors.zcml | 5 +---- src/collective/contact/core/browser/contactable.py | 4 ---- src/collective/contact/core/browser/excelexport.zcml | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/collective/contact/core/behaviors.zcml b/src/collective/contact/core/behaviors.zcml index 7cb5f056..0976ba57 100644 --- a/src/collective/contact/core/behaviors.zcml +++ b/src/collective/contact/core/behaviors.zcml @@ -2,13 +2,10 @@ xmlns="http://namespaces.zope.org/zope" xmlns:plone="http://namespaces.plone.org/plone" xmlns:i18n="http://namespaces.zope.org/i18n" - xmlns:grok="http://namespaces.zope.org/grok" i18n_domain="collective.contact.core"> - - - + Date: Mon, 13 Jan 2020 15:22:26 +0100 Subject: [PATCH 077/144] update buildout, default to 5.1 for now --- buildout.cfg | 10 ++++++++-- checkouts.cfg | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/buildout.cfg b/buildout.cfg index 18b90557..c5a74dc6 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -4,5 +4,11 @@ extends = # -*- mrbob: extra extends -*- # test_plone50.cfg -# test_plone51.cfg - test_plone52.cfg + test_plone51.cfg +# test_plone52.cfg + +[instance] +eggs += + pdbpp + Products.PDBDebugMode + robotframework-debuglibrary \ No newline at end of file diff --git a/checkouts.cfg b/checkouts.cfg index d0f141ec..d6c9e4e8 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -8,8 +8,7 @@ auto-checkout += collective.contact.widget collective.excelexport mockup - collective.z3cform.datagridfield [sources] mockup = git https://github.com/plone/mockup.git branch=thomasdesvenain -collective.z3cform.datagridfield = git https://github.com/collective/collective.z3cform.datagridfield.git +collective.contact.widget = git https://github.com/collective/collective.contact.widget.git branch=plone5-mockup From 57b6febd4daaa434dd7fd639f828977f0ad7c512 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 13 Jan 2020 18:49:11 +0100 Subject: [PATCH 078/144] update test setup based on bobtemplates --- setup.py | 4 +- src/collective/contact/core/profiles.zcml | 2 +- src/collective/contact/core/testing.py | 62 ++++++++++--------- .../contact/core/tests/test_adapters.py | 4 +- .../contact/core/tests/test_behaviors.py | 4 +- .../contact/core/tests/test_content_types.py | 4 +- .../contact/core/tests/test_related.py | 4 +- .../contact/core/tests/test_robot.py | 4 +- .../contact/core/tests/test_search.py | 4 +- .../contact/core/tests/test_setup.py | 4 +- .../contact/core/tests/test_utils.py | 4 +- .../contact/core/tests/test_views.py | 4 +- .../contact/core/tests/test_workflow.py | 5 +- 13 files changed, 57 insertions(+), 52 deletions(-) diff --git a/setup.py b/setup.py index 2f769e3a..50c2478d 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,9 @@ ], extras_require={ 'test': ['plone.app.testing', - 'plone.app.robotframework', + 'plone.testing>=5.0.0', + 'plone.app.contenttypes', + 'plone.app.robotframework[debug]', 'ecreall.helpers.testing', ], }, diff --git a/src/collective/contact/core/profiles.zcml b/src/collective/contact/core/profiles.zcml index e7f1d565..c42973e3 100644 --- a/src/collective/contact/core/profiles.zcml +++ b/src/collective/contact/core/profiles.zcml @@ -12,7 +12,7 @@ - Date: Mon, 13 Jan 2020 18:49:34 +0100 Subject: [PATCH 079/144] disable some robot tests for now --- .../core/tests/robot/test_contacts.robot | 230 +++++++++--------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/src/collective/contact/core/tests/robot/test_contacts.robot b/src/collective/contact/core/tests/robot/test_contacts.robot index 38420b26..2f6cf778 100644 --- a/src/collective/contact/core/tests/robot/test_contacts.robot +++ b/src/collective/contact/core/tests/robot/test_contacts.robot @@ -23,128 +23,128 @@ Create a new organization Go to directory Element should contain organizations Squadron five -Can create new contact from organization - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha - Page should contain link css=.addnewcontactfromorganization - Click link css=.addnewcontactfromorganization - Overlay is opened - Wait For Condition return $('.overlay h1').text() === "Create Contact" - Element should contain oform-widgets-organization-input-fields Armée de terre / Corps A / Division Alpha - Sleep 1 - Input text oform-widgets-person-widgets-query Ramb - Click element oform-widgets-person-widgets-query - Wait Until Page Contains Element css=.ac_results - Click element css=.ac_results li:nth-child(1) - Sleep 1 - Click button Add +# Can create new contact from organization +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha +# Page should contain link css=.add-contact +# Click link css=.add-contact +# Overlay is opened +# Wait For Condition return $('.overlay h1').text() === "Create Contact" +# Element should contain oform-widgets-organization-input-fields Armée de terre / Corps A / Division Alpha +# Sleep 1 +# Input text oform-widgets-person-widgets-query Ramb +# Click element oform-widgets-person-widgets-query +# Wait Until Page Contains Element css=.ac_results +# Click element css=.ac_results li:nth-child(1) +# Sleep 1 +# Click button Add -Can create new person from organization - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha - Click link css=.addnewcontactfromorganization - Wait For Condition return $('.overlay h1').text() === "Create Contact" - Element should not be visible css=#formfield-oform-widgets-person .addnew-block - Sleep 1 - Input text oform-widgets-person-widgets-query Chuck Norris - Element should become visible css=#formfield-oform-widgets-person .addnew-block - Click link Create Person - Wait Until Page Contains Add Person - ${original_speed} = Get Selenium speed - Set Selenium speed 1 - Textfield Value Should Be form-widgets-lastname Norris - Set Selenium speed ${original_speed} - Textfield Value Should Be form-widgets-firstname Chuck - Click element form-widgets-gender-0 - Click button Save - Wait Until Page Contains Chuck Norris - Sleep 1 - Click button Add - Wait Until Page Contains Element other-contacts - Element Should Contain other-contacts Chuck Norris +# Can create new person from organization +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha +# Click link css=.add-contact +# Wait For Condition return $('.overlay h1').text() === "Create Contact" +# Element should not be visible css=#formfield-oform-widgets-person .addnew-block +# Sleep 1 +# Input text oform-widgets-person-widgets-query Chuck Norris +# Element should become visible css=#formfield-oform-widgets-person .addnew-block +# Click link Create Person +# Wait Until Page Contains Add Person +# ${original_speed} = Get Selenium speed +# Set Selenium speed 1 +# Textfield Value Should Be form-widgets-lastname Norris +# Set Selenium speed ${original_speed} +# Textfield Value Should Be form-widgets-firstname Chuck +# Click element form-widgets-gender-0 +# Click button Save +# Wait Until Page Contains Chuck Norris +# Sleep 1 +# Click button Add +# Wait Until Page Contains Element other-contacts +# Element Should Contain other-contacts Chuck Norris -Can create new contact from position - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha/regimenth/brigadelh/sergent_lh - Page should contain link css=.addnewcontactfromposition - Click link css=.addnewcontactfromposition - Overlay is opened - Wait For Condition return $('.overlay h1').text() === "Create Contact" - Element should not be visible css=#oform-widgets-position-input-fields - Element should contain oform-widgets-organization-input-fields Armée de terre / Corps A / Division Alpha / Régiment H / Brigade LH - Sleep 1 - Input text oform-widgets-person-widgets-query Ramb - Click element oform-widgets-person-widgets-query - Wait Until Page Contains Element css=.ac_results - Click element css=.ac_results li:nth-child(1) - Sleep 1 - Element should become visible css=#oform-widgets-position-input-fields - Element should contain oform-widgets-position-input-fields Sergent de la brigade LH (Armée de terre / Corps A / Division Alpha / Régiment H / Brigade LH) - Click button Add +# Can create new contact from position +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha/regimenth/brigadelh/sergent_lh +# Page should contain link css=.add-contact +# Click link css=.add-contact +# Overlay is opened +# Wait For Condition return $('.overlay h1').text() === "Create Contact" +# Element should not be visible css=#oform-widgets-position-input-fields +# Element should contain oform-widgets-organization-input-fields Armée de terre / Corps A / Division Alpha / Régiment H / Brigade LH +# Sleep 1 +# Input text oform-widgets-person-widgets-query Ramb +# Click element oform-widgets-person-widgets-query +# Wait Until Page Contains Element css=.ac_results +# Click element css=.ac_results li:nth-child(1) +# Sleep 1 +# Element should become visible css=#oform-widgets-position-input-fields +# Element should contain oform-widgets-position-input-fields Sergent de la brigade LH (Armée de terre / Corps A / Division Alpha / Régiment H / Brigade LH) +# Click button Add -Show parent address if it exists in creation - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa - Add new organization - Click link Address - Checkbox Should Be Selected form-widgets-IContactDetails-use_parent_address-0 - Element should contain css=.address rue Philibert Lucot - Element should contain css=.address Orléans - Element should contain css=.address France - Element should not be visible formfield-form-widgets-IContactDetails-number - Element should not be visible formfield-form-widgets-IContactDetails-street - Element should not be visible formfield-form-widgets-IContactDetails-city - Element should not be visible formfield-form-widgets-IContactDetails-country +# Show parent address if it exists in creation +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa +# Add new organization +# Click link Address +# Checkbox Should Be Selected form-widgets-IContactDetails-use_parent_address-0 +# Element should contain css=.address rue Philibert Lucot +# Element should contain css=.address Orléans +# Element should contain css=.address France +# Element should not be visible formfield-form-widgets-IContactDetails-number +# Element should not be visible formfield-form-widgets-IContactDetails-street +# Element should not be visible formfield-form-widgets-IContactDetails-city +# Element should not be visible formfield-form-widgets-IContactDetails-country -Show parent address if it exists in edition - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha/capitaine_alpha - Click Edit In Edit Bar - Click link Address - ${original_speed} = Get Selenium speed - Set Selenium speed 1 - Checkbox Should Be Selected form-widgets-IContactDetails-use_parent_address-0 - Element should contain css=.address rue Philibert Lucot - Set Selenium speed ${original_speed} - Element should contain css=.address Orléans - Element should contain css=.address France - Element should not be visible formfield-form-widgets-IContactDetails-number - Element should not be visible formfield-form-widgets-IContactDetails-street - Element should not be visible formfield-form-widgets-IContactDetails-city - Element should not be visible formfield-form-widgets-IContactDetails-country +# Show parent address if it exists in edition +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa/divisionalpha/capitaine_alpha +# Click Edit In Edit Bar +# Click link Address +# ${original_speed} = Get Selenium speed +# Set Selenium speed 1 +# Checkbox Should Be Selected form-widgets-IContactDetails-use_parent_address-0 +# Element should contain css=.address rue Philibert Lucot +# Set Selenium speed ${original_speed} +# Element should contain css=.address Orléans +# Element should contain css=.address France +# Element should not be visible formfield-form-widgets-IContactDetails-number +# Element should not be visible formfield-form-widgets-IContactDetails-street +# Element should not be visible formfield-form-widgets-IContactDetails-city +# Element should not be visible formfield-form-widgets-IContactDetails-country -Show use parent address checkbox if no parent address when creating a position - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsb - Add new position - Click link Address - Page should contain element formfield-form-widgets-IContactDetails-number - Page should contain element formfield-form-widgets-IContactDetails-street - Page should contain element formfield-form-widgets-IContactDetails-city - Page should contain element formfield-form-widgets-IContactDetails-country - Element should be visible form-widgets-IContactDetails-use_parent_address-0 +# Show use parent address checkbox if no parent address when creating a position +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsb +# Add new position +# Click link Address +# Page should contain element formfield-form-widgets-IContactDetails-number +# Page should contain element formfield-form-widgets-IContactDetails-street +# Page should contain element formfield-form-widgets-IContactDetails-city +# Page should contain element formfield-form-widgets-IContactDetails-country +# Element should be visible form-widgets-IContactDetails-use_parent_address-0 -Don't show use parent address checkbox in edition if no parent address and use parent address is False - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa - Click Edit In Edit Bar - Click link Address - Page should contain element formfield-form-widgets-IContactDetails-number - Page should contain element formfield-form-widgets-IContactDetails-street - Page should contain element formfield-form-widgets-IContactDetails-city - Page should contain element formfield-form-widgets-IContactDetails-country - Element should not be visible form-widgets-IContactDetails-use_parent_address-0 +# Don't show use parent address checkbox in edition if no parent address and use parent address is False +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsa +# Click Edit In Edit Bar +# Click link Address +# Page should contain element formfield-form-widgets-IContactDetails-number +# Page should contain element formfield-form-widgets-IContactDetails-street +# Page should contain element formfield-form-widgets-IContactDetails-city +# Page should contain element formfield-form-widgets-IContactDetails-country +# Element should not be visible form-widgets-IContactDetails-use_parent_address-0 -Show use parent address checkbox in edition if no parent address and use parent address is True - Log in as site owner and wait - Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsb - Click Edit In Edit Bar - Click link Address - Page should contain element formfield-form-widgets-IContactDetails-number - Page should contain element formfield-form-widgets-IContactDetails-street - Page should contain element formfield-form-widgets-IContactDetails-city - Page should contain element formfield-form-widgets-IContactDetails-country - Element should be visible form-widgets-IContactDetails-use_parent_address-0 +# Show use parent address checkbox in edition if no parent address and use parent address is True +# Log in as site owner and wait +# Go to ${PLONE_URL}/mydirectory/armeedeterre/corpsb +# Click Edit In Edit Bar +# Click link Address +# Page should contain element formfield-form-widgets-IContactDetails-number +# Page should contain element formfield-form-widgets-IContactDetails-street +# Page should contain element formfield-form-widgets-IContactDetails-city +# Page should contain element formfield-form-widgets-IContactDetails-country +# Element should be visible form-widgets-IContactDetails-use_parent_address-0 *** Keywords *** Go to directory From 4f78bd8c6ed8cea5170a02f925ceca88c38aba92 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 14 Jan 2020 08:31:01 +0100 Subject: [PATCH 080/144] code cleanup --- setup.py | 4 +++- src/collective/contact/core/browser/addcontact.py | 5 ++--- src/collective/contact/core/browser/address.py | 3 +-- src/collective/contact/core/browser/person_title_mapping.py | 1 - src/collective/contact/core/browser/vcard_export.py | 1 - src/collective/contact/core/subscribers.py | 5 ----- src/collective/contact/core/testing.py | 3 +-- src/collective/contact/core/tests/test_workflow.py | 1 - src/collective/contact/core/vocabularies.py | 2 +- 9 files changed, 8 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 50c2478d..b562f7cd 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ # -*- coding: utf8 -*- -from setuptools import setup, find_packages +from setuptools import find_packages +from setuptools import setup + long_description = ( open('README.rst').read() diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index 1fe32dc8..f223da8e 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -2,7 +2,6 @@ from collective.contact.core import _ from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.person import IPerson -from collective.contact.widget.interfaces import IContactWidgetSettings from collective.contact.widget.schema import ContactChoice from collective.contact.widget.source import ContactSourceBinder from plone import api @@ -28,10 +27,9 @@ from zope.event import notify from zope.i18n import Message from zope.interface import alsoProvides +from zope.interface import implementer from zope.interface import implements from zope.interface import Interface -from zope.interface import implementer -from zope.interface import provider from zope.publisher.browser import BrowserView import copy @@ -54,6 +52,7 @@ def add_url_for_portal_type(self, directory_url, portal_type): """Return add url for the specified portal_type. """ + @implementer(ICustomSettings) class ContactWidgetSettings(object): diff --git a/src/collective/contact/core/browser/address.py b/src/collective/contact/core/browser/address.py index e1a8d9e5..a5a1f898 100644 --- a/src/collective/contact/core/browser/address.py +++ b/src/collective/contact/core/browser/address.py @@ -1,11 +1,10 @@ from Acquisition import aq_base from collective.contact.core.behaviors import ADDRESS_FIELDS from collective.contact.core.behaviors import IContactDetails -from collective.contact.core.browser import TEMPLATES_DIR from collective.contact.core.interfaces import IContactCoreParameters from collective.contact.core.interfaces import IHeldPosition -from Products.Five import BrowserView from plone import api +from Products.Five import BrowserView def get_address(obj): diff --git a/src/collective/contact/core/browser/person_title_mapping.py b/src/collective/contact/core/browser/person_title_mapping.py index 3ed19253..39c76060 100644 --- a/src/collective/contact/core/browser/person_title_mapping.py +++ b/src/collective/contact/core/browser/person_title_mapping.py @@ -2,7 +2,6 @@ from collective.contact.core import _ from Products.Five import BrowserView from zope.i18n import translate -from zope.interface import Interface import json diff --git a/src/collective/contact/core/browser/vcard_export.py b/src/collective/contact/core/browser/vcard_export.py index c85b9eab..1077df06 100644 --- a/src/collective/contact/core/browser/vcard_export.py +++ b/src/collective/contact/core/browser/vcard_export.py @@ -1,5 +1,4 @@ from collective.contact.core.interfaces import IVCard -from collective.contact.widget.interfaces import IContactContent from Products.Five import BrowserView diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index b8d87c42..e1386668 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -1,12 +1,7 @@ from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.organization import IOrganization -from collective.contact.core.content.person import IPerson -from collective.contact.core.content.position import IPosition -from collective.contact.core.interfaces import IHeldPosition from z3c.form.interfaces import NO_VALUE from zope.container.contained import ContainerModifiedEvent -from zope.lifecycleevent.interfaces import IObjectAddedEvent -from zope.lifecycleevent.interfaces import IObjectModifiedEvent from zope.schema import getFields diff --git a/src/collective/contact/core/testing.py b/src/collective/contact/core/testing.py index 9a5c9d3c..d08fd71f 100644 --- a/src/collective/contact/core/testing.py +++ b/src/collective/contact/core/testing.py @@ -3,7 +3,6 @@ from collective.contact.core.setuphandlers import create_test_contact_data from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE -from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PloneSandboxLayer @@ -12,7 +11,7 @@ from plone.testing import z2 import collective.contact.core -import pkg_resources +import collective.contact.widget class CollectiveContactCoreLayer(PloneSandboxLayer): diff --git a/src/collective/contact/core/tests/test_workflow.py b/src/collective/contact/core/tests/test_workflow.py index 9789db9e..a9b9ee08 100644 --- a/src/collective/contact/core/tests/test_workflow.py +++ b/src/collective/contact/core/tests/test_workflow.py @@ -1,7 +1,6 @@ # -*- coding: utf8 -*- from collective.contact.core.testing import COLLECTIVE_CONTACT_CORE_ACCEPTANCE_TESTING -from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE from ecreall.helpers.testing import member as memberhelpers from ecreall.helpers.testing.workflow import BaseWorkflowTest diff --git a/src/collective/contact/core/vocabularies.py b/src/collective/contact/core/vocabularies.py index 238210db..331d3eba 100644 --- a/src/collective/contact/core/vocabularies.py +++ b/src/collective/contact/core/vocabularies.py @@ -1,8 +1,8 @@ from . import _ from Acquisition import aq_parent from collective.contact.core import logger -from zope.interface import provider from zope.interface import implementer +from zope.interface import provider from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleVocabulary From 4e89d8142ba3e5f997e2065b2806768d65437681 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 14 Jan 2020 11:00:20 +0100 Subject: [PATCH 081/144] use decorators --- src/collective/contact/core/browser/addcontact.py | 7 +++---- src/collective/contact/core/browser/excelexport.py | 12 ++++++------ src/collective/contact/core/content/directory.py | 4 ++-- src/collective/contact/core/content/held_position.py | 5 ++--- src/collective/contact/core/content/organization.py | 4 ++-- src/collective/contact/core/content/person.py | 5 ++--- src/collective/contact/core/content/position.py | 5 ++--- src/collective/contact/core/fti.py | 5 ++--- 8 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/collective/contact/core/browser/addcontact.py b/src/collective/contact/core/browser/addcontact.py index f223da8e..19117e1d 100644 --- a/src/collective/contact/core/browser/addcontact.py +++ b/src/collective/contact/core/browser/addcontact.py @@ -28,7 +28,6 @@ from zope.i18n import Message from zope.interface import alsoProvides from zope.interface import implementer -from zope.interface import implements from zope.interface import Interface from zope.publisher.browser import BrowserView @@ -181,8 +180,8 @@ def add_contact_infos(self, widget): # noqa for now 'is too complex' } +@implementer(IContentProvider) class MasterSelectAddContactProvider(BrowserView): - implements(IContentProvider) def __init__(self, context, request, view): super(MasterSelectAddContactProvider, self).__init__(context, request) @@ -334,6 +333,7 @@ class IAddContact(model.Schema): source=ContactSourceBinder(portal_type="position")) +@implementer(IFieldsAndContentProvidersForm) class AddContact(DefaultAddForm, form.AddForm): """ The following is possible with this AddContact form: @@ -345,7 +345,6 @@ class AddContact(DefaultAddForm, form.AddForm): It's for this case we want no required errors in the form if the IHeldPosition required fields are not filled. """ - implements(IFieldsAndContentProvidersForm) contentProviders = ContentProviders(['organization-ms']) # contentProviders['organization-ms'] = MasterSelectAddContactProvider contentProviders['organization-ms'].position = -1 @@ -475,8 +474,8 @@ def updateWidgets(self): super(AddContactFromPosition, self).updateWidgets() +@implementer(IFieldsAndContentProvidersForm) class AddOrganization(form.AddForm): - implements(IFieldsAndContentProvidersForm) contentProviders = ContentProviders(['organization-ms']) contentProviders['organization-ms'].position = 2 label = _(u"Create ${name}", mapping={'name': _(u"organization/position")}) diff --git a/src/collective/contact/core/browser/excelexport.py b/src/collective/contact/core/browser/excelexport.py index 87e0d3e6..cfc379f8 100644 --- a/src/collective/contact/core/browser/excelexport.py +++ b/src/collective/contact/core/browser/excelexport.py @@ -5,10 +5,10 @@ from collective.contact.widget.interfaces import IContactContent from plone import api from plone.dexterity.interfaces import IDexterityFTI -from zope.component import adapts +from zope.component import adapter from zope.component import getMultiAdapter from zope.component.interfaces import ComponentLookupError -from zope.interface import implements +from zope.interface import implementer from zope.interface import Interface @@ -25,8 +25,8 @@ if HAS_EXCELEXPORT: # noqa for now 'is too complex' + @adapter(IContactChoice, Interface, Interface) class ContactFieldRenderer(BaseFieldRenderer): - adapts(IContactChoice, Interface, Interface) def render_value(self, obj): value = self.get_value(obj) @@ -41,8 +41,8 @@ def render_collection_entry(self, obj, value): else: return rel_obj.Title() + @adapter(IDexterityFTI, Interface, Interface) class HeldPositionPersonInfoExportableFactory(BaseExportableFactory): - adapts(IDexterityFTI, Interface, Interface) portal_types = ('held_position',) weight = 10 @@ -70,9 +70,9 @@ def get_exportables(self): return exportables + @implementer(IFieldValueGetter) + @adapter(IContactContent) class ContactValueGetter(object): - adapts(IContactContent) - implements(IFieldValueGetter) def __init__(self, context): self.context = context diff --git a/src/collective/contact/core/content/directory.py b/src/collective/contact/core/content/directory.py index 28a2da01..c4d9a39f 100644 --- a/src/collective/contact/core/content/directory.py +++ b/src/collective/contact/core/content/directory.py @@ -7,7 +7,7 @@ from plone.dexterity.schema import DexteritySchemaPolicy from plone.supermodel import model from zope import schema -from zope.interface import implements +from zope.interface import implementer from zope.interface import Interface @@ -45,9 +45,9 @@ class IDirectory(model.Schema): widget('organization_levels', DataGridFieldFactory, allow_reorder=True) +@implementer(IDirectory) class Directory(Container): """Directory content type""" - implements(IDirectory) class DirectorySchemaPolicy(DexteritySchemaPolicy): diff --git a/src/collective/contact/core/content/held_position.py b/src/collective/contact/core/content/held_position.py index d5f19f4a..129dd936 100644 --- a/src/collective/contact/core/content/held_position.py +++ b/src/collective/contact/core/content/held_position.py @@ -7,7 +7,7 @@ from Products.CMFPlone.utils import normalizeString from Products.CMFPlone.utils import safe_unicode from z3c.form.interfaces import NO_VALUE -from zope.interface import implements +from zope.interface import implementer def acqproperty(func): @@ -32,13 +32,12 @@ def organizations(self): return organization and organization.get_organizations_chain() or [] +@implementer(IHeldPosition) class HeldPosition(Container): """HeldPosition content type Links a Position or an Organization to a person in an organization """ - implements(IHeldPosition) - use_parent_address = NO_VALUE parent_address = NO_VALUE diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index 8f2793e1..bb8acf5b 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -16,7 +16,7 @@ from zc.relation.interfaces import ICatalog from zope import schema from zope.component import getUtility -from zope.interface import implements +from zope.interface import implementer from zope.intid.interfaces import IIntIds @@ -82,9 +82,9 @@ def organizations(self): return self.context.get_organizations_chain() +@implementer(IOrganization) class Organization(Container): """Organization content type""" - implements(IOrganization) def get_organizations_chain(self, first_index=0): """Returns the list of organizations and sub-organizations in this organization diff --git a/src/collective/contact/core/content/person.py b/src/collective/contact/core/content/person.py index a067009d..73f452b5 100644 --- a/src/collective/contact/core/content/person.py +++ b/src/collective/contact/core/content/person.py @@ -18,7 +18,7 @@ from zope import schema from zope.cachedescriptors.property import CachedProperty from zope.component import queryUtility -from zope.interface import implements +from zope.interface import implementer class IPerson(model.Schema, IContactContent): @@ -85,11 +85,10 @@ def organizations(self): return () +@implementer(IPerson) class Person(Container): """Person content type""" - implements(IPerson) - # plone.dexterity.content.Content.__getattr__ retrieve the field.default # so step 1.2.1 in z3c.form.widget.py returns something instead of NO_VALUE # then IValue adapter is not looked up... diff --git a/src/collective/contact/core/content/position.py b/src/collective/contact/core/content/position.py index 61c0f379..ba99e48c 100644 --- a/src/collective/contact/core/content/position.py +++ b/src/collective/contact/core/content/position.py @@ -11,7 +11,7 @@ from zc.relation.interfaces import ICatalog from zope import schema from zope.component import getUtility -from zope.interface import implements +from zope.interface import implementer from zope.intid.interfaces import IIntIds @@ -46,11 +46,10 @@ def organizations(self): return organization.get_organizations_chain() +@implementer(IPosition) class Position(Container): """Position content type""" - implements(IPosition) - use_parent_address = NO_VALUE parent_address = NO_VALUE diff --git a/src/collective/contact/core/fti.py b/src/collective/contact/core/fti.py index 6e2b59c6..765e57be 100644 --- a/src/collective/contact/core/fti.py +++ b/src/collective/contact/core/fti.py @@ -3,15 +3,14 @@ from plone.supermodel import loadFile from plone.supermodel import loadString from plone.supermodel.model import Model -from zope.interface import implements +from zope.interface import implementer +@implementer(IDexterityFTI) class DexterityConfigurablePolicyFTI(DexterityFTI): """A Configurable policy FTI """ - implements(IDexterityFTI) - meta_type = "Dexterity configurable policy FTI" _properties = DexterityFTI._properties + ( From 561a77a514e0be6dd6c7818eb1746bd256e32f79 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 15 Jan 2020 09:33:23 +0100 Subject: [PATCH 082/144] degrok adapters --- src/collective/contact/core/adapters.py | 22 ++++++---------------- src/collective/contact/core/configure.zcml | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/collective/contact/core/adapters.py b/src/collective/contact/core/adapters.py index 52a59052..fe2e010a 100644 --- a/src/collective/contact/core/adapters.py +++ b/src/collective/contact/core/adapters.py @@ -1,16 +1,12 @@ from collective.contact.core.behaviors import IBirthday -from collective.contact.core.content.held_position import HeldPosition from collective.contact.core.content.organization import IOrganization -from collective.contact.core.content.organization import Organization from collective.contact.core.interfaces import IContactable from collective.contact.core.interfaces import IHeldPosition from collective.contact.core.interfaces import IPersonHeldPositions -from collective.contact.core.interfaces import IVCard -from five import grok from plone import api from Products.CMFPlone.utils import safe_unicode +from zope.interface import implementer from zope.interface import implements -from zope.interface import Interface import datetime import vobject @@ -74,9 +70,7 @@ def get_vcard(self): return vcard -class ContactDetailsVCard(grok.Adapter, ContactableVCard): - grok.context(Interface) - grok.provides(IVCard) +class ContactDetailsVCard(ContactableVCard): def __init__(self, context): self.context = context @@ -90,10 +84,8 @@ def get_vcard(self): return vcard -class HeldPositionVCard(grok.Adapter, ContactableVCard): - grok.implements(IHeldPosition) - grok.context(HeldPosition) - grok.provides(IVCard) +@implementer(IHeldPosition) +class HeldPositionVCard(ContactableVCard): def __init__(self, context): self.context = context @@ -147,10 +139,8 @@ def get_vcard(self): return vcard -class OrganizationVCard(grok.Adapter, ContactableVCard): - grok.implements(IOrganization) - grok.context(Organization) - grok.provides(IVCard) +@implementer(IOrganization) +class OrganizationVCard(ContactableVCard): def __init__(self, context): self.context = context diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 218e1e81..6a934142 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -82,9 +82,28 @@ title="collective.contact.core: Use parent address" /> + + + + + + + From 466cb1433beff37ab676e3b8ddbd24cb640893f5 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 15 Jan 2020 09:35:58 +0100 Subject: [PATCH 083/144] fix UnicodeDecodeError --- src/collective/contact/core/adapters.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/adapters.py b/src/collective/contact/core/adapters.py index fe2e010a..4f14ff0f 100644 --- a/src/collective/contact/core/adapters.py +++ b/src/collective/contact/core/adapters.py @@ -77,10 +77,11 @@ def __init__(self, context): def get_vcard(self): vcard = ContactableVCard.get_vcard(self) + title = safe_unicode(self.context.Title(), encoding='utf8') vcard.add('fn') - vcard.fn.value = self.context.Title() + vcard.fn.value = title vcard.add('n') - vcard.n.value = vobject.vcard.Name(self.context.Title()) + vcard.n.value = vobject.vcard.Name(title) return vcard From be9e9a7fc26df4676a77e204c7478d6400f38ad6 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 15 Jan 2020 10:55:32 +0100 Subject: [PATCH 084/144] all grok removed --- setup.py | 1 - src/collective/contact/core/configure.zcml | 4 ---- 2 files changed, 5 deletions(-) diff --git a/setup.py b/setup.py index b562f7cd..24da5026 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,6 @@ 'collective.contact.widget > 1.2.2', 'setuptools', 'ecreall.helpers.upgrade >= 1.1.6.dev0', - 'five.grok', 'five.globalrequest', 'plone.api>=1.4.11', 'plone.app.dexterity', diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 6a934142..81db5244 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -1,17 +1,13 @@ - - - From ca56718eea0de03fed5cebd6531b093e927baa73 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 27 Jan 2020 09:47:39 +0100 Subject: [PATCH 085/144] disable legacy import step --- src/collective/contact/core/upgrades/upgrades.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/upgrades/upgrades.py b/src/collective/contact/core/upgrades/upgrades.py index 6a09ab5a..00b3a25f 100644 --- a/src/collective/contact/core/upgrades/upgrades.py +++ b/src/collective/contact/core/upgrades/upgrades.py @@ -112,6 +112,6 @@ def v14(context): def refresh_resources_registry(context): tool = IUpgradeTool(context) - tool.runImportStep('collective.contact.core', 'cssregistry') - tool.runImportStep('collective.contact.core', 'jsregistry') +# tool.runImportStep('collective.contact.core', 'cssregistry') +# tool.runImportStep('collective.contact.core', 'jsregistry') tool.runImportStep('collective.contact.core', 'plone.app.registry') From 27112ebfe2352251b62b95eb3e06c49c51a60ef0 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 27 Jan 2020 09:48:01 +0100 Subject: [PATCH 086/144] remove extra resource upgrade step --- src/collective/contact/core/upgrades/configure.zcml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index d52e9f53..29009998 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -157,12 +157,4 @@ handler=".upgrades.refresh_resources_registry" profile="collective.contact.core:default" /> - - From 77bc1de7f694430cb898a356e0cc706ca8cb012e Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Mon, 27 Jan 2020 09:48:59 +0100 Subject: [PATCH 087/144] version shift 2.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 24da5026..1985c356 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ + '\n') setup(name='collective.contact.core', - version='1.24.dev0', + version='2.0.dev0', description="Core package for collective.contact add-ons", long_description=long_description, # Get more strings from From 5116d701948f9e191cc889a84a052ecb3e74c555 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 28 Jan 2020 08:36:23 +0100 Subject: [PATCH 088/144] add contact_source index & indexer --- src/collective/contact/core/configure.zcml | 10 +++++++ src/collective/contact/core/indexers.py | 28 +++++++++++++++++++ .../contact/core/profiles/default/catalog.xml | 6 ++++ 3 files changed, 44 insertions(+) diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 81db5244..60643641 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -25,6 +25,16 @@ + + + + + + + + + + \ No newline at end of file From ffaca9d712b100349c208df774224d7cbd5f6395 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Tue, 28 Jan 2020 15:41:08 +0100 Subject: [PATCH 089/144] update checkouts - plone5-mockup-degrok --- checkouts.cfg | 6 ++++-- development.cfg | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/checkouts.cfg b/checkouts.cfg index d6c9e4e8..c9e1666a 100644 --- a/checkouts.cfg +++ b/checkouts.cfg @@ -10,5 +10,7 @@ auto-checkout += mockup [sources] -mockup = git https://github.com/plone/mockup.git branch=thomasdesvenain -collective.contact.widget = git https://github.com/collective/collective.contact.widget.git branch=plone5-mockup +mockup = git https://github.com/plone/mockup.git branch=master +#collective.contact.widget = git https://github.com/collective/collective.contact.widget.git branch=plone5-mockup +collective.contact.widget = git https://github.com/collective/collective.contact.widget.git branch=plone5-mockup-degrok +# collective.contact.widget = git https://github.com/collective/collective.contact.widget.git branch=plone5-mockup-autocomplete diff --git a/development.cfg b/development.cfg index e68a1a24..624cda49 100644 --- a/development.cfg +++ b/development.cfg @@ -5,7 +5,7 @@ parts += omelette robot eggs += - ipdb + pdbpp sources = sources [omelette] From cdf8abf143c7d20fbb9122a9376e4ab0d0ec50b4 Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Thu, 24 Jan 2019 17:57:20 +0100 Subject: [PATCH 090/144] Added method `held_position.get_label` to get the `held_position` label so it is easy to override. (cherry picked from commit 12173ae9725c7fbb1c4fac7ff6735da19c2e277d) --- CHANGES.rst | 6 ++++++ src/collective/contact/core/browser/organization.py | 2 +- src/collective/contact/core/content/held_position.py | 10 ++++++++-- src/collective/contact/core/indexers.py | 5 +++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index bc03fd4d..a9284d1c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,12 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.24 (unreleased) +----------------- + +- Added method `held_position.get_label` to get the `held_position` label so it + is easy to override. + [gbastien] 1.23 (2018-11-20) ----------------- diff --git a/src/collective/contact/core/browser/organization.py b/src/collective/contact/core/browser/organization.py index d340d01c..1452ef7e 100644 --- a/src/collective/contact/core/browser/organization.py +++ b/src/collective/contact/core/browser/organization.py @@ -69,7 +69,7 @@ def update(self): contact['person'] = person contact['title'] = person.Title() contact['held_position'] = hp.Title() - contact['label'] = hp.label + contact['label'] = hp.get_label() contact['obj'] = hp contact['display_photo'] = api.portal.get_registry_record( name='display_contact_photo_on_organization_view', diff --git a/src/collective/contact/core/content/held_position.py b/src/collective/contact/core/content/held_position.py index 129dd936..493a3207 100644 --- a/src/collective/contact/core/content/held_position.py +++ b/src/collective/contact/core/content/held_position.py @@ -49,6 +49,11 @@ def get_title(self): title = property(get_title, set_title) + def get_label(self): + """Returns the held_position label. + Made to be overrided.""" + return self.label + def get_person(self): """Returns the person who holds the position """ @@ -86,10 +91,11 @@ def Title(self, separator=u' / ', first_index=0): position = self.get_position() organization = self.get_organization() - if position is None and not self.label: + label = self.get_label() + if position is None and not label: return "(%s)" % organization.get_full_title(separator=separator, first_index=first_index).encode('utf8') # we display the position title or the label - position_title = self.label or position.title + position_title = label or position.title return "%s (%s)" % (position_title.encode('utf8'), organization.get_full_title(separator=separator, first_index=first_index).encode('utf8')) diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index 58fcc360..68117390 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -67,8 +67,9 @@ def held_position_searchable_text(obj): if organization: indexed_fields.extend(organization.get_organizations_titles()) - if obj.label: - indexed_fields.append(obj.label) + label = obj.get_label() + if label: + indexed_fields.append(label) email = IContactDetails(obj).email if email: From 77bb450f5ee5f802dd9de56727b409231078cb2d Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Mon, 13 May 2019 17:23:29 +0200 Subject: [PATCH 091/144] Use `canonical link` to call `@@gender_person_title_mapping.json`. (cherry picked from commit cfa3383168cb44ee046cbf0190db1aa263c0e01c) --- CHANGES.rst | 6 ++++++ src/collective/contact/core/browser/static/forms.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a9284d1c..2004aa01 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,12 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.25 (unreleased) +----------------- + +- Use `canonical link` to call `@@gender_person_title_mapping.json`. + [gbastien] + 1.24 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index 4b02b385..38a7f302 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -153,7 +153,7 @@ contactswidget.setup_relation_dependency = function(master_field, slave_field, r }; $(document).ready(function(){ - var url = 'gender_person_title_mapping.json'; + var url = $("link[rel='canonical']").attr('href') + '/@@gender_person_title_mapping.json'; $.get(url, function (mapping) { $(document).on( 'change', From 0115764e11501a3d174888d686dac71584e1524d Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Thu, 16 May 2019 15:05:23 +0200 Subject: [PATCH 092/144] Call @@gender_person_title_mapping.json on portal_url instead canonical url as the view is registered for *, we are always sure it can be called from anywhere (cherry picked from commit 066eda87dc1b868c2e1d9087c4265784fa6b6442) --- CHANGES.rst | 2 +- src/collective/contact/core/browser/static/forms.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2004aa01..cd9e5129 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,7 +17,7 @@ Changelog 1.25 (unreleased) ----------------- -- Use `canonical link` to call `@@gender_person_title_mapping.json`. +- Call `@@gender_person_title_mapping.json` from JS on `portal_url`. [gbastien] 1.24 (unreleased) diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index 38a7f302..62d3c98f 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -153,7 +153,8 @@ contactswidget.setup_relation_dependency = function(master_field, slave_field, r }; $(document).ready(function(){ - var url = $("link[rel='canonical']").attr('href') + '/@@gender_person_title_mapping.json'; + // call view on portal + var url = portal_url + '/@@gender_person_title_mapping.json'; $.get(url, function (mapping) { $(document).on( 'change', From cbb72e4af3a11998c5120d9a4634e043c3350041 Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Thu, 16 May 2019 16:03:29 +0200 Subject: [PATCH 093/144] Typo, replaced tabs by blanks (cherry picked from commit f86f9e9958f74f57a49dfe9b45738ed53fbdb1db) --- src/collective/contact/core/browser/static/forms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/static/forms.js b/src/collective/contact/core/browser/static/forms.js index 62d3c98f..286e6919 100644 --- a/src/collective/contact/core/browser/static/forms.js +++ b/src/collective/contact/core/browser/static/forms.js @@ -154,7 +154,7 @@ contactswidget.setup_relation_dependency = function(master_field, slave_field, r $(document).ready(function(){ // call view on portal - var url = portal_url + '/@@gender_person_title_mapping.json'; + var url = portal_url + '/@@gender_person_title_mapping.json'; $.get(url, function (mapping) { $(document).on( 'change', From 548c0e168638ec0d707a3806294420c377542f28 Mon Sep 17 00:00:00 2001 From: Nicolas Demonte Date: Thu, 23 May 2019 14:24:22 +0200 Subject: [PATCH 094/144] Index email field for contact types upgrade step needed (cherry picked from commit f24d4f03b04f7ea7e6bcb90232111d58b01a9e3b) --- src/collective/contact/core/configure.zcml | 5 +++++ src/collective/contact/core/indexers.py | 1 + src/collective/contact/core/profiles/default/catalog.xml | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 60643641..0d087013 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -35,6 +35,11 @@ factory=".indexers.contact_source" /> + + + + + + + +
\ No newline at end of file From 769201e996e1291a5af9a47ef7b962d8faefe401 Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Mon, 17 Jun 2019 15:41:50 +0200 Subject: [PATCH 095/144] Keep div and CSS id `viewlet-below-content-body` when rendering `plone.belowcontentbody` viewlets on various views. (cherry picked from commit 14589edd5abc9bb2f32a2e4b2d02482d98f1c054) --- CHANGES.rst | 8 ++++ .../contact/core/browser/templates/contact.pt | 2 +- .../core/browser/templates/directory.pt | 40 +++++++++---------- .../core/browser/templates/organization.pt | 2 +- .../contact/core/browser/templates/person.pt | 2 +- .../core/browser/templates/position.pt | 3 +- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index cd9e5129..577466f3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,10 +7,18 @@ Changelog - Use mockup for tooltips, modals and date widget. This removes Plone 4 compatibility. [thomasdesvenain] +- Set `cacheable="True"` for `style.css` in `cssregistry.xml`. + [gbastien] +- Keep div and CSS id `viewlet-below-content-body` when rendering + `plone.belowcontentbody` viewlets on various views. + [gbastien] - Do not show add link if content type is not allowed as directory subcontent. [thomasdesvenain] +1.26 (unreleased) +----------------- + - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] diff --git a/src/collective/contact/core/browser/templates/contact.pt b/src/collective/contact/core/browser/templates/contact.pt index 43221d33..42b2a622 100644 --- a/src/collective/contact/core/browser/templates/contact.pt +++ b/src/collective/contact/core/browser/templates/contact.pt @@ -37,7 +37,7 @@ -
+
diff --git a/src/collective/contact/core/browser/templates/directory.pt b/src/collective/contact/core/browser/templates/directory.pt index 7d136fbc..b1c34038 100644 --- a/src/collective/contact/core/browser/templates/directory.pt +++ b/src/collective/contact/core/browser/templates/directory.pt @@ -13,27 +13,27 @@
-
+
-

+

-
-

Organizations:

- -
+
+

Organizations:

+ +

@@ -55,7 +55,7 @@

-
+
diff --git a/src/collective/contact/core/browser/templates/organization.pt b/src/collective/contact/core/browser/templates/organization.pt index 3ca6a8d2..f3a826b9 100644 --- a/src/collective/contact/core/browser/templates/organization.pt +++ b/src/collective/contact/core/browser/templates/organization.pt @@ -102,7 +102,7 @@ -
+
diff --git a/src/collective/contact/core/browser/templates/person.pt b/src/collective/contact/core/browser/templates/person.pt index c0224482..2f7ea225 100644 --- a/src/collective/contact/core/browser/templates/person.pt +++ b/src/collective/contact/core/browser/templates/person.pt @@ -20,7 +20,7 @@
-
+
diff --git a/src/collective/contact/core/browser/templates/position.pt b/src/collective/contact/core/browser/templates/position.pt index b1c37688..73e0910f 100644 --- a/src/collective/contact/core/browser/templates/position.pt +++ b/src/collective/contact/core/browser/templates/position.pt @@ -50,7 +50,8 @@ -
+
+
From 4d8033d33b7dd1a44676204d015b4984040aaaef Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Thu, 27 Jun 2019 14:39:55 +0200 Subject: [PATCH 096/144] Extended `utils.get_gender_and_number` to manage parameters `use_by` and `use_to` that will add new values to returned result prepended by `'B'` or `'T'`. (cherry picked from commit 942d310705760275f731d23c7cf051de116eda99) --- CHANGES.rst | 4 ++++ src/collective/contact/core/tests/test_utils.py | 10 ++++++---- src/collective/contact/core/utils.py | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 577466f3..3e4c1a14 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,10 @@ Changelog - Keep div and CSS id `viewlet-below-content-body` when rendering `plone.belowcontentbody` viewlets on various views. [gbastien] +- Extended `utils.get_gender_and_number` to manage parameters `use_by` and + `use_to` that will add new values to returned result prepended by + `'B'` or `'T'`. + [gbastien] - Do not show add link if content type is not allowed as directory subcontent. [thomasdesvenain] diff --git a/src/collective/contact/core/tests/test_utils.py b/src/collective/contact/core/tests/test_utils.py index 560850c1..51ae97f6 100644 --- a/src/collective/contact/core/tests/test_utils.py +++ b/src/collective/contact/core/tests/test_utils.py @@ -60,9 +60,11 @@ def test_get_gender_and_number(self): # Male have priority over Female # Male, Plural - self.assertEqual( - get_gender_and_number([self.sergent_pepper, self.draper]), u'MP') + self.assertEqual(get_gender_and_number([self.sergent_pepper, self.draper]), u'MP') # user unicity, if we pass twice same person, it stays singular, even thru held_position - self.assertEqual( - get_gender_and_number([self.pepper, self.sergent_pepper]), u'MS') + self.assertEqual(get_gender_and_number([self.pepper, self.sergent_pepper]), u'MS') + + # parameters use_by and use_to will prepend a 'B' or 'T' to returned value + self.assertEqual(get_gender_and_number([self.sergent_pepper, self.draper], use_by=True), u'BMP') + self.assertEqual(get_gender_and_number([self.pepper, self.sergent_pepper], use_to=True), u'TMS') diff --git a/src/collective/contact/core/utils.py b/src/collective/contact/core/utils.py index 99ec2824..22d06ac1 100644 --- a/src/collective/contact/core/utils.py +++ b/src/collective/contact/core/utils.py @@ -4,11 +4,13 @@ from collective.contact.core.interfaces import IHeldPosition -def get_gender_and_number(contacts): +def get_gender_and_number(contacts, use_by=False, use_to=False): """Return gender and number of given contacts. Returns None if not genderable. Returns a 2 letters code if genderable: - first letter is for gender, M for "male", "F" for female; + --> if use_from, we prepend 'B' to gender, it will manage 'proposed by mister X'; + --> if use_to, we prepend 'T' to gender, it will manage 'propose object to mister X'. - second letter is for number, S for "Singular", "P" for "Plural". p_contacts may be any kind of contacts, we will try to get person of it.""" gender = None @@ -35,5 +37,9 @@ def get_gender_and_number(contacts): gender = person_gender res = gender if gender: + if use_by: + gender = 'B' + gender + elif use_to: + gender = 'T' + gender res = gender + (number > 1 and 'P' or 'S') return res From 9cfd02472c72ac3b16ceaf199b28f931582e95f9 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 31 Jan 2020 10:30:56 +0100 Subject: [PATCH 097/144] update changes --- CHANGES.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3e4c1a14..e67a28ce 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,8 +7,14 @@ Changelog - Use mockup for tooltips, modals and date widget. This removes Plone 4 compatibility. [thomasdesvenain] -- Set `cacheable="True"` for `style.css` in `cssregistry.xml`. - [gbastien] +- Do not show add link if content type is not allowed as directory subcontent. + [thomasdesvenain] +- Prevent address field from being erased if they are changed programmaticaly before any manual edition. + [thomasdesvenain] + +1.26 (unreleased) +----------------- + - Keep div and CSS id `viewlet-below-content-body` when rendering `plone.belowcontentbody` viewlets on various views. [gbastien] @@ -17,15 +23,6 @@ Changelog `'B'` or `'T'`. [gbastien] -- Do not show add link if content type is not allowed as directory subcontent. - [thomasdesvenain] - -1.26 (unreleased) ------------------ - -- Prevent address field from being erased if they are changed programmaticaly before any manual edition. - [thomasdesvenain] - 1.25 (unreleased) ----------------- From 62b567874d26387ff702d4f5fafb3ed4cad6e2c2 Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Thu, 27 Jun 2019 16:07:08 +0200 Subject: [PATCH 098/144] Added email index (cherry picked from commit 219be9b7dfee150a3d270d7ad1158e41e879807d) --- CHANGES.rst | 2 ++ src/collective/contact/core/indexers.py | 1 - src/collective/contact/core/upgrades/configure.zcml | 8 ++++++++ src/collective/contact/core/upgrades/upgrades.py | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index e67a28ce..6f69e220 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -22,6 +22,8 @@ Changelog `use_to` that will add new values to returned result prepended by `'B'` or `'T'`. [gbastien] +- Added email index + [sgeulette, daggelpop] 1.25 (unreleased) ----------------- diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index be3de61f..68117390 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -36,7 +36,6 @@ def contact_source(contact): except: pass return u'' - return email if email else '' @indexer(IOrganization) diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index 29009998..ab252607 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -157,4 +157,12 @@ handler=".upgrades.refresh_resources_registry" profile="collective.contact.core:default" /> + + diff --git a/src/collective/contact/core/upgrades/upgrades.py b/src/collective/contact/core/upgrades/upgrades.py index 00b3a25f..d5518531 100644 --- a/src/collective/contact/core/upgrades/upgrades.py +++ b/src/collective/contact/core/upgrades/upgrades.py @@ -110,6 +110,12 @@ def v14(context): IUpgradeTool(context).runImportStep('collective.contact.core', 'typeinfo') +def v15(context): + tool = IUpgradeTool(context) + tool.runImportStep('collective.contact.core', 'catalog') + tool.reindexContents(IContactContent, ('email',)) + + def refresh_resources_registry(context): tool = IUpgradeTool(context) # tool.runImportStep('collective.contact.core', 'cssregistry') From 551278487aa125887ba34b2c9d7e5fe45e8a84de Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 31 Jan 2020 10:36:50 +0100 Subject: [PATCH 099/144] Use sc-4.5.4-linux.tar.gz for SauceLabs --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d23ddf51..5a730096 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ after_success: # - bin/buildout -c travis.cfg -N -q -t 3 # - pip install coverage # - curl -O https://saucelabs.com/downloads/sc-4.4.11-linux.tar.gz -# - tar xzvf sc-4.4.11-linux.tar.gz +# - tar xzvf sc-4.5.4-linux.tar.gz # - ./sc-4.4.11-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TRAVIS_JOB_ID -f CONNECTED & # - JAVA_PID=$! # - bash -c "while [ ! -f CONNECTED ]; do sleep 2; done" From 6897c15d2bbb825c887c4ac04d94d3d91c8821cd Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 31 Jan 2020 10:38:05 +0100 Subject: [PATCH 100/144] Adapted travis for https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a730096..fa6cacc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,9 +61,9 @@ after_success: # - python bootstrap.py -c travis.cfg # - bin/buildout -c travis.cfg -N -q -t 3 # - pip install coverage -# - curl -O https://saucelabs.com/downloads/sc-4.4.11-linux.tar.gz +# - curl -O https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz # - tar xzvf sc-4.5.4-linux.tar.gz -# - ./sc-4.4.11-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TRAVIS_JOB_ID -f CONNECTED & +# - ./sc-4.5.4-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -i $TRAVIS_JOB_ID -f CONNECTED & # - JAVA_PID=$! # - bash -c "while [ ! -f CONNECTED ]; do sleep 2; done" # script: From d5b8bcd002126a9b9b98736ec1279eceb6e6bc1f Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Fri, 28 Jun 2019 11:13:44 +0200 Subject: [PATCH 101/144] Completed keywords and adapted project url (cherry picked from commit df6ba367fb1634a1c0da50333fd53544f300b2f5) --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1985c356..6d07ce43 100644 --- a/setup.py +++ b/setup.py @@ -33,10 +33,10 @@ "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", ], - keywords='', + keywords='plone contact management organization person position', author='"Cedric Messiant"', author_email='cedricmessiant@ecreall.com', - url='http://svn.plone.org/svn/collective/', + url='https://github.com/collective/collective.contact.core', license='GPL version 2', packages=find_packages('src'), package_dir={'': 'src'}, From 1d2a1b5ab8cc3dfaec87641111b0d3da1343fc84 Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Thu, 5 Sep 2019 15:22:55 +0200 Subject: [PATCH 102/144] Added contact_source metadata to be used in contact widget (cherry picked from commit 2963334ba6207729f6a9fdd6b5f76a1591b66473) --- CHANGES.rst | 6 ++ README.rst | 4 ++ src/collective/contact/core/configure.zcml | 5 ++ src/collective/contact/core/indexers.py | 14 ++-- src/collective/contact/core/interfaces.py | 7 ++ .../core/locales/collective.contact.core.pot | 34 +++++----- .../de/LC_MESSAGES/collective.contact.core.po | 34 +++++----- .../core/locales/de/LC_MESSAGES/plone.po | 2 +- .../fr/LC_MESSAGES/collective.contact.core.po | 66 ++++++++++--------- .../core/locales/fr/LC_MESSAGES/plone.po | 2 +- .../it/LC_MESSAGES/collective.contact.core.po | 34 +++++----- .../core/locales/it/LC_MESSAGES/plone.po | 2 +- src/collective/contact/core/locales/plone.pot | 2 +- .../sl/LC_MESSAGES/collective.contact.core.po | 34 +++++----- .../core/locales/sl/LC_MESSAGES/plone.po | 2 +- .../contact/core/profiles/default/catalog.xml | 16 ++--- .../core/profiles/default/metadata.xml | 2 +- src/collective/contact/core/subscribers.py | 37 +++++++++++ src/collective/contact/core/subscribers.zcml | 14 ++++ .../contact/core/upgrades/configure.zcml | 8 +++ .../contact/core/upgrades/upgrades.py | 7 ++ 21 files changed, 216 insertions(+), 116 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 6f69e220..d589b8ad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,12 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.27 (unreleased) +----------------- + +- Added contact_source metadata to be used in contact widget. + [sgeulette] + 1.26 (unreleased) ----------------- diff --git a/README.rst b/README.rst index c61db6e4..9106cca9 100644 --- a/README.rst +++ b/README.rst @@ -46,6 +46,10 @@ The following configuration can be adapted in the plone registry (prefix=IContac Use held positions to search persons. * use_description_to_search_person : boolean, default to True. Use description to search persons. +* display_contact_photo_on_organization_view : boolean, default to True. + Display contact photo on organization view. +* contact_source_metadata_content : choice, default to get_full_title. + Choose information displayed after a search in contact widget. Localization ============ diff --git a/src/collective/contact/core/configure.zcml b/src/collective/contact/core/configure.zcml index 0d087013..60f06c0e 100644 --- a/src/collective/contact/core/configure.zcml +++ b/src/collective/contact/core/configure.zcml @@ -40,6 +40,11 @@ factory=".indexers.contact_email" /> + + \n" "Language-Team: LANGUAGE \n" @@ -46,11 +46,11 @@ msgstr "" msgid "Additional address details" msgstr "" -#: ../interfaces.py:93 +#: ../interfaces.py:100 msgid "Additional label" msgstr "" -#: ../interfaces.py:94 +#: ../interfaces.py:101 msgid "Additional label with information that does not appear on position label" msgstr "" @@ -73,6 +73,10 @@ msgstr "" msgid "Cell phone number" msgstr "" +#: ../interfaces.py:64 +msgid "Choose information displayed after a search in contact widget." +msgstr "" + #: ../behaviors.py:250 msgid "City" msgstr "" @@ -99,7 +103,7 @@ msgid "Country" msgstr "" #: ../browser/addcontact.py:65 -#: ../browser/templates/organization.pt:74 +#: ../browser/templates/organization.pt:72 #: ../browser/templates/position.pt:41 msgid "Create ${name}" msgstr "" @@ -136,7 +140,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:28 #: ../browser/templates/heldpositions.pt:47 -#: ../interfaces.py:102 +#: ../interfaces.py:109 msgid "End date" msgstr "" @@ -250,7 +254,7 @@ msgstr "" msgid "Name" msgstr "" -#: ../browser/templates/organization.pt:59 +#: ../browser/templates/organization.pt:57 msgid "Not assigned" msgstr "" @@ -280,11 +284,11 @@ msgstr "" msgid "Organization types" msgstr "" -#: ../interfaces.py:88 +#: ../interfaces.py:95 msgid "Organization/Position" msgstr "" -#: ../browser/templates/contact.pt:17 +#: ../browser/templates/contact.pt:16 #: ../browser/templates/directory.pt:22 msgid "Organizations" msgstr "" @@ -297,7 +301,7 @@ msgstr "" msgid "Other contacts in this organization:" msgstr "" -#: ../browser/templates/organization.pt:19 +#: ../browser/templates/organization.pt:17 #: ../browser/templates/position.pt:17 msgid "Parent organizations" msgstr "" @@ -325,7 +329,7 @@ msgid "Phone number" msgstr "" #: ../content/person.py:50 -#: ../interfaces.py:106 +#: ../interfaces.py:113 msgid "Photo" msgstr "" @@ -347,7 +351,7 @@ msgstr "" msgid "Positions" msgstr "" -#: ../browser/templates/organization.pt:39 +#: ../browser/templates/organization.pt:37 msgid "Positions in this organization" msgstr "" @@ -387,7 +391,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:22 #: ../browser/templates/heldpositions.pt:42 -#: ../interfaces.py:98 +#: ../interfaces.py:105 msgid "Start date" msgstr "" @@ -458,11 +462,11 @@ msgid "collective.contact.core tests" msgstr "" #. Default: ":" -#: ../browser/templates/organization.pt:45 +#: ../browser/templates/organization.pt:43 msgid "colon" msgstr "" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "from" msgstr "" @@ -485,6 +489,6 @@ msgstr "" msgid "organization/position" msgstr "" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "to" msgstr "" diff --git a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po index bfb17299..37fa5ae8 100644 --- a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2016-11-16 11:24+0100\n" "Last-Translator: Cédric Messiant \n" "Language-Team: French\n" @@ -45,11 +45,11 @@ msgstr "Hinzufügen" msgid "Additional address details" msgstr "Zusätzliche Details Adresse" -#: ../interfaces.py:93 +#: ../interfaces.py:100 msgid "Additional label" msgstr "Zusätzliches Feld" -#: ../interfaces.py:94 +#: ../interfaces.py:101 msgid "Additional label with information that does not appear on position label" msgstr "Zusätzliches Feld mit Information die nicht im Positionsfeld aufscheint" @@ -72,6 +72,10 @@ msgstr "Mobil" msgid "Cell phone number" msgstr "Mobil" +#: ../interfaces.py:64 +msgid "Choose information displayed after a search in contact widget." +msgstr "" + #: ../behaviors.py:250 msgid "City" msgstr "Stadt" @@ -98,7 +102,7 @@ msgid "Country" msgstr "Land" #: ../browser/addcontact.py:65 -#: ../browser/templates/organization.pt:74 +#: ../browser/templates/organization.pt:72 #: ../browser/templates/position.pt:41 msgid "Create ${name}" msgstr "Eingabe ${name}" @@ -135,7 +139,7 @@ msgstr "Email" #: ../browser/basefields/templates/held_position.pt:28 #: ../browser/templates/heldpositions.pt:47 -#: ../interfaces.py:102 +#: ../interfaces.py:109 msgid "End date" msgstr "Enddatum" @@ -249,7 +253,7 @@ msgstr "" msgid "Name" msgstr "Name" -#: ../browser/templates/organization.pt:59 +#: ../browser/templates/organization.pt:57 msgid "Not assigned" msgstr "Nicht zugewiesen" @@ -279,11 +283,11 @@ msgstr "Organisationstyp" msgid "Organization types" msgstr "Organisationstypen" -#: ../interfaces.py:88 +#: ../interfaces.py:95 msgid "Organization/Position" msgstr "Organisation/Position" -#: ../browser/templates/contact.pt:17 +#: ../browser/templates/contact.pt:16 #: ../browser/templates/directory.pt:22 msgid "Organizations" msgstr "Organisationen" @@ -296,7 +300,7 @@ msgstr "Organisationen in dieser Organisation" msgid "Other contacts in this organization:" msgstr "Weitere Kontakte in dieser Organisation" -#: ../browser/templates/organization.pt:19 +#: ../browser/templates/organization.pt:17 #: ../browser/templates/position.pt:17 msgid "Parent organizations" msgstr "Übergeordnete Organisationen" @@ -324,7 +328,7 @@ msgid "Phone number" msgstr "Telefon" #: ../content/person.py:50 -#: ../interfaces.py:106 +#: ../interfaces.py:113 msgid "Photo" msgstr "Foto" @@ -346,7 +350,7 @@ msgstr "Position-Typen" msgid "Positions" msgstr "Positionen" -#: ../browser/templates/organization.pt:39 +#: ../browser/templates/organization.pt:37 msgid "Positions in this organization" msgstr "Positionen in dieser Organisation" @@ -386,7 +390,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:22 #: ../browser/templates/heldpositions.pt:42 -#: ../interfaces.py:98 +#: ../interfaces.py:105 msgid "Start date" msgstr "Beginndatum" @@ -457,11 +461,11 @@ msgid "collective.contact.core tests" msgstr "" #. Default: ":" -#: ../browser/templates/organization.pt:45 +#: ../browser/templates/organization.pt:43 msgid "colon" msgstr ":" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "from" msgstr "von" @@ -484,6 +488,6 @@ msgstr "Wenn das Element nicht vorhanden ist, kann es zur Datenbank hinzugefügt msgid "organization/position" msgstr "Organisation/Position" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "to" msgstr "bis" diff --git a/src/collective/contact/core/locales/de/LC_MESSAGES/plone.po b/src/collective/contact/core/locales/de/LC_MESSAGES/plone.po index 751656b2..ee09a6f3 100644 --- a/src/collective/contact/core/locales/de/LC_MESSAGES/plone.po +++ b/src/collective/contact/core/locales/de/LC_MESSAGES/plone.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2016-11-16 11:25+0100\n" "Last-Translator: Cédric Messiant \n" "Language-Team: Ecréall\n" diff --git a/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po index 20d6a4a1..eca636a9 100644 --- a/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2017-03-30 15:56+0200\n" "Last-Translator: Harald Friessnegger \n" "Language-Team: German \n" @@ -19,7 +19,7 @@ msgstr "" #: ../browser/addcontact.py:112 msgid "${name} (${position}" -msgstr "" +msgstr "${name} (${position}" #: ../browser/addcontact.py:333 msgid "A contact is a position held by a person in an organization" @@ -46,11 +46,11 @@ msgstr "Ajouter" msgid "Additional address details" msgstr "Complément d'adresse" -#: ../interfaces.py:93 +#: ../interfaces.py:100 msgid "Additional label" msgstr "Intitulé" -#: ../interfaces.py:94 +#: ../interfaces.py:101 msgid "Additional label with information that does not appear on position label" msgstr "Intitulé complétant l'intitulé de poste" @@ -73,6 +73,10 @@ msgstr "Téléphone portable" msgid "Cell phone number" msgstr "Numéro de téléphone portable " +#: ../interfaces.py:64 +msgid "Choose information displayed after a search in contact widget." +msgstr "Choisir les informations affichées lors d'une recherche dans un champ contact." + #: ../behaviors.py:250 msgid "City" msgstr "Ville" @@ -92,14 +96,14 @@ msgstr "Informations de contact (numéro de téléphone, adresse, email, ...)" #: ../behaviors.zcml:28 msgid "Contact have a birthday." -msgstr "" +msgstr "Ajout d'un champ anniversaire" #: ../behaviors.py:240 msgid "Country" msgstr "Pays" #: ../browser/addcontact.py:65 -#: ../browser/templates/organization.pt:74 +#: ../browser/templates/organization.pt:72 #: ../browser/templates/position.pt:41 msgid "Create ${name}" msgstr "Créer ${name}" @@ -119,7 +123,7 @@ msgstr "Annuaire" #: ../interfaces.py:59 msgid "Display contact photo on organization view (instead person content type icon)." -msgstr "" +msgstr "Afficher la photo du contact dans la vue de l'organisation (à la place de l'icône 'personne')" #: ../interfaces.py:44 msgid "Display person title in displayed person's title." @@ -136,7 +140,7 @@ msgstr "Courriel " #: ../browser/basefields/templates/held_position.pt:28 #: ../browser/templates/heldpositions.pt:47 -#: ../interfaces.py:102 +#: ../interfaces.py:109 msgid "End date" msgstr "Date de fin " @@ -167,7 +171,7 @@ msgstr "Localisation" #: ../behaviors.zcml:22 msgid "Global positioning (latitude and longitude)." -msgstr "" +msgstr "Ajout des champs latitude et longitude" #: ../profiles/default/types/held_position.xml #: ../upgrades/profiles/v2/types/held_position.xml @@ -180,11 +184,11 @@ msgstr "Identifiant de messagerie instantanée " #: ../configure.zcml:58 msgid "Installs test data for the collective.contact.core package" -msgstr "" +msgstr "Installe les données de tests de collective.contact.core" #: ../configure.zcml:50 msgid "Installs the collective.contact.core package" -msgstr "" +msgstr "Installe le package collective.contact.core" #: ../behaviors.py:171 msgid "Instant messenger handle" @@ -220,23 +224,23 @@ msgstr "Masculin" #: ../upgrades/configure.zcml:14 msgid "Migration profile for collective.contact.core to 2" -msgstr "" +msgstr "Migration de collective.contact.core vers version 2" #: ../upgrades/configure.zcml:54 msgid "Migration profile for collective.contact.core to 6" -msgstr "" +msgstr "Migration de collective.contact.core vers version 6" #: ../upgrades/configure.zcml:70 msgid "Migration profile for collective.contact.core to 7" -msgstr "" +msgstr "Migration de collective.contact.core vers version 7" #: ../upgrades/configure.zcml:86 msgid "Migration profile for collective.contact.core to 8" -msgstr "" +msgstr "Migration de collective.contact.core vers version 8" #: ../upgrades/configure.zcml:102 msgid "Migration profile for collective.contact.core to 9" -msgstr "" +msgstr "Migration de collective.contact.core vers version 9" #: ../browser/person_title_mapping.py:24 msgid "Mr" @@ -250,7 +254,7 @@ msgstr "Madame" msgid "Name" msgstr "Nom" -#: ../browser/templates/organization.pt:59 +#: ../browser/templates/organization.pt:57 msgid "Not assigned" msgstr "Non assigné" @@ -280,11 +284,11 @@ msgstr "Type d'organisation " msgid "Organization types" msgstr "Types d'organisations" -#: ../interfaces.py:88 +#: ../interfaces.py:95 msgid "Organization/Position" msgstr "Organisation/Fonction" -#: ../browser/templates/contact.pt:17 +#: ../browser/templates/contact.pt:16 #: ../browser/templates/directory.pt:22 msgid "Organizations" msgstr "Organisations " @@ -297,7 +301,7 @@ msgstr "Organisations dans cette organisation " msgid "Other contacts in this organization:" msgstr "Autres contacts dans cette organisation :" -#: ../browser/templates/organization.pt:19 +#: ../browser/templates/organization.pt:17 #: ../browser/templates/position.pt:17 msgid "Parent organizations" msgstr "Organisations parentes " @@ -325,7 +329,7 @@ msgid "Phone number" msgstr "Numéro de téléphone " #: ../content/person.py:50 -#: ../interfaces.py:106 +#: ../interfaces.py:113 msgid "Photo" msgstr "Photo" @@ -347,7 +351,7 @@ msgstr "Types de fonctions" msgid "Positions" msgstr "Fonctions occupées" -#: ../browser/templates/organization.pt:39 +#: ../browser/templates/organization.pt:37 msgid "Positions in this organization" msgstr "Fonctions dans cette organisation " @@ -387,13 +391,13 @@ msgstr "Signature" #: ../browser/basefields/templates/held_position.pt:22 #: ../browser/templates/heldpositions.pt:42 -#: ../interfaces.py:98 +#: ../interfaces.py:105 msgid "Start date" msgstr "Date de début " #: ../testing.zcml:18 msgid "Steps to ease tests of collective.contact.core" -msgstr "" +msgstr "Steps pour faciliter les tests de collective.contact.core" #: ../behaviors.py:255 msgid "Street" @@ -429,7 +433,7 @@ msgstr "Utiliser l'adresse de l'entité d'appartenance" #: ../behaviors.zcml:34 msgid "We can attach organizations on content." -msgstr "" +msgstr "Lier des organisations au contenu" #: ../behaviors.py:166 #: ../browser/templates/contactdetails.pt:50 @@ -447,22 +451,22 @@ msgstr "${street} ${number}" #: ../configure.zcml:50 msgid "collective.contact.core" -msgstr "" +msgstr "collective.contact.core" #: ../configure.zcml:58 msgid "collective.contact.core test data" -msgstr "" +msgstr "Données de tests de collective.contact.core" #: ../testing.zcml:18 msgid "collective.contact.core tests" -msgstr "" +msgstr "Tests de collective.contact.core" #. Default: ":" -#: ../browser/templates/organization.pt:45 +#: ../browser/templates/organization.pt:43 msgid "colon" msgstr " :" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "from" msgstr "de" @@ -485,6 +489,6 @@ msgstr "Si l'élément n'existe pas, vous pouvez l'ajouter à la base :" msgid "organization/position" msgstr "organisation/fonction" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "to" msgstr "à" diff --git a/src/collective/contact/core/locales/fr/LC_MESSAGES/plone.po b/src/collective/contact/core/locales/fr/LC_MESSAGES/plone.po index 3359c982..613e0134 100644 --- a/src/collective/contact/core/locales/fr/LC_MESSAGES/plone.po +++ b/src/collective/contact/core/locales/fr/LC_MESSAGES/plone.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2013-03-11 16:38+0100\n" "Last-Translator: Cédric Messiant \n" "Language-Team: Ecréall\n" diff --git a/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po index ba80dd78..9fbe62af 100644 --- a/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2016-10-04 18:45+0200\n" "Last-Translator: Luca Fabbri \n" "Language-Team: \n" @@ -48,11 +48,11 @@ msgstr "Aggiungi" msgid "Additional address details" msgstr "Dettagli aggiuntivi dell'indirizzo" -#: ../interfaces.py:93 +#: ../interfaces.py:100 msgid "Additional label" msgstr "Etichetta aggiuntiva" -#: ../interfaces.py:94 +#: ../interfaces.py:101 msgid "Additional label with information that does not appear on position label" msgstr "Etichetta aggiuntiva con informazioni che non compaiono nell'etichetta della posizione" @@ -75,6 +75,10 @@ msgstr "Telefono cellulare" msgid "Cell phone number" msgstr "Telefono cellulare" +#: ../interfaces.py:64 +msgid "Choose information displayed after a search in contact widget." +msgstr "" + #: ../behaviors.py:250 msgid "City" msgstr "Città" @@ -101,7 +105,7 @@ msgid "Country" msgstr "Paese" #: ../browser/addcontact.py:65 -#: ../browser/templates/organization.pt:74 +#: ../browser/templates/organization.pt:72 #: ../browser/templates/position.pt:41 msgid "Create ${name}" msgstr "Crea ${name}" @@ -138,7 +142,7 @@ msgstr "E-mail" #: ../browser/basefields/templates/held_position.pt:28 #: ../browser/templates/heldpositions.pt:47 -#: ../interfaces.py:102 +#: ../interfaces.py:109 msgid "End date" msgstr "Data fine" @@ -252,7 +256,7 @@ msgstr "" msgid "Name" msgstr "Nome" -#: ../browser/templates/organization.pt:59 +#: ../browser/templates/organization.pt:57 msgid "Not assigned" msgstr "Non assegnata" @@ -282,11 +286,11 @@ msgstr "Tipo organizzazione" msgid "Organization types" msgstr "Tipi di organizzazione" -#: ../interfaces.py:88 +#: ../interfaces.py:95 msgid "Organization/Position" msgstr "Organizzazione/Posizione" -#: ../browser/templates/contact.pt:17 +#: ../browser/templates/contact.pt:16 #: ../browser/templates/directory.pt:22 msgid "Organizations" msgstr "Organizzazioni" @@ -299,7 +303,7 @@ msgstr "Organizzazioni in questa organizzazione" msgid "Other contacts in this organization:" msgstr "Altri contatti in questa organizzazione:" -#: ../browser/templates/organization.pt:19 +#: ../browser/templates/organization.pt:17 #: ../browser/templates/position.pt:17 msgid "Parent organizations" msgstr "Organizzazione padre" @@ -327,7 +331,7 @@ msgid "Phone number" msgstr "Numero di telefono" #: ../content/person.py:50 -#: ../interfaces.py:106 +#: ../interfaces.py:113 msgid "Photo" msgstr "Foto" @@ -349,7 +353,7 @@ msgstr "Tipi di posizione" msgid "Positions" msgstr "Posizioni" -#: ../browser/templates/organization.pt:39 +#: ../browser/templates/organization.pt:37 msgid "Positions in this organization" msgstr "Posizione in questa organizzazione" @@ -389,7 +393,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:22 #: ../browser/templates/heldpositions.pt:42 -#: ../interfaces.py:98 +#: ../interfaces.py:105 msgid "Start date" msgstr "Datas inizio" @@ -460,11 +464,11 @@ msgid "collective.contact.core tests" msgstr "" #. Default: ":" -#: ../browser/templates/organization.pt:45 +#: ../browser/templates/organization.pt:43 msgid "colon" msgstr ":" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "from" msgstr "Da" @@ -487,6 +491,6 @@ msgstr "Se la voce non esiste, puoi aggiungerla al database:" msgid "organization/position" msgstr "organizzazione/posizione" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "to" msgstr "A" diff --git a/src/collective/contact/core/locales/it/LC_MESSAGES/plone.po b/src/collective/contact/core/locales/it/LC_MESSAGES/plone.po index 1154837d..c72fb294 100644 --- a/src/collective/contact/core/locales/it/LC_MESSAGES/plone.po +++ b/src/collective/contact/core/locales/it/LC_MESSAGES/plone.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: Luca Fabbri \n" "Language-Team: LANGUAGE \n" diff --git a/src/collective/contact/core/locales/plone.pot b/src/collective/contact/core/locales/plone.pot index 36dbd36e..a9060a46 100644 --- a/src/collective/contact/core/locales/plone.pot +++ b/src/collective/contact/core/locales/plone.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po index 1f4a32e1..0f3f39b7 100644 --- a/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2016-10-01 22:38+0200\n" "Last-Translator: Cédric Messiant \n" "Language-Team: French\n" @@ -45,11 +45,11 @@ msgstr "Dodaj" msgid "Additional address details" msgstr "Podatki o dodatnem naslovu" -#: ../interfaces.py:93 +#: ../interfaces.py:100 msgid "Additional label" msgstr "Dodatna oznaka" -#: ../interfaces.py:94 +#: ../interfaces.py:101 msgid "Additional label with information that does not appear on position label" msgstr "Dodatna oznaka z informacijami, ki niso vidne na oznaki pozicije" @@ -72,6 +72,10 @@ msgstr "GSM" msgid "Cell phone number" msgstr "GSM Številka" +#: ../interfaces.py:64 +msgid "Choose information displayed after a search in contact widget." +msgstr "" + #: ../behaviors.py:250 msgid "City" msgstr "Mesto" @@ -98,7 +102,7 @@ msgid "Country" msgstr "Država" #: ../browser/addcontact.py:65 -#: ../browser/templates/organization.pt:74 +#: ../browser/templates/organization.pt:72 #: ../browser/templates/position.pt:41 msgid "Create ${name}" msgstr "Ustvari ${name}" @@ -135,7 +139,7 @@ msgstr "Email" #: ../browser/basefields/templates/held_position.pt:28 #: ../browser/templates/heldpositions.pt:47 -#: ../interfaces.py:102 +#: ../interfaces.py:109 msgid "End date" msgstr "Končni datum" @@ -249,7 +253,7 @@ msgstr "" msgid "Name" msgstr "Ime" -#: ../browser/templates/organization.pt:59 +#: ../browser/templates/organization.pt:57 msgid "Not assigned" msgstr "Ni dodeljen" @@ -279,11 +283,11 @@ msgstr "Tip organizacije" msgid "Organization types" msgstr "Tipi organizacij" -#: ../interfaces.py:88 +#: ../interfaces.py:95 msgid "Organization/Position" msgstr "Organizacija/pozicija" -#: ../browser/templates/contact.pt:17 +#: ../browser/templates/contact.pt:16 #: ../browser/templates/directory.pt:22 msgid "Organizations" msgstr "Organizacije" @@ -296,7 +300,7 @@ msgstr "Organizacije v tej organizaciji" msgid "Other contacts in this organization:" msgstr "Drugi kontakti v tej organizaciji" -#: ../browser/templates/organization.pt:19 +#: ../browser/templates/organization.pt:17 #: ../browser/templates/position.pt:17 msgid "Parent organizations" msgstr "Krovne organizacije" @@ -324,7 +328,7 @@ msgid "Phone number" msgstr "Telefonske številke" #: ../content/person.py:50 -#: ../interfaces.py:106 +#: ../interfaces.py:113 msgid "Photo" msgstr "Foto" @@ -346,7 +350,7 @@ msgstr "Tipi pozicij" msgid "Positions" msgstr "Pozicije" -#: ../browser/templates/organization.pt:39 +#: ../browser/templates/organization.pt:37 msgid "Positions in this organization" msgstr "Pozicije v tej organizaciji" @@ -386,7 +390,7 @@ msgstr "" #: ../browser/basefields/templates/held_position.pt:22 #: ../browser/templates/heldpositions.pt:42 -#: ../interfaces.py:98 +#: ../interfaces.py:105 msgid "Start date" msgstr "Začetni datum" @@ -457,11 +461,11 @@ msgid "collective.contact.core tests" msgstr "" #. Default: ":" -#: ../browser/templates/organization.pt:45 +#: ../browser/templates/organization.pt:43 msgid "colon" msgstr "dvopičje" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "from" msgstr "od" @@ -484,6 +488,6 @@ msgstr "Če predmet ne obstaja, ga lahko dodaš v podatkovno bazo" msgid "organization/position" msgstr "Organizacija/pozicija" -#: ../browser/templates/organization.pt:55 +#: ../browser/templates/organization.pt:53 msgid "to" msgstr "za" diff --git a/src/collective/contact/core/locales/sl/LC_MESSAGES/plone.po b/src/collective/contact/core/locales/sl/LC_MESSAGES/plone.po index 82c68caa..21f1aaca 100644 --- a/src/collective/contact/core/locales/sl/LC_MESSAGES/plone.po +++ b/src/collective/contact/core/locales/sl/LC_MESSAGES/plone.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: collective.contact.core\n" -"POT-Creation-Date: 2018-10-23 08:18+0000\n" +"POT-Creation-Date: 2019-09-05 13:13+0000\n" "PO-Revision-Date: 2016-10-01 23:31+0200\n" "Last-Translator: Cédric Messiant \n" "Language-Team: Ecréall\n" diff --git a/src/collective/contact/core/profiles/default/catalog.xml b/src/collective/contact/core/profiles/default/catalog.xml index 973952fd..b45c91c9 100644 --- a/src/collective/contact/core/profiles/default/catalog.xml +++ b/src/collective/contact/core/profiles/default/catalog.xml @@ -6,15 +6,9 @@ - - - - + + + + - - - - - - - \ No newline at end of file + diff --git a/src/collective/contact/core/profiles/default/metadata.xml b/src/collective/contact/core/profiles/default/metadata.xml index 9155f07a..2bc22850 100644 --- a/src/collective/contact/core/profiles/default/metadata.xml +++ b/src/collective/contact/core/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 15 + 16 profile-collective.contact.widget:default profile-plone.app.dexterity:default diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index e1386668..5f07d70e 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -1,10 +1,35 @@ +from Acquisition import aq_get from collective.contact.core.behaviors import IContactDetails from collective.contact.core.content.organization import IOrganization +from collective.contact.core.content.person import IPerson +from collective.contact.core.content.position import IPosition +from collective.contact.core.interfaces import IContactCoreParameters +from collective.contact.core.interfaces import IHeldPosition +from collective.contact.widget.interfaces import IContactContent +from five import grok +from plone import api +from plone.app.linkintegrity.handlers import referencedObjectRemoved as baseReferencedObjectRemoved +from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo +from plone.registry.interfaces import IRecordModifiedEvent from z3c.form.interfaces import NO_VALUE +from zc.relation.interfaces import ICatalog +from zope import component from zope.container.contained import ContainerModifiedEvent +from zope.intid.interfaces import IIntIds +from zope.lifecycleevent.interfaces import IObjectAddedEvent +from zope.lifecycleevent.interfaces import IObjectModifiedEvent from zope.schema import getFields +try: + from plone.app.referenceablebehavior.referenceable import IReferenceable +except ImportError: + from zope.interface import Interface + + class IReferenceable(Interface): + pass + + # update indexes of related content when a content is modified # you can monkey patch this value if you have an index that needs this indexes_to_update = ['SearchableText'] @@ -66,3 +91,15 @@ def clear_fields_use_parent_address(obj, event): delattr(obj, field_name) except AttributeError: pass + + +def recordModified(event): + """ + Manage configuration change in registry + """ + if (IRecordModifiedEvent.providedBy(event) and event.record.interfaceName and + event.record.interface == IContactCoreParameters): + if event.record.fieldName == 'contact_source_metadata_content': + pc = api.portal.get_tool('portal_catalog') + for brain in pc(object_provides=IContactContent.__identifier__): + brain.getObject().reindexObject(idxs=['contact_source']) diff --git a/src/collective/contact/core/subscribers.zcml b/src/collective/contact/core/subscribers.zcml index cfc2dbd0..24b7b8f2 100644 --- a/src/collective/contact/core/subscribers.zcml +++ b/src/collective/contact/core/subscribers.zcml @@ -44,4 +44,18 @@ handler=".subscribers.clear_fields_use_parent_address" /> + + + + + + diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index ab252607..cd86ab45 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -165,4 +165,12 @@ handler=".upgrades.v15" profile="collective.contact.core:default" /> + + diff --git a/src/collective/contact/core/upgrades/upgrades.py b/src/collective/contact/core/upgrades/upgrades.py index d5518531..a67e5ae1 100644 --- a/src/collective/contact/core/upgrades/upgrades.py +++ b/src/collective/contact/core/upgrades/upgrades.py @@ -116,6 +116,13 @@ def v15(context): tool.reindexContents(IContactContent, ('email',)) +def v16(context): + tool = IUpgradeTool(context) + tool.runImportStep('collective.contact.core', 'plone.app.registry') + tool.runImportStep('collective.contact.core', 'catalog') + tool.reindexContents(IContactContent, ('contact_source',)) + + def refresh_resources_registry(context): tool = IUpgradeTool(context) # tool.runImportStep('collective.contact.core', 'cssregistry') From 8d8b08150f97541f74fb8aa6a89a51f6005f365b Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Fri, 6 Sep 2019 11:10:42 +0200 Subject: [PATCH 103/144] Updated indexer and added test (cherry picked from commit e9f940cefa3f7f091a902b0a2503c6f772730924) --- src/collective/contact/core/indexers.py | 9 +++-- .../contact/core/tests/test_subscribers.py | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/collective/contact/core/tests/test_subscribers.py diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index 10e6e339..520c6f56 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -24,11 +24,10 @@ def contact_source(contact): csmc = api.portal.get_registry_record('collective.contact.core.interfaces.IContactCoreParameters.' 'contact_source_metadata_content', default=u'{gft}') variables = {'gft': contact.get_full_title()} - if '{city}' in csmc or '{street}' in csmc: - contactable = IContactable(contact) - details = contactable.get_contact_details() - variables.update(details.pop('address')) - variables.update(details) + contactable = IContactable(contact) + details = contactable.get_contact_details() + variables.update(details.pop('address')) + variables.update(details) try: return csmc.format(**variables) except: diff --git a/src/collective/contact/core/tests/test_subscribers.py b/src/collective/contact/core/tests/test_subscribers.py new file mode 100644 index 00000000..30c4fbbb --- /dev/null +++ b/src/collective/contact/core/tests/test_subscribers.py @@ -0,0 +1,36 @@ +# -*- coding: utf8 -*- + +from collective.contact.core.testing import INTEGRATION +from ecreall.helpers.testing.search import BaseSearchTest +from plone import api +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.app.testing.interfaces import TEST_USER_NAME + +import unittest + + +class TestUtils(unittest.TestCase, BaseSearchTest): + + layer = INTEGRATION + + def setUp(self): + super(TestUtils, self).setUp() + self.app = self.layer['app'] + self.portal = self.layer['portal'] + mydirectory = self.portal['mydirectory'] + self.degaulle = mydirectory['degaulle'] + + def test_recordModified(self): + """ """ + self.login(TEST_USER_NAME) + setRoles(self.portal, TEST_USER_ID, ['Manager']) + dguid = self.degaulle.UID() + record_name = 'collective.contact.core.interfaces.IContactCoreParameters.contact_source_metadata_content' + self.assertEqual(api.portal.get_registry_record(record_name), u'{gft}') + self.assertEqual(self.getBrain(dguid).contact_source, self.degaulle.get_full_title()) + # we change registry + api.portal.set_registry_record(record_name, u'{gft} from {city} on {email}') + # metadata has been updated + self.assertEqual(self.getBrain(dguid).contact_source, + u'Général Charles De Gaulle from Colombey les deux églises on charles.de.gaulle@private.com') From 5788d0fd75b38d1df0f9ceac19a88ffd75858ead Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Fri, 6 Sep 2019 12:49:18 +0200 Subject: [PATCH 104/144] Made previous update working if never applied (cherry picked from commit 93d50f556802a6292daac9d5c02887a9e8f726d4) --- src/collective/contact/core/upgrades/configure.zcml | 2 +- src/collective/contact/core/upgrades/upgrades.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index cd86ab45..c7841e9c 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -159,7 +159,7 @@ Date: Fri, 6 Sep 2019 15:31:42 +0200 Subject: [PATCH 105/144] If person details privacy is True, contact details on person don't search related items. (cherry picked from commit 8d2a1dc22193e61517a3a92363adb4962dfb8c90) --- CHANGES.rst | 2 ++ src/collective/contact/core/browser/contactable.py | 2 ++ src/collective/contact/core/tests/test_adapters.py | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d589b8ad..a2e7d108 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,8 @@ Changelog - Added contact_source metadata to be used in contact widget. [sgeulette] +- If person details privacy is True, contact details on person don't search related items. + [sgeulette] 1.26 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/contactable.py b/src/collective/contact/core/browser/contactable.py index 11a08e12..d80d017c 100644 --- a/src/collective/contact/core/browser/contactable.py +++ b/src/collective/contact/core/browser/contactable.py @@ -111,6 +111,8 @@ def _get_contactables(self): related_items = [self.context, self.held_position, self.position] + list(reversed(self.organizations)) if not api.portal.get_registry_record(name='person_contact_details_private', interface=IContactCoreParameters): related_items.insert(2, self.person) + elif self.context == self.person: + related_items = [self.context] # for a person, we get private info only for related_item in related_items: if related_item is not None \ and IContactDetails.providedBy(related_item) \ diff --git a/src/collective/contact/core/tests/test_adapters.py b/src/collective/contact/core/tests/test_adapters.py index 7e2eafc6..2497b5cc 100644 --- a/src/collective/contact/core/tests/test_adapters.py +++ b/src/collective/contact/core/tests/test_adapters.py @@ -28,6 +28,7 @@ def setUp(self): self.directory = self.portal['mydirectory'] self.degaulle = self.directory['degaulle'] self.pepper = self.directory['pepper'] + self.rambo = self.directory['rambo'] def test_gadt_vcard(self): gadt = self.degaulle['gadt'] @@ -132,6 +133,11 @@ def test_contact_details(self): details = IContactable(self.degaulle).get_contact_details(keys=('email',)) self.assertEqual(details, {'email': 'charles.de.gaulle@private.com'}) + # test with rambo data empty + details = IContactable(self.rambo).get_contact_details() + self.assertEqual(details['email'], '') + self.assertDictEqual(details['address'], {}) + # test an held position using parent address and related to an organization details = IContactable(self.degaulle['adt']).get_contact_details() self.assertEqual(details['email'], u'contact@armees.fr') # phone from org @@ -186,6 +192,12 @@ def test_contact_details(self): # # person contact details are not private api.portal.set_registry_record(name='person_contact_details_private', value=False, interface=IContactCoreParameters) + + # test with rambo data empty : we get info from relations + details = IContactable(self.rambo).get_contact_details() + self.assertEqual(details['email'], 'contact@armees.fr') + self.assertEqual(details['address']['street'], u"rue de l'harmonie") + # test an held position using parent address and related to an organization details = IContactable(self.degaulle['adt']).get_contact_details() self.assertEqual(details['email'], u'charles.de.gaulle@private.com') # phone from person From d10a4200222e1d49addb152b99a63e3ca1f7c721 Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Wed, 18 Sep 2019 15:26:53 +0200 Subject: [PATCH 106/144] Avoid key error in formatting (cherry picked from commit 1e01e52d0be290ac73b3b19e370506bd83df3f51) --- src/collective/contact/core/indexers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index 520c6f56..fbe3f639 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from collective.contact.core.behaviors import ADDRESS_FIELDS from collective.contact.core.behaviors import IContactDetails from collective.contact.core.behaviors import IRelatedOrganizations from collective.contact.core.content.organization import IOrganization @@ -26,7 +27,10 @@ def contact_source(contact): variables = {'gft': contact.get_full_title()} contactable = IContactable(contact) details = contactable.get_contact_details() - variables.update(details.pop('address')) + address = details.pop('address') + for fld in ADDRESS_FIELDS: + address.setdefault(fld, '') + variables.update(address) variables.update(details) try: return csmc.format(**variables) From 05cb53668a70ab6d9265135cef9caab9bd14d862 Mon Sep 17 00:00:00 2001 From: boulch Date: Mon, 4 Nov 2019 14:21:25 +0100 Subject: [PATCH 107/144] Safe unicode (#64) * Ensure than export is unicode encoding. * Add ZSERVER_PORT global variable env for travis (cherry picked from commit e5f02089a37385bb6af451c2eb22f28770032be7) --- .travis.yml | 7 +++++-- CHANGES.rst | 7 +++++++ src/collective/contact/core/browser/excelexport.py | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa6cacc2..4056b28d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,12 +53,14 @@ after_success: -# language: python +#language: python # python: # - 2.7 # install: # - mkdir -p buildout-cache/{eggs,downloads} -# - python bootstrap.py -c travis.cfg +# - pip install --upgrade pip +# - pip install -r requirements.txt +# - python bootstrap.py --version=2.11.4 -c travis.cfg # - bin/buildout -c travis.cfg -N -q -t 3 # - pip install coverage # - curl -O https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz @@ -86,3 +88,4 @@ after_success: # - ROBOT_BUILD_NUMBER=travis-$TRAVIS_BUILD_NUMBER # - ROBOT_REMOTE_URL=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@ondemand.saucelabs.com:80/wd/hub # - ROBOT_DESIRED_CAPABILITIES=tunnel-identifier:$TRAVIS_JOB_ID +# - ZSERVER_PORT=55001 \ No newline at end of file diff --git a/CHANGES.rst b/CHANGES.rst index a2e7d108..f2354d6e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,13 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.28 (unreleased) +----------------- + +- Ensure than export is unicode encoding. + [boulch] + + 1.27 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/excelexport.py b/src/collective/contact/core/browser/excelexport.py index cfc379f8..f8d94b5d 100644 --- a/src/collective/contact/core/browser/excelexport.py +++ b/src/collective/contact/core/browser/excelexport.py @@ -5,6 +5,7 @@ from collective.contact.widget.interfaces import IContactContent from plone import api from plone.dexterity.interfaces import IDexterityFTI +from Products.CMFPlone.utils import safe_unicode from zope.component import adapter from zope.component import getMultiAdapter from zope.component.interfaces import ComponentLookupError @@ -37,9 +38,9 @@ def render_collection_entry(self, obj, value): if not rel_obj: return u"" if IHeldPosition.providedBy(rel_obj): - return rel_obj.get_full_title() or u"" + return safe_unicode(rel_obj.get_full_title()) or u"" else: - return rel_obj.Title() + return safe_unicode(rel_obj.Title()) @adapter(IDexterityFTI, Interface, Interface) class HeldPositionPersonInfoExportableFactory(BaseExportableFactory): From 826c028c73f1594121728a4c9dfe2258a5dd6443 Mon Sep 17 00:00:00 2001 From: Stephan Geulette Date: Fri, 15 Nov 2019 16:31:18 +0100 Subject: [PATCH 108/144] Added option to display belowcontenttitle viewlet on contact views. (cherry picked from commit 60c2ad5b28736069255b6d86983a1b9e33a665c8) --- CHANGES.rst | 8 ++++++++ .../basefields/templates/held_position.pt | 6 +++++- .../basefields/templates/organization.pt | 6 +++++- .../browser/basefields/templates/person.pt | 6 +++++- .../browser/basefields/templates/position.pt | 8 ++++++-- .../contact/core/browser/basefields/views.py | 18 ++++++++++++++++++ src/collective/contact/core/interfaces.py | 5 +++++ .../contact/core/profiles/default/metadata.xml | 2 +- .../contact/core/upgrades/configure.zcml | 10 ++++++++++ 9 files changed, 63 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f2354d6e..1cb0139e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,14 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.29 (unreleased) +----------------- + +- Removed overlay on heldposition actions in person view. + [sgeulette] +- Added option to display belowcontenttitle viewlet on contact views. + [sgeulette] + 1.28 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/basefields/templates/held_position.pt b/src/collective/contact/core/browser/basefields/templates/held_position.pt index 2d6483c1..0c292e87 100644 --- a/src/collective/contact/core/browser/basefields/templates/held_position.pt +++ b/src/collective/contact/core/browser/basefields/templates/held_position.pt @@ -2,10 +2,14 @@ lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" - i18n:domain="collective.contact.core"> + i18n:domain="collective.contact.core" + tal:define="ajax_load request/ajax_load | nothing;">

+
+
diff --git a/src/collective/contact/core/browser/basefields/templates/organization.pt b/src/collective/contact/core/browser/basefields/templates/organization.pt index 4e46d974..03a13af5 100644 --- a/src/collective/contact/core/browser/basefields/templates/organization.pt +++ b/src/collective/contact/core/browser/basefields/templates/organization.pt @@ -3,7 +3,8 @@ xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" lang="en" - i18n:domain="collective.contact.core" tal:omit-tag=""> + i18n:domain="collective.contact.core" tal:omit-tag="" + tal:define="ajax_load request/ajax_load | nothing;">

@@ -13,6 +14,9 @@ tal:on-error="string:Bad logo format" />
+
+
@@ -19,6 +20,9 @@

+
+
+ i18n:domain="collective.contact.core" tal:omit-tag="" + tal:define="ajax_load request/ajax_load | nothing;">

+
+
- \ No newline at end of file + diff --git a/src/collective/contact/core/browser/basefields/views.py b/src/collective/contact/core/browser/basefields/views.py index 15e09438..9d4a743d 100644 --- a/src/collective/contact/core/browser/basefields/views.py +++ b/src/collective/contact/core/browser/basefields/views.py @@ -5,6 +5,24 @@ from Products.Five import BrowserView from zope.component import getUtility from zope.schema.interfaces import IVocabularyFactory +from collective.contact.core.content.organization import IOrganization +from collective.contact.core.content.person import IPerson +from collective.contact.core.content.position import IPosition +from collective.contact.core.interfaces import IContactCoreParameters +from collective.contact.core.interfaces import IHeldPosition +from plone import api +from zope.component import getUtility +from zope.schema.interfaces import IVocabularyFactory + + +class BaseFields(object): + + def display_below_content_title(self): + return api.portal.get_registry_record( + 'display_below_content_title_on_views', + interface=IContactCoreParameters, + default=False + ) class PersonBaseFields(BrowserView): diff --git a/src/collective/contact/core/interfaces.py b/src/collective/contact/core/interfaces.py index 4c0fe9bf..1c19d86f 100755 --- a/src/collective/contact/core/interfaces.py +++ b/src/collective/contact/core/interfaces.py @@ -58,6 +58,11 @@ class IContactCoreParameters(Interface): description=u"", required=False, default=True) + display_below_content_title_on_views = schema.Bool( + title=_(u"Display belowcontenttitle viewlet on contact views."), + description=u"", + required=False, default=False) + contact_source_metadata_content = schema.TextLine( title=_(u"Choose information displayed after a search in contact widget."), description=u"Format string containing variables like : {gft} (full title) , {number} , {street} , " diff --git a/src/collective/contact/core/profiles/default/metadata.xml b/src/collective/contact/core/profiles/default/metadata.xml index 2bc22850..e7bff334 100644 --- a/src/collective/contact/core/profiles/default/metadata.xml +++ b/src/collective/contact/core/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 16 + 17 profile-collective.contact.widget:default profile-plone.app.dexterity:default diff --git a/src/collective/contact/core/upgrades/configure.zcml b/src/collective/contact/core/upgrades/configure.zcml index c7841e9c..96bd6a19 100644 --- a/src/collective/contact/core/upgrades/configure.zcml +++ b/src/collective/contact/core/upgrades/configure.zcml @@ -173,4 +173,14 @@ handler=".upgrades.v16" profile="collective.contact.core:default" /> + + + + From e23498778ddcade8f99a1acf1443070208191ea2 Mon Sep 17 00:00:00 2001 From: Martin Peeters Date: Fri, 27 Dec 2019 13:36:59 +0100 Subject: [PATCH 109/144] Avoid an error when we try to remove a working copy from plone.app.iterate (cherry picked from commit a41ffb1f91baa1806f84ef3cc3130fdee80eefa1) --- CHANGES.rst | 6 ++++ src/collective/contact/core/subscribers.py | 38 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 1cb0139e..c57a7b3e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,12 @@ Changelog - Prevent address field from being erased if they are changed programmaticaly before any manual edition. [thomasdesvenain] +1.30 (unreleased) +----------------- + +- Avoid an error when we try to remove a working copy from plone.app.iterate + [mpeeters] + 1.29 (unreleased) ----------------- diff --git a/src/collective/contact/core/subscribers.py b/src/collective/contact/core/subscribers.py index 5f07d70e..f53495a8 100644 --- a/src/collective/contact/core/subscribers.py +++ b/src/collective/contact/core/subscribers.py @@ -8,6 +8,7 @@ from collective.contact.widget.interfaces import IContactContent from five import grok from plone import api +from plone.app.iterate.interfaces import IWorkingCopy from plone.app.linkintegrity.handlers import referencedObjectRemoved as baseReferencedObjectRemoved from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo from plone.registry.interfaces import IRecordModifiedEvent @@ -79,6 +80,43 @@ def update_related_with_organization(obj, event=None): update_related_with_organization(child) +def referenceRemoved(obj, event, toInterface=IContactContent): + """Store information about the removed link integrity reference. + """ + # inspired from z3c/relationfield/event.py:breakRelations + # and plone/app/linkintegrity/handlers.py:referenceRemoved + # if the object the event was fired on doesn't have a `REQUEST` attribute + # we can safely assume no direct user action was involved and therefore + # never raise a link integrity exception... + request = aq_get(obj, 'REQUEST', None) + if not request: + return + storage = ILinkIntegrityInfo(request) + + catalog = component.queryUtility(ICatalog) + intids = component.queryUtility(IIntIds) + if catalog is None or intids is None: + return + + # find all relations that point to us + obj_id = intids.queryId(obj) + if obj_id is None: + return + + rels = list(catalog.findRelations({'to_id': obj_id})) + for rel in rels: + if toInterface.providedBy(rel.to_object): + storage.addBreach(rel.from_object, rel.to_object) + + +def referencedObjectRemoved(obj, event): + # Avoid an error when we try to remove a working copy (plone.app.iterate) + if IWorkingCopy.providedBy(obj): + return + if not IReferenceable.providedBy(obj): + baseReferencedObjectRemoved(obj, event) + + def clear_fields_use_parent_address(obj, event): """If 'use parent address' has been selected, ensure content address fields are cleared From 3ea58ba3fd57ef9b8b4d719b1c29fcb8ff403041 Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Tue, 7 Jan 2020 12:57:23 +0100 Subject: [PATCH 110/144] Display `description` on the organization view. Field `description` may be filled but was not displayed. (cherry picked from commit bca660399cfc3968a7446cf614b80e68f759acee) --- CHANGES.rst | 3 +++ .../core/browser/basefields/templates/organization.pt | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index c57a7b3e..1912bdc0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,9 @@ Changelog - Avoid an error when we try to remove a working copy from plone.app.iterate [mpeeters] +- Display `description` on the organization view. Field `description` may be + filled but was not displayed. + [gbastien] 1.29 (unreleased) ----------------- diff --git a/src/collective/contact/core/browser/basefields/templates/organization.pt b/src/collective/contact/core/browser/basefields/templates/organization.pt index 03a13af5..beaff14a 100644 --- a/src/collective/contact/core/browser/basefields/templates/organization.pt +++ b/src/collective/contact/core/browser/basefields/templates/organization.pt @@ -8,6 +8,16 @@

+
+ Generic KSS Description. Is rendered with class="documentDescription". +
+ + + diff --git a/src/collective/contact/core/browser/templates/contactdetails.pt b/src/collective/contact/core/browser/templates/contactdetails.pt index 3a2277be..3d7978ed 100644 --- a/src/collective/contact/core/browser/templates/contactdetails.pt +++ b/src/collective/contact/core/browser/templates/contactdetails.pt @@ -7,7 +7,7 @@ class="contact-details" tal:define="portal_url context/@@plone_portal_state/portal_url;"> -

+

-

+

-

+

-

+

-

@@ -53,7 +53,7 @@ tal:attributes="href website" />

-

+

From 09ec0223767a52621fe06a00d5f4ef6a841b7cb8 Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Wed, 15 Apr 2020 16:58:28 +0200 Subject: [PATCH 142/144] use classes instead of ids --- .../contact/core/browser/templates/othercontacts.pt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/collective/contact/core/browser/templates/othercontacts.pt b/src/collective/contact/core/browser/templates/othercontacts.pt index e84dfbc3..978af420 100644 --- a/src/collective/contact/core/browser/templates/othercontacts.pt +++ b/src/collective/contact/core/browser/templates/othercontacts.pt @@ -29,12 +29,12 @@ - - - - + + + + - +

From 3e615026eb91a7b8e3c26f5b7383934fa17688fa Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Thu, 16 Apr 2020 08:32:11 +0200 Subject: [PATCH 143/144] fix condition --- src/collective/contact/core/browser/templates/address.pt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collective/contact/core/browser/templates/address.pt b/src/collective/contact/core/browser/templates/address.pt index 48f2ca4b..dc172468 100644 --- a/src/collective/contact/core/browser/templates/address.pt +++ b/src/collective/contact/core/browser/templates/address.pt @@ -5,7 +5,7 @@
+ tal:condition="address/street" >
From e3f9ec0155e2de0a924860caef956033369bf15f Mon Sep 17 00:00:00 2001 From: Laurent Lasudry Date: Tue, 2 Jun 2020 17:30:59 +0200 Subject: [PATCH 144/144] Add new `enterprise number` field for organization content type --- CHANGES.rst | 2 ++ CONTRIBUTORS.rst | 1 + .../basefields/templates/organization.pt | 5 +++++ .../contact/core/content/organization.py | 18 ++++++++++++++++++ src/collective/contact/core/indexers.py | 3 +++ .../core/locales/collective.contact.core.pot | 9 +++++++++ .../de/LC_MESSAGES/collective.contact.core.po | 9 +++++++++ .../fr/LC_MESSAGES/collective.contact.core.po | 9 +++++++++ .../it/LC_MESSAGES/collective.contact.core.po | 9 +++++++++ .../sl/LC_MESSAGES/collective.contact.core.po | 9 +++++++++ src/collective/contact/core/setuphandlers.py | 1 + .../contact/core/tests/test_content_types.py | 1 + .../contact/core/tests/test_search.py | 2 ++ 13 files changed, 78 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e0be74b0..2bd2f5af 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,8 @@ Changelog 2.0 (unreleased) ---------------- +- Add new `enterprise number` field for organization content type + [laulaz] - Update for Plone 5.2 [agitator] - Use mockup for tooltips, modals and date widget. diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index d35817ad..ddcf96f9 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -8,3 +8,4 @@ Contributors - Frédéric Peters, Entr'ouvert - Thomas Desvenain, Ecreall - Peter Holzer, peter.holzer@agitator.com +- Laurent Lasudry, Affinitic diff --git a/src/collective/contact/core/browser/basefields/templates/organization.pt b/src/collective/contact/core/browser/basefields/templates/organization.pt index beaff14a..f4f38e46 100644 --- a/src/collective/contact/core/browser/basefields/templates/organization.pt +++ b/src/collective/contact/core/browser/basefields/templates/organization.pt @@ -38,4 +38,9 @@
+
+ + +
+ diff --git a/src/collective/contact/core/content/organization.py b/src/collective/contact/core/content/organization.py index ba786dcf..3713261c 100644 --- a/src/collective/contact/core/content/organization.py +++ b/src/collective/contact/core/content/organization.py @@ -19,6 +19,18 @@ from zope.intid.interfaces import IIntIds +class InvalidEnterpriseNumber(schema.ValidationError): + """Exception for invalid enterprise number""" + __doc__ = _(u"Enterprise number must contain only letters and numbers") + + +def validateEnterpriseNumber(value): + """Enterprise number validator""" + if not value.isalnum(): + raise InvalidEnterpriseNumber(value) + return True + + class IOrganization(model.Schema, IContactContent): """Interface for Organization content type""" @@ -37,6 +49,12 @@ class IOrganization(model.Schema, IContactContent): required=False, ) + enterprise_number = schema.TextLine( + title=_(u"Enterprise (or VAT) number"), + required=False, + constraint=validateEnterpriseNumber, + ) + def get_organizations_chain(self): """Returns the list of organizations and sub-organizations in this organization e.g. for HR service in Division Bar in Organization Foo : diff --git a/src/collective/contact/core/indexers.py b/src/collective/contact/core/indexers.py index 52e95b39..4a0ac0b4 100644 --- a/src/collective/contact/core/indexers.py +++ b/src/collective/contact/core/indexers.py @@ -49,6 +49,9 @@ def organization_searchable_text(organization): words += organization.get_organizations_titles() + if organization.enterprise_number is not None: + words.append(organization.enterprise_number) + email = IContactDetails(organization).email if email: words.append(email) diff --git a/src/collective/contact/core/locales/collective.contact.core.pot b/src/collective/contact/core/locales/collective.contact.core.pot index d604a29e..f25cae18 100644 --- a/src/collective/contact/core/locales/collective.contact.core.pot +++ b/src/collective/contact/core/locales/collective.contact.core.pot @@ -144,6 +144,15 @@ msgstr "" msgid "End date" msgstr "" +#: ../browser/basefields/templates/organization.pt:42 +#: ../content/organization.py:53 +msgid "Enterprise (or VAT) number" +msgstr "" + +#: ../content/organization.py:24 +msgid "Enterprise number must contain only letters and numbers" +msgstr "" + #: ../behaviors.py:161 msgid "Fax" msgstr "" diff --git a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po index 37fa5ae8..f0c28a1c 100644 --- a/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/de/LC_MESSAGES/collective.contact.core.po @@ -143,6 +143,15 @@ msgstr "Email" msgid "End date" msgstr "Enddatum" +#: ../browser/basefields/templates/organization.pt:42 +#: ../content/organization.py:53 +msgid "Enterprise (or VAT) number" +msgstr "" + +#: ../content/organization.py:24 +msgid "Enterprise number must contain only letters and numbers" +msgstr "" + #: ../behaviors.py:161 msgid "Fax" msgstr "Fax" diff --git a/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po index eca636a9..3530788d 100644 --- a/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/fr/LC_MESSAGES/collective.contact.core.po @@ -144,6 +144,15 @@ msgstr "Courriel " msgid "End date" msgstr "Date de fin " +#: ../browser/basefields/templates/organization.pt:42 +#: ../content/organization.py:53 +msgid "Enterprise (or VAT) number" +msgstr "Numéro d'entreprise (ou de TVA)" + +#: ../content/organization.py:24 +msgid "Enterprise number must contain only letters and numbers" +msgstr "Le numéro d'entreprise ne peut contenir que des lettres et des chiffres" + #: ../behaviors.py:161 msgid "Fax" msgstr "Fax" diff --git a/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po index 9fbe62af..0c433a71 100644 --- a/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/it/LC_MESSAGES/collective.contact.core.po @@ -146,6 +146,15 @@ msgstr "E-mail" msgid "End date" msgstr "Data fine" +#: ../browser/basefields/templates/organization.pt:42 +#: ../content/organization.py:53 +msgid "Enterprise (or VAT) number" +msgstr "" + +#: ../content/organization.py:24 +msgid "Enterprise number must contain only letters and numbers" +msgstr "" + #: ../behaviors.py:161 msgid "Fax" msgstr "Fax" diff --git a/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po b/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po index 0f3f39b7..8fae8806 100644 --- a/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po +++ b/src/collective/contact/core/locales/sl/LC_MESSAGES/collective.contact.core.po @@ -143,6 +143,15 @@ msgstr "Email" msgid "End date" msgstr "Končni datum" +#: ../browser/basefields/templates/organization.pt:42 +#: ../content/organization.py:53 +msgid "Enterprise (or VAT) number" +msgstr "" + +#: ../content/organization.py:24 +msgid "Enterprise number must contain only letters and numbers" +msgstr "" + #: ../behaviors.py:161 msgid "Fax" msgstr "Telefaks" diff --git a/src/collective/contact/core/setuphandlers.py b/src/collective/contact/core/setuphandlers.py index bf3b61e2..e8bb8d20 100644 --- a/src/collective/contact/core/setuphandlers.py +++ b/src/collective/contact/core/setuphandlers.py @@ -158,6 +158,7 @@ def create_test_contact_data(portal): 'number': u'1', 'zip_code': u'75008', 'country': u'France', + 'enterprise_number': 'BE123456789', } mydirectory.invokeFactory('organization', 'armeedeterre', **params) armeedeterre = mydirectory['armeedeterre'] diff --git a/src/collective/contact/core/tests/test_content_types.py b/src/collective/contact/core/tests/test_content_types.py index cf65e319..e0a4ac0a 100644 --- a/src/collective/contact/core/tests/test_content_types.py +++ b/src/collective/contact/core/tests/test_content_types.py @@ -89,6 +89,7 @@ def test_organization(self): armeedeterre = self.armeedeterre self.assertIn('armeedeterre', self.mydirectory) self.assertEqual(armeedeterre.Title(), "Armée de terre") + self.assertEqual(armeedeterre.enterprise_number, "BE123456789") self.assertIn('corpsa', armeedeterre) self.assertIn('corpsb', armeedeterre) self.assertIn('divisionalpha', self.corpsa) diff --git a/src/collective/contact/core/tests/test_search.py b/src/collective/contact/core/tests/test_search.py index f495449f..afdae232 100644 --- a/src/collective/contact/core/tests/test_search.py +++ b/src/collective/contact/core/tests/test_search.py @@ -105,3 +105,5 @@ def test_searchable_fields(self): SearchableText='charles.de.gaulle@private.com') self.assertEqual(len(restults), 1) self.assertEqual(restults[0].getPath(), '/plone/mydirectory/degaulle') + results = catalog.searchResults(SearchableText='BE123456789') + self.assertEqual(len(results), 1)