Skip to content

Commit

Permalink
Merge pull request #5 from RedTurtle/us_49302_Documento
Browse files Browse the repository at this point in the history
added Documento ct
  • Loading branch information
cekk authored Jul 31, 2024
2 parents 0849ed3 + 4d621c5 commit d79f342
Show file tree
Hide file tree
Showing 10 changed files with 484 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/iosanita/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
for="redturtle.bandi.interfaces.bando.IBando"
marker=".bando.IBando"
/>
<plone:behavior
name="iosanita.contenttypes.behavior.multi_file"
title="Multi File"
description="Tre campi file aggiuntivi."
factory=".multi_file.MultiFile"
provides=".multi_file.IMultiFile"
marker=".multi_file.IMultiFile"
/>
<!-- to check -->
<plone:behavior
name="iosanita.contenttypes.behavior.news"
Expand Down
68 changes: 68 additions & 0 deletions src/iosanita/contenttypes/behaviors/multi_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
from iosanita.contenttypes import _
from plone.autoform.interfaces import IFormFieldProvider
from plone.dexterity.interfaces import IDexterityContent
from plone.namedfile import field
from plone.supermodel import model
from zope.component import adapter
from zope.interface import implementer
from zope.interface import provider


class IMultiFileSchema(model.Schema):
""""""

file_principale = field.NamedBlobFile(
title=_("file_principale_label", default="Vai al documento"),
description=_(
"file_principale_help",
default="Inserisci il file principale di questo contenuto.",
),
required=True,
)

formato_alternativo_1 = field.NamedBlobFile(
title=_("formato_alternativo_1_label", default="Formato alternativo 1"),
description=_(
"formato_alternativo_1_help",
default="Inserisci un eventuale formato alternativo del "
"file principale.",
),
required=False,
)

formato_alternativo_2 = field.NamedBlobFile(
title=_("formato_alternativo_2_label", default="Formato alternativo 2"),
description=_(
"formato_alternativo_2_help",
default="Inserisci un eventuale formato alternativo del "
"file principale.",
),
required=False,
)

model.primary("file_principale")

model.fieldset(
"formati",
label=_("formati_label", default="Formati"),
fields=[
"file_principale",
"formato_alternativo_1",
"formato_alternativo_2",
],
)


@provider(IFormFieldProvider)
class IMultiFile(IMultiFileSchema):
""""""


@implementer(IMultiFile)
@adapter(IDexterityContent)
class MultiFile(object):
""""""

def __init__(self, context):
self.context = context
9 changes: 9 additions & 0 deletions src/iosanita/contenttypes/content/documento.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from iosanita.contenttypes.interfaces.documento import IDocumento
from plone.dexterity.content import Container
from zope.interface import implementer


@implementer(IDocumento)
class Documento(Container):
""" """
126 changes: 126 additions & 0 deletions src/iosanita/contenttypes/interfaces/documento.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# -*- coding: utf-8 -*-

from collective.volto.blocksfield.field import BlocksField
from iosanita.contenttypes import _
from iosanita.contenttypes.interfaces import IIosanitaContenttypes
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.autoform import directives as form
from plone.supermodel import model
from z3c.relationfield.schema import RelationChoice
from z3c.relationfield.schema import RelationList
from zope import schema


class IDocumento(model.Schema, IIosanitaContenttypes):
"""Marker interface for content type"""

protocollo = schema.TextLine(
title=_(
"protocollo_documento_label",
default="Numero di protocollo",
),
description=_(
"protocollo_documento_help",
default="Il numero di protocollo del documento.",
),
max_length=255,
required=False,
)

data_protocollo = schema.Date(
title=_("data_protocollo", default="Data del protocollo"),
required=False,
)

descrizione_estesa = BlocksField(
title=_("descrizione_estesa_label", default="Cos'è"),
required=True,
description=_(
"descrizione_estesa_documento_help",
default="Descrizione estesa e completa del Documento.",
),
)

# formati_alternativi = BlocksField(
# title=_("formati_alternativi_label", default="Formati disponibili"),
# description=_(
# "formati_alternativi_help",
# default="Lista dei formati in cui è disponibile il documento",
# ),
# required=True,
# )

servizio_procedura_riferimento = RelationList(
title=_(
"servizio_procedura_riferimento_label",
default="Servizio di riferimento / Procedura di riferimento",
),
description=_(
"servizio_procedura_riferimento_help",
default="Indicazione del servizio, la prestazione o la procedura (Come fare per) a cui fa riferimento il documento.",
),
default=[],
value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
required=False,
missing_value=(),
)

uo_correlata = RelationList(
title=_("uo_correlata_documento_label", default="Responsabile del documento"),
description=_(
"uo_correlata_documento_help",
default="Indicazione dell'unità organizzativa responsabile del documento.",
),
default=[],
value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
required=True,
missing_value=(),
)

