Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed missing categories when 'sending to college' in iA.Docs #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/imio/pm/wsclient/browser/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __call__(self, context):
# find categories for given meetingConfigId
for configInfo in configInfos:
if configInfo["id"] == meetingConfigId:
categories = hasattr(configInfo, 'categories') and configInfo.categories or ()
categories = configInfo.get('categories', ())
break
# if not categories is returned, it means that the meetingConfig does
# not use categories...
Expand Down
25 changes: 25 additions & 0 deletions src/imio/pm/wsclient/tests/testVocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,28 @@ def test_desired_meetingdates_vocabulary(

raw_voc = vocabularies.desired_meetingdates_vocabularyFactory(api.portal.get())
self.assertEqual(len(raw_voc), 2)

@patch("imio.pm.wsclient.browser.settings.WS4PMClientSettings._rest_getConfigInfos")
def test_categories_for_user_vocabulary(self, _rest_getConfigInfos):
chris-adam marked this conversation as resolved.
Show resolved Hide resolved
"""Ensure that vocabularies values are the expected"""
_rest_getConfigInfos.return_value = [
{"id": u"plonegov-assembly", "title": u"PloneGov Assembly"},
{"id": u"plonemeeting-assembly", "title": u"PloneMeeting Assembly"},
{"id": u"meeting-config-college", "title": u'Coll\xe8ge'},
]

import ipdb; ipdb.set_trace()
registry_key = "imio.pm.wsclient.browser.settings.IWS4PMClientSettings.field_mappings"
# [u'annexes', u'associatedGroups', u'budgetInfos', u'category', u'classifier', u'committeeObservations', u'committeeTranscript', u'copyGroups', u'decision', u'decisionEnd', u'decisionSuite', u'description', u'detailedDescription', u'emergency', u'emergencyMotivation', u'externalIdentifier', u'extraAttrs', u'groupsInCharge', u'ignore_validation_for', u'inAndOutMoves', u'internalNotes', u'itemInitiator', u'itemKeywords', u'manuallyLinkedItems', u'marginalNotes', u'meetingDeadlineDate', u'meetingManagersNotes', u'motivation', u'notes', u'observations', u'optionalAdvisers', u'oralQuestion', u'otherMeetingConfigsClonableToEmergency', u'otherMeetingConfigsClonableToFieldDecision', u'otherMeetingConfigsClonableToFieldDecisionEnd', u'otherMeetingConfigsClonableToFieldDecisionSuite', u'otherMeetingConfigsClonableToPrivacy', u'pollType', u'pollTypeObservations', u'preferredMeeting', u'privacy', u'proposingGroup', u'sendToAuthority', u'takenOverBy', u'textCheckList', u'title', u'toDiscuss', u'votesObservations', u'votesResult', u'votesResult_after_motivation']
field_mappings = [
{'expression': u'context/title', 'field_name': u'title'},
{'expression': u"python: u'{}\\n{}'.format(context.description, context.restrictedTraverse('@@IncomingmailWSClient').detailed_description())", 'field_name': u'description'},
{'expression': u'context/@@IncomingmailWSClient/get_main_files', 'field_name': u'annexes'}
]
# FIXME *** WrongContainedType: ([ConstraintNotSatisfied(u'title'), ConstraintNotSatisfied(u'description'), ConstraintNotSatisfied(u'annexes')], 'value')
api.portal.set_registry_record(registry_key, field_mappings)

raw_voc = vocabularies.categories_for_user_vocabularyFactory(api.portal.get())
self.assertEqual(len(raw_voc), 1)
self.assertEqual(raw_voc[0].value, "meeting-config-college")
self.assertEqual(raw_voc[0].title, u'Coll\xe8ge')
Loading