Skip to content

Handle tipologia_notizia #2

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
Expand All @@ -19,7 +19,7 @@ jobs:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
Expand All @@ -19,7 +19,7 @@ jobs:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pyroma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
Expand All @@ -19,7 +19,7 @@ jobs:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/zpretty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
Expand All @@ -19,7 +19,7 @@ jobs:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.coverage
.coverage.*
.python-version
Expand Down
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Changelog

- Fix mapping for Persona.
[daniele]

- Remove tipoligia_notizia taxonomy (from v3) and index v2 field.
[cekk]
- Re-add tipologia_notizia criteria.
[cekk]

1.0.3 (2024-06-24)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/ctgeneric/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<include package=".behaviors" />
<include package=".browser" />
<include package=".restapi" />
<include package=".upgrades" />
<include package=".vocabularies" />

<include file="monkey.zcml" />
Expand Down Expand Up @@ -53,5 +54,4 @@
name="ruolo"
/>


</configure>
5 changes: 5 additions & 0 deletions src/design/plone/ctgeneric/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0"?>
<object name="portal_catalog">

<column value="tipologia_notizia"/><index name="tipologia_notizia" meta_type="FieldIndex">
<indexed_attr value="tipologia_notizia"/>
</index>

<column value="ruolo"/>
</object>
4 changes: 2 additions & 2 deletions src/design/plone/ctgeneric/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<metadata>
<version>1000</version>
<version>1001</version>
<dependencies>
<!-- <dependency>profile-design.plone.contenttypes:default</dependency> -->
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
>Metadata</value>
</records>

<!-- redefine tipologia_notizia criteria to not use taxonomy -->
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_notizia">
<value key="title" i18n:translate="">Tipologia notizia</value>
<value key="description" i18n:translate="">Tipologia della notizia</value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.selection.any</element>
<element>plone.app.querystring.operation.selection.all</element>
</value>
<value key="vocabulary">design.plone.vocabularies.tipologie_notizia</value>
<value key="group" i18n:translate="">Metadata</value>
</records>

<!-- remove from V3 -->
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.business_events" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.person_life_events" remove="True" />
Expand All @@ -35,7 +49,6 @@
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_incarico" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_licenze" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_luogo" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_notizia" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_organizzazione" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_pdc" remove="True" />
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_stati_pratica" remove="True" />
Expand Down
18 changes: 18 additions & 0 deletions src/design/plone/ctgeneric/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from Products.CMFPlone.interfaces import ISearchSchema
from zope.component import getUtility
from zope.interface import implementer
from plone import api
from collective.taxonomy.interfaces import ITaxonomy
from zope.i18n.interfaces import ITranslationDomain
from zope.schema.interfaces import IVocabularyFactory


@implementer(INonInstallable)
Expand All @@ -23,6 +27,7 @@ def post_install(context):
"""Post install script"""
# Do something at the end of the installation of this package.
disable_searchable_types()
delete_tipologia_notizia_taxonomy()


def uninstall(context):
Expand All @@ -44,3 +49,16 @@ def disable_searchable_types():
]
types = [x for x in settings.types_not_searched if x not in remove_types]
settings.types_not_searched = tuple(types)


def delete_tipologia_notizia_taxonomy():
portal = api.portal.get()
sm = portal.getSiteManager()
name = "collective.taxonomy.tipologia_notizia"
utility = sm.queryUtility(ITaxonomy, name=name)
if utility is None:
return
utility.unregisterBehavior()
sm.unregisterUtility(utility, ITaxonomy, name=name)
sm.unregisterUtility(utility, IVocabularyFactory, name=name)
sm.unregisterUtility(utility, ITranslationDomain, name=name)
29 changes: 29 additions & 0 deletions src/design/plone/ctgeneric/upgrades/1001.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:gs="http://namespaces.zope.org/genericsetup"
>

<gs:registerProfile
name="1001"
title="Enable tipologia_notizia criteria"
description="Configuration for version 1001"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="Products.CMFPlone.interfaces.IMigratingPloneSiteRoot"
directory="1001"
/>

<gs:upgradeSteps
profile="design.plone.ctgeneric:default"
source="1000"
destination="1001"
>

<gs:upgradeStep
title="Enable tipologia_notizia criteria and reindex"
description=""
handler=".v1001.upgrade"
/>

</gs:upgradeSteps>

</configure>
Empty file.
7 changes: 7 additions & 0 deletions src/design/plone/ctgeneric/upgrades/1001/catalog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<object name="portal_catalog">

<column value="tipologia_notizia"/><index name="tipologia_notizia" meta_type="FieldIndex">
<indexed_attr value="tipologia_notizia"/>
</index>
</object>
Empty file.
17 changes: 17 additions & 0 deletions src/design/plone/ctgeneric/upgrades/1001/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone">
<!-- redefine tipologia_notizia criteria to not use taxonomy -->
<records interface="plone.app.querystring.interfaces.IQueryField" prefix="plone.app.querystring.field.tipologia_notizia">
<value key="title" i18n:translate="">Tipologia notizia</value>
<value key="description" i18n:translate="">Tipologia della notizia</value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.selection.any</element>
<element>plone.app.querystring.operation.selection.all</element>
</value>
<value key="vocabulary">design.plone.vocabularies.tipologie_notizia</value>
<value key="group" i18n:translate="">Metadata</value>
</records>

</registry>
6 changes: 6 additions & 0 deletions src/design/plone/ctgeneric/upgrades/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*

import logging


logger = logging.getLogger("design.plone.ctgeneric")
9 changes: 9 additions & 0 deletions src/design/plone/ctgeneric/upgrades/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from plone.app.upgrade.utils import loadMigrationProfile


def reload_gs_profile(context):
loadMigrationProfile(
context,
"profile-design.plone.ctgeneric:default",
)
10 changes: 10 additions & 0 deletions src/design/plone/ctgeneric/upgrades/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="design.plone.ctgeneric"
>

<!-- -*- extra stuff goes here -*- -->

<include file="1001.zcml" />

</configure>
25 changes: 25 additions & 0 deletions src/design/plone/ctgeneric/upgrades/v1001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from design.plone.ctgeneric.setuphandlers import delete_tipologia_notizia_taxonomy
from plone import api

import logging

logger = logging.getLogger(__name__)


def upgrade(setup_tool=None):
""" """
delete_tipologia_notizia_taxonomy()

setup_tool.runAllImportStepsFromProfile("design.plone.ctgeneric.upgrades:1001")

brains = api.content.find(portal_type="News Item")
tot = len(brains)
i = 0
for brain in brains:
i += 1
if i % 100 == 0:
logger.info(f"Processing {i} of {tot}")
obj = brain.getObject()
if getattr(obj, "tipologia_notizia", ""):
obj.reindexObject(idxs=["tipologia_notizia"])
8 changes: 0 additions & 8 deletions test_plone60.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ collective.address = 1.6
# redturtle.volto==5.0.1
collective.purgebyid = 1.2.1

# Required by:
# eea.api.taxonomy==1.5
collective.taxonomy = 3.0.1

# Required by:
# redturtle.bandi==1.4.3
collective.tiles.collection = 2.0.0
Expand All @@ -65,10 +61,6 @@ collective.z3cform.datagridfield = 3.0.1
# zest.releaser==8.0.0
colorama = 0.4.6

# Required by:
# design.plone.contenttypes==6.0.17.dev0
eea.api.taxonomy = 1.5

# Required by:
# openpyxl==3.1.2
et-xmlfile = 1.1.0
Expand Down