diff --git a/CHANGES.rst b/CHANGES.rst index 384fd04e6..fcb4bdfbb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,15 @@ Changelog `_get_default_voters` to `_get_default_voters` and added it to `safe_utils` so it may be used in restricted python code. [gbastien] +- Added parameter `signatories={}` to `BaseDGHV.print_signatories_by_position` + to be able to pass a dict of arbitrary held positions to render as signatures. + This is useful for printing default signatories for example when we do + not want to use signatories defined on context (item or meeting). + [gbastien] +- Fixed `PMAttendeeRedefinePositionTypesVocabulary` that did not render default + value term of `IRedefineAttendeePosition.position_type` correctly when it was + not in the base vocabulary. + [gbastien] - Fixed `PMCategorizedObjectAdapter.can_view` when managing not viewable items because it could lead to unwanted users having access to some annexes by accessing it's URL directly. diff --git a/src/Products/PloneMeeting/browser/views.py b/src/Products/PloneMeeting/browser/views.py index 80bbecf40..40587416d 100644 --- a/src/Products/PloneMeeting/browser/views.py +++ b/src/Products/PloneMeeting/browser/views.py @@ -1419,7 +1419,8 @@ def print_signatories_by_position(self, signature_format=(u'prefixed_secondary_position_type', u'person'), separator=u',', ender=u'', - committee_id=None): + committee_id=None, + signatories={}): """ Print signatories by position :param signature_format: tuple representing a single signature format @@ -1440,6 +1441,9 @@ def print_signatories_by_position(self, (same for 'secondary_position_type' that will fall back to 'position_type') :param separator: str that will be appended at the end of each line (except the last one) :param ender: str that will be appended at the end of the last one + :param committee_id: to be used to get the signatories from a committee_id + :param signatories: arbitrary dict with {'1': hp1, '2': hp2} as format + to not get signatories from the context but pass arbitrary signatories (held_positions) :return: a dict with position as key and signature as value like this {0 : 'The Manager,', 1 : "Jane Doe", 2 : 'The mayor,', 3: 'John Doe'} A dict is used to safely retrieve a signature with the '.get()' method in the PODTemplates @@ -1452,22 +1456,23 @@ def print_signatories_by_position(self, """ signature_lines = OrderedDict() forced_position_type_values = {} - if committee_id: - signatories = self.context.get_committee_signatories( - committee_id, the_objects=True, by_signature_number=True) - elif self.context.getTagName() == 'Meeting': - signatories = self.context.get_signatories(the_objects=True, by_signature_number=True) - else: - signatories = self.context.get_item_signatories(the_objects=True, by_signature_number=True) - if self.context.hasMeeting(): - # if we have redefined signatories, use the selected position_type - meeting = self.context.getMeeting() - item_uid = self.context.UID() - item_signatories = meeting.get_item_signatories(include_position_type=True) - if item_uid in item_signatories: - forced_position_type_values = { - k: v['position_type'] for k, v in - item_signatories[item_uid].items()} + if not signatories: + if committee_id: + signatories = self.context.get_committee_signatories( + committee_id, the_objects=True, by_signature_number=True) + elif self.context.getTagName() == 'Meeting': + signatories = self.context.get_signatories(the_objects=True, by_signature_number=True) + else: + signatories = self.context.get_item_signatories(the_objects=True, by_signature_number=True) + if self.context.hasMeeting(): + # if we have redefined signatories, use the selected position_type + meeting = self.context.getMeeting() + item_uid = self.context.UID() + item_signatories = meeting.get_item_signatories(include_position_type=True) + if item_uid in item_signatories: + forced_position_type_values = { + k: v['position_type'] for k, v in + item_signatories[item_uid].items()} line = 0 sorted_signatories = [(v, forced_position_type_values.get(k, None)) diff --git a/src/Products/PloneMeeting/tests/testContacts.py b/src/Products/PloneMeeting/tests/testContacts.py index fa0148822..db02c97d6 100644 --- a/src/Products/PloneMeeting/tests/testContacts.py +++ b/src/Products/PloneMeeting/tests/testContacts.py @@ -913,6 +913,20 @@ def test_pm_print_signatories_by_position(self): 3: u"La Super-héroine" } ) + + # we can also pass arbitrary signatories, use other signatories + self.assertEqual( + helper.print_signatories_by_position( + signatories={'1': self.hp1, '2': self.hp2}, + signature_format=(u'person', )), + {0: u'Jane Doe', 1: u'Person2FirstName Person2LastName'}) + # can also be passed to print_signatures_by_position + self.assertEqual( + helper.print_signatories_by_position( + signatories={'1': self.hp3, '2': self.hp4}, + signature_format=(u'person', )), + {0: u'Person3FirstName Person3LastName', 1: u'John Doe'}) + # print_signatories_by_position is using Meeting.get_signature_infos_for # redefined on item self.assertTrue(signatory3_uid in item.get_item_signatories(real=True)) diff --git a/src/Products/PloneMeeting/vocabularies.py b/src/Products/PloneMeeting/vocabularies.py index c95ecb09a..ba90a469d 100644 --- a/src/Products/PloneMeeting/vocabularies.py +++ b/src/Products/PloneMeeting/vocabularies.py @@ -3220,7 +3220,7 @@ def _get_base_terms(self, context): res._terms = [term for term in res._terms if not selectableRedefinedPositionTypes or term.token in selectableRedefinedPositionTypes or - hp and term.token == hp.position_type] + hp and term.token in (hp.position_type, hp.secondary_position_type)] return res