Skip to content

Commit

Permalink
DELIBE-180: Fix some issues when an Institution.representatives_mappi…
Browse files Browse the repository at this point in the history
…ngs could be None.
  • Loading branch information
duchenean committed Dec 19, 2024
1 parent e3aa6db commit f87f289
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog
[aduchene]
- DELIBE-29: Add ZoomControl back on institutions map
[aduchene]
- DELIBE-180: Fix some issues when an `Institution.representatives_mappings` could be None.
[aduchene]

2.0.4 (2024-10-23)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/plonemeeting/portal/core/content/institution.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def representatives_mappings_invariant(data):
changes = {}
for rpz in new_representatives:
changes[rpz['representative_key']] = rpz['representative_value']
if data.__context__:
if data.__context__ and data.__context__.representatives_mappings:
for rpz in data.__context__.representatives_mappings:
rpz_uid = rpz['representative_key']
if rpz_uid not in changes and rpz_uid not in missing_uids:
Expand Down
2 changes: 1 addition & 1 deletion src/plonemeeting/portal/core/sync_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _get_mapped_representatives_in_charge(item_data, institution):
) or item_data.get("all_groupsInCharge")

res = []
if groups_in_charge:
if groups_in_charge and institution.representatives_mappings:
gic_tokens = [gic["token"] for gic in groups_in_charge]
mapped_uids = [mapping["representative_key"] for mapping in institution.representatives_mappings]
res = list(filter(lambda uid: uid in mapped_uids, gic_tokens))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ def __init__(self, institution, categories_mappings, representatives_mappings):
'representative_long_value': 'fake name long',
'representative_value': 'fake name'}, )
representatives_mappings_invariant(data)

data.__context__.representatives_mappings = None # Could be None in Plone 6
representatives_mappings_invariant(data)
3 changes: 3 additions & 0 deletions src/plonemeeting/portal/core/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def test_sync_meeting_items(self):
self.assertEqual(meeting.values()[20].category, 'batiment')
self.assertEqual(meeting.values()[-1].category, 'batiment')

self.institution.representatives_mappings = None
sync_items_data(meeting, self.json_meeting_items, self.institution, force=True)

def test_sync_with_updates_meeting_items(self):
meeting = sync_meeting_data(self.institution, self.json_meeting.get("items")[0])
# only a few picked items
Expand Down

0 comments on commit f87f289

Please sign in to comment.