diff --git a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint.xml b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint.xml index fc68a01b64e95175172782e2db6c05015e866e09..295cb4a8366f65893db840e025e6f26e7752f746 100644 --- a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint.xml +++ b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint.xml @@ -28,6 +28,10 @@ <key> <string>id</string> </key> <value> <string>VifibPersonConstraint</string> </value> </item> + <item> + <key> <string>last_id</string> </key> + <value> <string>3</string> </value> + </item> <item> <key> <string>portal_type</string> </key> <value> <string>Property Sheet</string> </value> diff --git a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/default_email_constraint.xml b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/default_email_constraint.xml index 8a2c0a5571df8ca6fca78db8b0a191178bc306cb..c65bf5752bc0229c9efec77ad98e11e582664a02 100644 --- a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/default_email_constraint.xml +++ b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/default_email_constraint.xml @@ -6,6 +6,18 @@ </pickle> <pickle> <dictionary> + <item> + <key> <string>_identity_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> <item> <key> <string>constraint_portal_type</string> </key> <value> <string>python: (\'Email\',)</string> </value> @@ -18,6 +30,14 @@ <key> <string>id</string> </key> <value> <string>default_email_constraint</string> </value> </item> + <item> + <key> <string>message_no_subobject</string> </key> + <value> <string>Person have to contain an Email</string> </value> + </item> + <item> + <key> <string>message_no_subobject_portal_type</string> </key> + <value> <string>Person have to contain an Email</string> </value> + </item> <item> <key> <string>portal_type</string> </key> <value> <string>Content Existence Constraint</string> </value> @@ -25,4 +45,34 @@ </dictionary> </pickle> </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> </ZopeData> diff --git a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/property_existence_constraint.xml b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/property_existence_constraint.xml index 17a35bd3afdf7c19a59d35dd1b823b2a186b5241..2b807db14cb4b4b0c5b68c1f6e2d214d02662952 100644 --- a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/property_existence_constraint.xml +++ b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/property_existence_constraint.xml @@ -6,6 +6,35 @@ </pickle> <pickle> <dictionary> + <item> + <key> <string>_identity_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>_local_properties</string> </key> + <value> + <tuple> + <dictionary> + <item> + <key> <string>id</string> </key> + <value> <string>message_property_not_set</string> </value> + </item> + <item> + <key> <string>type</string> </key> + <value> <string>string</string> </value> + </item> + </dictionary> + </tuple> + </value> + </item> + <item> + <key> <string>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> <item> <key> <string>constraint_property</string> </key> <value> @@ -22,6 +51,14 @@ <key> <string>id</string> </key> <value> <string>property_existence_constraint</string> </value> </item> + <item> + <key> <string>message_no_such_property</string> </key> + <value> <string>Property last_name must be defined</string> </value> + </item> + <item> + <key> <string>message_property_not_set</string> </key> + <value> <string>Property last_name must be defined</string> </value> + </item> <item> <key> <string>portal_type</string> </key> <value> <string>Property Existence Constraint</string> </value> @@ -29,4 +66,34 @@ </dictionary> </pickle> </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> </ZopeData> diff --git a/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/subordination_state_constraint.xml b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/subordination_state_constraint.xml new file mode 100644 index 0000000000000000000000000000000000000000..454ac85317a087c84c2ae8899d2e510f20062575 --- /dev/null +++ b/master/bt5/vifib_erp5/PropertySheetTemplateItem/portal_property_sheets/VifibPersonConstraint/subordination_state_constraint.xml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Category Acquired Membership State Constraint" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_identity_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> + </value> + </item> + <item> + <key> <string>_range_criterion</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> + <item> + <key> <string>base_category</string> </key> + <value> <string>subordination</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>subordination_state_constraint</string> </value> + </item> + <item> + <key> <string>membership_portal_type_list</string> </key> + <value> <string>python: (\'Organisation\',)</string> </value> + </item> + <item> + <key> <string>message_different_state</string> </key> + <value> <string>The Organisation is not validated</string> </value> + </item> + <item> + <key> <string>portal_type</string> </key> + <value> <string>Category Acquired Membership State Constraint</string> </value> + </item> + <item> + <key> <string>workflow_state_list</string> </key> + <value> <string>python: \'validated\'</string> </value> + </item> + <item> + <key> <string>workflow_variable</string> </key> + <value> <string>validation_state</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="2" aka="AAAAAAAAAAI="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> + <record id="3" aka="AAAAAAAAAAM="> + <pickle> + <global name="PersistentMapping" module="Persistence.mapping"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>data</string> </key> + <value> + <dictionary/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_erp5/TestTemplateItem/testVifibConstraint.py b/master/bt5/vifib_erp5/TestTemplateItem/testVifibConstraint.py index 5f0c0be64730f9d3939399901b713188d51a941f..f745aea0351bc4d87f788cf09ea7bd508f27f0b9 100644 --- a/master/bt5/vifib_erp5/TestTemplateItem/testVifibConstraint.py +++ b/master/bt5/vifib_erp5/TestTemplateItem/testVifibConstraint.py @@ -284,3 +284,55 @@ class TestVifibInternalPackingListLineConstraint(testVifibMixin): line.setAggregate(aggregate.getRelativeUrl()) self.assertFalse(consistency_message in getMessageList(line)) + +class testVifibPersonConstraint(testVifibMixin): + def getTitle(self): + return "Vifib Person Constraint checks" + + def test_last_name_existence(self): + person = self.portal.person_module.newContent(portal_type='Person') + consistency_message = 'Property last_name must be defined' + + self.assertTrue(consistency_message in getMessageList(person)) + + person.setLastName(rndstr()) + + self.assertFalse(consistency_message in getMessageList(person)) + + def test_role(self): + person = self.portal.person_module.newContent(portal_type='Person') + consistency_message = 'One role should be defined' + self.assertTrue(consistency_message in getMessageList(person)) + + role_id_list = list(self.portal.portal_categories.role.objectIds()) + self.assertTrue(len(role_id_list) >= 2) + person.setRole(role_id_list[0]) + self.assertFalse(consistency_message in getMessageList(person)) + + person.setRoleList(role_id_list) + self.assertTrue(consistency_message in getMessageList(person)) + person.setRole(role_id_list[0]) + self.assertFalse(consistency_message in getMessageList(person)) + + def test_subordination_state(self): + organisation = self.portal.organisation_module.newContent( + portal_type='Organisation') + person = self.portal.person_module.newContent(portal_type='Person', + subordination=organisation.getRelativeUrl()) + consistency_message = 'The Organisation is not validated' + + self.assertTrue(consistency_message in getMessageList(person)) + + organisation.validate() + + self.assertFalse(consistency_message in getMessageList(person)) + + def test_email(self): + person = self.portal.person_module.newContent(portal_type='Person') + consistency_message = 'Person have to contain an Email' + + self.assertTrue(consistency_message in getMessageList(person)) + + person.newContent(portal_type='Email') + + self.assertFalse(consistency_message in getMessageList(person)) diff --git a/master/bt5/vifib_erp5/bt/revision b/master/bt5/vifib_erp5/bt/revision index fb351815657b5e2d423f156c000b624c3a74b73d..8e24a69a053265b21f1ba4d1c8429aa2c0dffa67 100644 --- a/master/bt5/vifib_erp5/bt/revision +++ b/master/bt5/vifib_erp5/bt/revision @@ -1 +1 @@ -197 \ No newline at end of file +198 \ No newline at end of file