Skip to content
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

Group utils views into one place and add export-incarichi #211

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Changelog
6.0.22 (unreleased)
-------------------

- Nothing changed yet.

- Add @@agid-utils view that shows all available utility views.
[cekk]
- Add user action that points to @@agid-utils view.
[cekk]
- Add @@export-incarichi view that allows to download a csv file with all Persona and their roles.
[cekk]

6.0.21 (2023-10-30)
-------------------
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="agid-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="agid-utils" meta_type="CMF Action" i18n:domain="plone">
<property name="title" i18n:translate="">Agid utils</property>
<property name="url_expr">string:${globals_view/navigationRootUrl}/agid-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>7012</version>
<version>7020</version>
<dependencies>
<dependency>profile-redturtle.bandi:default</dependency>
<dependency>profile-collective.venue:default</dependency>
Expand Down
10 changes: 10 additions & 0 deletions src/design/plone/contenttypes/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -774,4 +774,14 @@
handler=".upgrades.to_7012"
/>
</genericsetup:upgradeSteps>
<genericsetup:upgradeSteps
profile="design.plone.contenttypes:default"
source="7012"
destination="7020"
>
<genericsetup:upgradeStep
title="Add utils views in user actions"
handler=".upgrades.update_actions"
/>
</genericsetup:upgradeSteps>
</configure>
4 changes: 4 additions & 0 deletions src/design/plone/contenttypes/upgrades/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def update_profile(context, profile, run_dependencies=True):
context.runImportStepFromProfile(DEFAULT_PROFILE, profile, run_dependencies)


def update_actions(context):
update_profile(context, "actions")


def update_types(context):
update_profile(context, "typeinfo")

Expand Down
Loading