-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from plone.app.dexterity import _ | ||
from plone.autoform import directives as form | ||
from plone.autoform.interfaces import IFormFieldProvider | ||
from zope import schema | ||
from zope.interface import provider | ||
from plone.supermodel import model | ||
from plone import api | ||
from plone.api.exc import InvalidParameterError | ||
from rer.ufficiostampa import _ | ||
from rer.ufficiostampa.interfaces.settings import IRerUfficiostampaSettings | ||
import json | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def defaultLegislature(): | ||
try: | ||
legislatures = json.loads( | ||
api.portal.get_registry_record( | ||
"legislatures", interface=IRerUfficiostampaSettings | ||
) | ||
) | ||
except (KeyError, InvalidParameterError, TypeError) as e: | ||
logger.exception(e) | ||
return "" | ||
|
||
if not legislatures: | ||
return "" | ||
current = legislatures[-1] | ||
return current.get("legislature", "") | ||
|
||
|
||
@provider(IFormFieldProvider) | ||
class ILegislatureComunicati(model.Schema): | ||
legislature = schema.TextLine( | ||
title=_("label_legislature", default="Legislature"), | ||
description="", | ||
required=True, | ||
defaultFactory=defaultLegislature, | ||
) | ||
form.mode(legislature="display") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters