Skip to content

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

Merged
merged 17 commits into from
Mar 24, 2025

Conversation

chris-adam
Copy link
Contributor

@chris-adam chris-adam marked this pull request as draft January 20, 2025 09:10
@chris-adam chris-adam requested a review from duchenean January 31, 2025 10:08
@chris-adam chris-adam marked this pull request as ready for review January 31, 2025 10:08
@duchenean
Copy link
Contributor

duchenean commented Mar 4, 2025

Salut @chris-adam je regarde à ça demain.
Merci et désolé pour le délai

Copy link
Contributor

@duchenean duchenean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @chris-adam

Est-ce tu peux regarder à mes 2 commentaires et adapter ton code ?

Merci ! 🙂

Comment on lines 73 to 116
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, [])
Copy link
Contributor

@duchenean duchenean Mar 13, 2025

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 :

Suggested change
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], [])

Copy link
Contributor

@duchenean duchenean left a 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:

  1. Enlever le widget custom
  2. Implémenter ma suggestion ou autre si tu trouves mieux (voir plus bas dans le code)
  3. 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)
Copy link
Contributor

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

Comment on lines 317 to 323
terms.append(
SimpleTerm(
unicode(meeting_info["UID"]),
unicode(meeting_info["UID"]),
unicode(meeting_info["date"]),
)
)
Copy link
Contributor

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:

Suggested change
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),
)
)

@chris-adam chris-adam merged commit bb57cd2 into master Mar 24, 2025
1 check failed
@chris-adam chris-adam deleted the fix/missing-categories branch March 24, 2025 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants