Skip to content

Commit

Permalink
Merge branch 'main' into v2v3_test
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Nov 7, 2023
2 parents 6eb94bc + 9cf044d commit d2e5acd
Show file tree
Hide file tree
Showing 29 changed files with 393 additions and 91 deletions.
58 changes: 56 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
Changelog
=========

6.0.17 (unreleased)
-------------------
6.1.1 (unreleased)
------------------

- Do not show fieldsets with no visible fields in @types endpoint.
[cekk]


6.1.0 (2023-11-07)
------------------

- Optionally add image_scales and image_field in Summary serializer.
[mamico]

- Add @@design-utils view that shows all available utility views.
[cekk]

- Add user action that points to @@design-utils view.
[cekk]

- Add @@export-incarichi view that allows to download a csv file with all Persona and their roles.
[cekk]

- Add tipologia_bando to summary serializer.
[cekk]

6.0.21 (2023-10-30)
-------------------

- Handle cost with empty text block in previous upgrade-step.
[cekk]


6.0.20 (2023-10-30)
-------------------

- Add upgrade-step to set a default cost text for events.
[cekk]


6.0.19 (2023-10-25)
-------------------

- Set event tickets cost as required field
[pnicolli]


6.0.18 (2023-09-20)
-------------------

- Add permission check to solve problem accessing private resources with
anonymous user
[lucabel]


6.0.17 (2023-09-06)
-------------------

- Added dates for incarico persona.
[deodorhuter]


6.0.16 (2023-08-24)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="design.plone.contenttypes",
version="6.0.17.dev0",
version="6.1.1.dev0",
description="DesignItalia contenty types",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 2 additions & 2 deletions src/design/plone/contenttypes/behaviors/evento.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class IEvento(model.Schema):

