Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into PM-4280_not_viewabl…
Browse files Browse the repository at this point in the history
…e_annexes_access
  • Loading branch information
gbastien committed Jan 13, 2025
2 parents b107fe0 + a07170a commit f9243b3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 22 additions & 17 deletions src/Products/PloneMeeting/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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))
Expand Down
14 changes: 14 additions & 0 deletions src/Products/PloneMeeting/tests/testContacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PloneMeeting/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f9243b3

Please sign in to comment.