-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed missing categories when 'sending to college' in iA.Docs #8
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
Conversation
Sup 37039
Salut @chris-adam je regarde à ça demain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_categories_for_user_vocabulary(self, _rest_getConfigInfos): | ||
"""Ensure that vocabularies values are the expected""" | ||
|
||
def set_config(): | ||
setCorrectSettingsConfig(self.portal, setConnectionParams=False, withValidation=False) | ||
ws4pmsettings = getMultiAdapter((self.portal, self.portal.REQUEST), name="ws4pmclient-settings") | ||
for i in range(len(ws4pmsettings.settings().field_mappings)): | ||
if ws4pmsettings.settings().field_mappings[i]["field_name"] == "category": | ||
del ws4pmsettings.settings().field_mappings[i] | ||
break | ||
raw_voc = vocabularies.categories_for_user_vocabulary() | ||
titles = [v.title for v in raw_voc(self.portal)] | ||
tokens = [v.token for v in raw_voc(self.portal)] | ||
return titles, tokens | ||
|
||
self.portal.REQUEST.set("meetingConfigId", u"plonegov-assembly") | ||
|
||
_rest_getConfigInfos.return_value = [ | ||
{ | ||
"id": u"plonegov-assembly", | ||
"title": u"PloneGov Assembly", | ||
"categories": [ | ||
{ | ||
"id": "urbanisme", | ||
"title": "Urbanisme", | ||
"enabled": True, | ||
}, | ||
{ | ||
"id": "finances", | ||
"title": "finances", | ||
"enabled": True, | ||
}, | ||
], | ||
}, | ||
{"id": u"plonemeeting-assembly", "title": u"PloneMeeting Assembly"}, | ||
] | ||
titles, tokens = set_config() | ||
self.assertEqual(titles, [u"finances", u"Urbanisme"]) | ||
self.assertEqual(tokens, [u"finances", u"urbanisme"]) | ||
|
||
_rest_getConfigInfos.return_value = [] | ||
titles, tokens = set_config() | ||
self.assertEqual(titles, []) | ||
self.assertEqual(tokens, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas besoin de méthode nestée et pas besoin de setter la config entre chaque test.
Voici une suggestion :
def test_categories_for_user_vocabulary(self, _rest_getConfigInfos): | |
"""Ensure that vocabularies values are the expected""" | |
def set_config(): | |
setCorrectSettingsConfig(self.portal, setConnectionParams=False, withValidation=False) | |
ws4pmsettings = getMultiAdapter((self.portal, self.portal.REQUEST), name="ws4pmclient-settings") | |
for i in range(len(ws4pmsettings.settings().field_mappings)): | |
if ws4pmsettings.settings().field_mappings[i]["field_name"] == "category": | |
del ws4pmsettings.settings().field_mappings[i] | |
break | |
raw_voc = vocabularies.categories_for_user_vocabulary() | |
titles = [v.title for v in raw_voc(self.portal)] | |
tokens = [v.token for v in raw_voc(self.portal)] | |
return titles, tokens | |
self.portal.REQUEST.set("meetingConfigId", u"plonegov-assembly") | |
_rest_getConfigInfos.return_value = [ | |
{ | |
"id": u"plonegov-assembly", | |
"title": u"PloneGov Assembly", | |
"categories": [ | |
{ | |
"id": "urbanisme", | |
"title": "Urbanisme", | |
"enabled": True, | |
}, | |
{ | |
"id": "finances", | |
"title": "finances", | |
"enabled": True, | |
}, | |
], | |
}, | |
{"id": u"plonemeeting-assembly", "title": u"PloneMeeting Assembly"}, | |
] | |
titles, tokens = set_config() | |
self.assertEqual(titles, [u"finances", u"Urbanisme"]) | |
self.assertEqual(tokens, [u"finances", u"urbanisme"]) | |
_rest_getConfigInfos.return_value = [] | |
titles, tokens = set_config() | |
self.assertEqual(titles, []) | |
self.assertEqual(tokens, []) | |
def test_categories_for_user_vocabulary(self, _rest_getConfigInfos): | |
"""Ensure that vocabularies values are the expected""" | |
# Set the correct settings | |
setCorrectSettingsConfig(self.portal, setConnectionParams=False, withValidation=False) | |
ws4pmsettings = getMultiAdapter((self.portal, self.portal.REQUEST), name="ws4pmclient-settings") | |
for i in range(len(ws4pmsettings.settings().field_mappings)): | |
if ws4pmsettings.settings().field_mappings[i]["field_name"] == "category": | |
del ws4pmsettings.settings().field_mappings[i] | |
break | |
self.portal.REQUEST.set("meetingConfigId", u"plonegov-assembly") | |
# First test with categories | |
_rest_getConfigInfos.return_value = [ | |
{ | |
"id": u"plonegov-assembly", | |
"title": u"PloneGov Assembly", | |
"categories": [ | |
{ | |
"id": "urbanisme", | |
"title": "Urbanisme", | |
"enabled": True, | |
}, | |
{ | |
"id": "finances", | |
"title": "Finances", | |
"enabled": True, | |
}, | |
], | |
}, | |
{"id": u"plonemeeting-assembly", "title": u"PloneMeeting Assembly"}, | |
] | |
voc = vocabularies.categories_for_user_vocabulary()(self.portal) | |
self.assertListEqual([(v.token, v.title) for v in voc], [('finances', u'Finances'), ('urbanisme', u'Urbanisme')]) | |
# Second test without categories | |
_rest_getConfigInfos.return_value = [] | |
voc = vocabularies.categories_for_user_vocabulary()(self.portal) | |
self.assertListEqual([(v.token, v.title) for v in voc], []) |
…dget to display dates in the form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Salut @chris-adam
C'est trop "extrême" de créer un nouveau widget rien que pour ça. De plus, si tu ajoutes un nouveau widget il faut le tester...
Le bonne solution est de s'occuper de l'affichage de la date après l'adapter IPreferredMeetings.
Peux-tu:
- Enlever le widget custom
- Implémenter ma suggestion ou autre si tu trouves mieux (voir plus bas dans le code)
- Compléter le changlelog
Une fois que ça sera fait, je mergerai.
Merci !
possible_meetings = ws4pmsettings._rest_getMeetingsAcceptingItems(data) | ||
local = pytz.timezone("Europe/Brussels") | ||
if not possible_meetings: | ||
return SimpleVocabulary([]) | ||
for meeting in possible_meetings: | ||
meeting["date"] = datetime.strptime(meeting["date"], "%Y-%m-%dT%H:%M:%S") | ||
meeting["date"] = local.localize(meeting["date"]) | ||
meeting['date'] = meeting['date'].astimezone(local) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meeting['date'] = meeting['date'].astimezone(local)
À remettre
terms.append( | ||
SimpleTerm( | ||
unicode(meeting_info["UID"]), | ||
unicode(meeting_info["UID"]), | ||
unicode(meeting_info["date"]), | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gestion de l'affichage après l'adapter IPreferredMeetings
et rétro-compatible:
terms.append( | |
SimpleTerm( | |
unicode(meeting_info["UID"]), | |
unicode(meeting_info["UID"]), | |
unicode(meeting_info["date"]), | |
) | |
) | |
display_date = datetime.strftime(meeting_info["date"], "%d/%m/%Y %H:%M") \ | |
if isinstance(meeting_info["date"], datetime) else meeting_info["date"] | |
terms.append( | |
SimpleTerm( | |
unicode(meeting_info["UID"]), | |
unicode(meeting_info["UID"]), | |
unicode(display_date), | |
) | |
) |
https://my.support.imio.be/browse/DMS-948?focusedCommentId=246317