prezzo = BlocksField(
title=_("prezzo", default="Costo"),
required=False,
required=True,
description=_(
"prezzo_help",
default="Eventuale costo dell'evento (se ci sono uno o più biglietti), "
"con link all'alcquisto se disponibile",
"con link all'acquisto se disponibile",
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/>

<!-- Include packages -->
<include package=".manage_content" />
<include package=".utils" />

<browser:jbot
directory="overrides"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
i18n_domain="design.plone.contenttypes"
>

<browser:page
name="design-utils"
for="*"
template="templates/utils.pt"
permission="cmf.ManagePortal"
/>

<browser:page
name="export-incarichi"
for="*"
class=".export_incarichi.View"
permission="cmf.ManagePortal"
/>

<browser:page
name="change_news_type"
for="*"
Expand All @@ -14,28 +28,28 @@
/>

<browser:page
name="move_news_items"
name="move-news-items"
for="*"
class=".move_news_items.View"
template="templates/move_news_items.pt"
permission="cmf.ManagePortal"
/>
<browser:page
name="check_servizi"
name="check-servizi"
for="*"
class=".check_servizi.CheckServizi"
template="templates/check_servizi.pt"
permission="zope2.Public"
/>

<browser:page
name="download_check_servizi"
name="download-check-servizi"
for="*"
class=".check_servizi.DownloadCheckServizi"
permission="zope2.Public"
/>
<browser:page
name="download_check_persone"
name="download-check-persone"
for="*"
class=".check_persone.DownloadCheckPersone"
permission="zope2.Public"
Expand Down
46 changes: 46 additions & 0 deletions src/design/plone/contenttypes/browser/utils/export_incarichi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
from plone import api
from Products.Five import BrowserView
from six import StringIO

import csv


class View(BrowserView):
def __call__(self, *args, **kwargs):
self.request.response.setHeader("Content-type", "application/csv")
self.request.response.setHeader(
"Content-dispsition", "attachment; filename=incarichi.csv"
)

sbuf = StringIO()

fieldnames = ["nome", "incarico", "data inizio", "tipo", "url"]
writer = csv.DictWriter(sbuf, fieldnames=fieldnames, quoting=csv.QUOTE_ALL)
writer.writeheader()
brains = api.content.find(portal_type="Persona")
for brain in brains:
ruolo = brain.ruolo and brain.ruolo[0] or ""
persona = brain.getObject()
incarico_obj = (
persona.incarichi_persona
and persona.incarichi_persona[0].to_object
or None
)
data_inizio = incarico_obj and incarico_obj.data_inizio_incarico or ""
if data_inizio:
data_inizio = data_inizio.strftime("%d/%m/%Y")
tipo_incarico = incarico_obj and incarico_obj.tipologia_incarico or ""
writer.writerow(
{
"nome": brain.Title,
"incarico": ruolo,
"data inizio": data_inizio,
"tipo": tipo_incarico,
"url": brain.getURL(),
}
)

res = sbuf.getvalue()
sbuf.close()
return res
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@

<div class="forms">
<div tal:condition="view/cds">
<form action="${context/absolute_url}/@@check_servizi">
<form action="${context/absolute_url}/@@check-servizi">
<input type="Submit"
value="Cerca senza condizioni di servizio"
/>
</form>
</div>
<div tal:condition="not:view/cds">
<form action="${context/absolute_url}/@@check_servizi">
<form action="${context/absolute_url}/@@check-servizi">
<input name="condizioni_di_servizio"
type="hidden"
value="True"
Expand All @@ -137,7 +137,7 @@
</form>
</div>
<div class="download_button">
<form action="${context/absolute_url}/@@download_check_servizi">
<form action="${context/absolute_url}/@@download-check-servizi">
<!-- <input type="Submit" value="Download" /> -->
<input name="condizioni_di_servizio"
type="hidden"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</metal:content-description>
<metal:content-core fill-slot="content-core">
<div class="form">
<form action="${context/portal_url}/move_news_items"
<form action="${context/portal_url}/move-news-items"
method="POST"
>
<div class="field">
Expand Down Expand Up @@ -77,7 +77,7 @@
"
tal:condition="results"
>
<form action="${context/portal_url}/move_news_items"
<form action="${context/portal_url}/move-news-items"
method="POST"
>
<div>
Expand Down
64 changes: 64 additions & 0 deletions src/design/plone/contenttypes/browser/utils/templates/utils.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
lang="en"
metal:use-macro="here/main_template/macros/master"
xml:lang="en"
i18n:domain="design.plone.contenttypes"
>

<body>
<metal:content-title fill-slot="content-title">
<h1 i18n:translate="">Viste di utility per Design Plone Contenttypes</h1>
</metal:content-title>
<metal:content-description fill-slot="content-description"
i18n:translate=""
>
Una raccolta di utility per i contenuti agid
</metal:content-description>
<metal:content-core fill-slot="content-core">
<div>
<h3>Content-types</h3>
<ul class="list-group">
<li class="list-group-item">
<a href="${context/portal_url}/change-news-type">Cambia la Tipologia Notizia</a>
<p class="discreet">
Questo tool viene usato per cambiare il valore del campo 'Tipologia Notizia' in tutte le notizie che hanno il valore del campo selezionato. Fa anche il giro su tutti i blocchi elenco.
</p>
</li>
<li class="list-group-item">
<a href="${context/portal_url}/export_incarichi">Export incarichi</a>
<p class="discreet">
Scarica un csv con la lista delle persone del sito e relativi incarichi.
</p>
</li>
<li class="list-group-item">
<a href="${context/portal_url}/check-servizi">Check servizi</a>
<p class="discreet">
Verifica dello stato dei servizi.
</p>
</li>
</ul>
</div>
<br />
<div>
<h3>Redturtle Volto</h3>
<ul class="list-group">
<li class="list-group-item">
<a href="${context/portal_url}/fix-links">Fix links</a>
<p class="discreet">
Controlla e corregge i link interni nei blocchi.
</p>
</li>
<li class="list-group-item">
<a href="${context/portal_url}/find-blocks">Find blocks</a>
<p class="discreet">
Permette di trovare i contenuti che hanno un determinato blocco.
</p>
</li>
</div>
</metal:content-core>
</body>

</html>
16 changes: 16 additions & 0 deletions src/design/plone/contenttypes/profiles/default/actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<object name="portal_actions" meta_type="Plone Actions Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<object name="user" meta_type="CMF Action Category" purge="False">
<object name="design-utils" meta_type="CMF Action" i18n:domain="plone">
<property name="title" i18n:translate="">Design utils</property>
<property name="url_expr">string:${globals_view/navigationRootUrl}/design-utils</property>
<property name="link_target"></property>
<property name="icon_expr"></property>
<property name="permissions">
<element value="Manage portal"/>
</property>
<property name="visible">True</property>
</object>
</object>
</object>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7011</version>
<version>7020</version>
<dependencies>
<dependency>profile-redturtle.bandi:default</dependency>
<dependency>profile-collective.venue:default</dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/design/plone/contenttypes/restapi/serializers/modulo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@implementer(ISerializeToJsonSummary)
@adapter(IModulo, IDesignPloneContenttypesLayer)
class SerializeModuloToJsonSummary(DefaultJSONSummarySerializer):
def __call__(self, force_all_metadata=False):
summary = super().__call__(force_all_metadata=force_all_metadata)
def __call__(self, **kwargs):
summary = super().__call__(**kwargs)
fields = [
"file_principale",
"formato_alternativo_1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
@implementer(ISerializeToJsonSummary)
@adapter(IPuntoDiContatto, Interface)
class SerializePuntoDiContattoToJsonSummary(DefaultJSONSummarySerializer):
def __call__(self, force_all_metadata=False):
summary = super().__call__(force_all_metadata=force_all_metadata)
def __call__(self, **kwargs):
summary = super().__call__(**kwargs)
fields = ["value_punto_contatto"]
for schema in iterSchemata(self.context):
for name, field in getFields(schema).items():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# TODO: documentare le motiviazioni di questo override
#
from design.plone.contenttypes.interfaces import IDesignPloneContenttypesLayer
from plone import api
from plone.dexterity.interfaces import IDexterityContent
Expand All @@ -18,7 +20,7 @@
@adapter(IRelationList, IDexterityContent, IDesignPloneContenttypesLayer)
@implementer(IFieldSerializer)
class RelationListFieldSerializer(DefaultRelationListFieldSerializer):
def __call__(self):
def __call__(self, force_images=True):
data = []
for value in self.get_value() or ():
if not value:
Expand All @@ -39,9 +41,9 @@ def __call__(self):
# Users that can edit current context, should see it because otherwise
# they will not see it in edit form.
continue
summary = getMultiAdapter(
(content, getRequest()), ISerializeToJsonSummary
)()
summary = getMultiAdapter((content, getRequest()), ISerializeToJsonSummary)(
force_images=force_images
)
if content.effective().Date() != "1969/12/31":
summary["effective"] = json_compatible(content.effective())
else:
Expand Down
4 changes: 2 additions & 2 deletions src/design/plone/contenttypes/restapi/serializers/servizio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
@implementer(ISerializeToJsonSummary)
@adapter(IServizio, Interface)
class SerializeServizioToJsonSummary(DefaultJSONSummarySerializer):
def __call__(self, force_all_metadata=False):
summary = super().__call__(force_all_metadata=force_all_metadata)
def __call__(self, **kwargs):
summary = super().__call__(**kwargs)
fields = ["canale_digitale"]
for schema in iterSchemata(self.context):
for name, field in getFields(schema).items():
Expand Down
Loading

0 comments on commit d2e5acd

Please sign in to comment.