autori = RelationList(
title=_(
"autori_label",
default="Autore/i",
),
description=_(
"autori_help",
default="Seleziona una lista di autori che hanno pubblicato "
"il documento.",
),
value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
required=False,
default=[],
)

# widgets
form.widget(
"uo_correlata",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"maximumSelectionSize": 1,
"selectableTypes": ["UnitaOrganizzativa"],
},
)
form.widget(
"autori",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"selectableTypes": ["Persona"],
},
)
form.widget(
"servizio_procedura_riferimento",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"selectableTypes": ["ComeFarePer", "Servizio"],
},
)

model.fieldset(
"cosa_e",
label=_("cosa_e_fieldset", default="Cos'è"),
fields=["descrizione_estesa"],
)
4 changes: 4 additions & 0 deletions src/iosanita/contenttypes/permissions.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
id="iosanita.contenttypes.AddServizio"
title="iosanita.contenttypes: Add Servizio"
/>
<permission
id="iosanita.contenttypes.AddDocumento"
title="iosanita.contenttypes: Add Documento"
/>
</configure>

</configure>
6 changes: 6 additions & 0 deletions src/iosanita/contenttypes/profiles/default/rolemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@
<role name="Owner" />
<role name="Contributor" />
</permission>
<permission acquire="True" name="iosanita.contenttypes: Add Documento">
<role name="Manager" />
<role name="Site Administrator" />
<role name="Owner" />
<role name="Contributor" />
</permission>
</permissions>
</rolemap>
1 change: 1 addition & 0 deletions src/iosanita/contenttypes/profiles/default/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
name="Struttura"
/>
<object meta_type="Dexterity FTI" name="Servizio" />
<object meta_type="Dexterity FTI" name="Documento" />

</object>
109 changes: 109 additions & 0 deletions src/iosanita/contenttypes/profiles/default/types/Documento.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
meta_type="Dexterity FTI"
name="Documento"
i18n:domain="iosanita.contenttypes"
>

<!-- Basic properties -->
<property name="title"
i18n:translate=""
>Documento</property>
<property name="description"
i18n:translate=""
/>

<property name="allow_discussion">False</property>
<property name="factory">Documento</property>
<property name="icon_expr" />
<property name="link_target" />

<!-- Hierarchy control -->
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
<property name="allowed_content_types"
purge="False"
>
<element value="Document" />

</property>
<!-- Schema, class and security -->
<property name="add_permission">iosanita.contenttypes.AddDocumento</property>
<property name="klass">iosanita.contenttypes.content.documento.Documento</property>
<property name="model_file" />
<property name="model_source" />
<property name="schema">iosanita.contenttypes.interfaces.documento.IDocumento</property>

<!-- Enabled behaviors -->
<property name="behaviors"
purge="false"
>
<element value="plone.namefromtitle" />
<element value="plone.allowdiscussion" />
<element value="plone.excludefromnavigation" />
<element value="plone.shortname" />
<element value="plone.ownership" />
<element value="plone.publication" />
<element value="plone.categorization" />
<element value="plone.basic" />
<element value="plone.locking" />
<element value="plone.constraintypes" />
<element value="plone.leadimage" />
<element value="volto.preview_image" />
<element value="plone.relateditems" />
<element value="plone.textindexer" />
<element value="plone.translatable" />
<element value="kitconcept.seo" />
<element value="plone.versioning" />
<element value="iosanita.contenttypes.behavior.a_chi_si_rivolge" />
<element value="collective.taxonomy.generated.a_chi_si_rivolge_tassonomia" />
<element value="collective.taxonomy.generated.parliamo_di" />
<element value="iosanita.contenttypes.behavior.multi_file" />
</property>

<!-- View information -->
<property name="add_view_expr">string:${folder_url}/++add++Documento</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="view" />
</property>

<!-- Method aliases -->
<alias from="(Default)"
to="(dynamic view)"
/>
<alias from="edit"
to="@@edit"
/>
<alias from="sharing"
to="@@sharing"
/>
<alias from="view"
to="(selected layout)"
/>

<!-- Actions -->
<action action_id="view"
category="object"
condition_expr=""
title="View"
url_expr="string:${object_url}"
visible="True"
i18n:attributes="title"
>
<permission value="View" />
</action>
<action action_id="edit"
category="object"
condition_expr="not:object/@@plone_lock_info/is_locked_for_current_user|python:True"
title="Edit"
url_expr="string:${object_url}/edit"
visible="True"
i18n:attributes="title"
>
<permission value="Modify portal content" />
</action>

</object>
6 changes: 6 additions & 0 deletions src/iosanita/contenttypes/restapi/services/types/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class FieldsetsMismatchError(Exception):
"utenti",
"ulteriori_informazioni",
],
"Documento": [
"default",
"formati",
"cosa_e",
"a_chi_si_rivolge",
],
"Event": [
"default",
"cosa_e",
Expand Down
Loading

0 comments on commit d79f342

Please sign in to comment.