Skip to content

Commit

Permalink
WEB-4134 : Timestamping : code refactoring, fix view , improve some t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
boulch committed Sep 2, 2024
1 parent c22c1a8 commit 156cb3e
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 98 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
1.2.67 (unreleased)
-------------------

- WEB-4134 : Timestamping : code refactoring, fix view , improve some tests
[boulch]

- Fix: Replace i tag with svg icon in React view
[thomlamb]

Expand Down
8 changes: 8 additions & 0 deletions src/imio/smartweb/core/browser/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ class ISmartwebControlPanel(Interface):
required=False,
)

iadeliberations_url = schema.TextLine(
title=_("I.A. Deliberations' url"),
description=_(
"For staging : https://conseil.staging.imio.be | for production : https://www.deliberations.be"
),
required=False,
)

iadeliberations_api_username = schema.TextLine(
title=_("Username to consume I.A. Deliberations API"),
required=False,
Expand Down
4 changes: 0 additions & 4 deletions src/imio/smartweb/core/contents/publication/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
class IPublication(Interface):
""" """

# title = schema.TextLine(title=_("Title"), required=True)

# description = schema.Text(title=_("Description"), required=False)

linked_publication = schema.Choice(
vocabulary="imio.smartweb.vocabulary.IADeliberationsPublications",
title=_("I.A. Deliberation publication"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,14 @@

<!-- Enabled behaviors -->
<property name="behaviors" purge="false">
<!--element value="plone.namefromtitle"/>
<element value="plone.shortname"/> -->
<element value="plone.imagecropping"/>
<element value="plone.locking"/>
<element value="plone.shortname"/>
<element value="plone.leadimage"/>
<element value="solr.fields" />
</property>

# get

<!-- View information -->
<property name="default_view">link_redirect_view</property>
<property name="default_view">view</property>
<property name="default_view_fallback">False</property>
<property name="immediate_view">view</property>
<property name="view_methods">
<element value="link_redirect_view"/>
</property>

</object>
20 changes: 6 additions & 14 deletions src/imio/smartweb/core/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from imio.smartweb.common.utils import is_log_active
from imio.smartweb.common.utils import remove_cropping
from imio.smartweb.core.behaviors.minisite import IImioSmartwebMinisite
from imio.smartweb.core.utils import get_json
from imio.smartweb.core.utils import get_iadeliberation_institution_from_registry
from imio.smartweb.core.utils import get_iadeliberation_json
from imio.smartweb.core.utils import safe_html
from imio.smartweb.locales import SmartwebMessageFactory as _
from plone import api
Expand All @@ -18,7 +19,6 @@
from zope.globalrequest import getRequest
from zope.schema import getFields

import base64
import logging
import os

Expand Down Expand Up @@ -114,21 +114,13 @@ def added_publication(obj, event):
"""save json attributes on object attributes"""
# query the deliberation API with the
# selected publication UID to retrieve all informations
url = obj.linked_publication
iadeliberation_institution = get_iadeliberation_institution_from_registry()
url = f"{iadeliberation_institution}/publications/{obj.linked_publication}?fullobjects=y"
try:
iadeliberation_user = api.portal.get_registry_record(
"smartweb.iadeliberations_api_username"
)
iadeliberation_pwd = api.portal.get_registry_record(
"smartweb.iadeliberation_api_password"
)
usrPass = f"{iadeliberation_user}:{iadeliberation_pwd}".encode("utf-8")
b64Val = base64.b64encode(usrPass)
json_publication = get_json(
url, auth=f"Basic {b64Val.decode('utf-8')}", timeout=20
)
json_publication = get_iadeliberation_json(url)
obj.title = json_publication.get("title")
obj.description = json_publication.get("description")
obj.publication_uid = json_publication.get("UID")
obj.publication_url = json_publication.get("@id")
obj.publication_datetime = json_publication.get("effective")
obj.publication_document_type = json_publication.get("document_type").get(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
{
"@id": "https://www.deliberations.be/@search?portal_type=Institution&metadata_fields=UID",
"@id": "https://conseil.staging.imio.be/@search?portal_type=Institution&metadata_fields=UID",
"batching": {
"@id": "https://www.deliberations.be/@search?portal_type=Institution&metadata_fields=UID",
"first": "https://www.deliberations.be/@search?b_start=0&portal_type=Institution&metadata_fields=UID",
"last": "https://www.deliberations.be/@search?b_start=150&portal_type=Institution&metadata_fields=UID",
"next": "https://www.deliberations.be/@search?b_start=25&portal_type=Institution&metadata_fields=UID"
"@id": "https://conseil.staging.imio.be/@search?portal_type=Institution&metadata_fields=UID",
"first": "https://conseil.staging.imio.be/@search?b_start=0&portal_type=Institution&metadata_fields=UID",
"last": "https://conseil.staging.imio.be/@search?b_start=150&portal_type=Institution&metadata_fields=UID",
"next": "https://conseil.staging.imio.be/@search?b_start=25&portal_type=Institution&metadata_fields=UID"
},
"items": [
{
"@id": "https://www.deliberations.be/quaregnon",
"@id": "https://conseil.staging.imio.be/quaregnon",
"@type": "Institution",
"UID": "8b7ee28aee6a4d17a796c198139bb477",
"description": "",
"review_state": "published",
"title": "Quaregnon"
},
{
"@id": "https://www.deliberations.be/waremme",
"@id": "https://conseil.staging.imio.be/waremme",
"@type": "Institution",
"UID": "7a125baa06d844b4aaea97c73b9efddd",
"description": "",
"review_state": "published",
"title": "Waremme"
},
{
"@id": "https://www.deliberations.be/jalhay",
"@id": "https://conseil.staging.imio.be/jalhay",
"@type": "Institution",
"UID": "d04e1e724694450da535f57f0c0b0450",
"description": "",
"review_state": "published",
"title": "Jalhay"
},
{
"@id": "https://www.deliberations.be/la-hulpe",
"@id": "https://conseil.staging.imio.be/la-hulpe",
"@type": "Institution",
"UID": "970bb179557940d28a3751aa76e123c2",
"description": "",
"review_state": "published",
"title": "La Hulpe"
},
{
"@id": "https://www.deliberations.be/ramillies",
"@id": "https://conseil.staging.imio.be/ramillies",
"@type": "Institution",
"UID": "c85014aaec2d4b2a861911b8b6085b15",
"description": "",
"review_state": "published",
"title": "Ramillies"
},
{
"@id": "https://www.deliberations.be/liege",
"@id": "https://conseil.staging.imio.be/liege",
"@type": "Institution",
"UID": "970bb179557940d28a3751aa76edddd",
"description": "",
Expand Down
Loading

0 comments on commit 156cb3e

Please sign in to comment.