Skip to content
Draft
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
18 changes: 18 additions & 0 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Security check - Bandit

on: push

jobs:
analyze:
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
steps:
- name: Perform Bandit Analysis
uses: PyCQA/bandit-action@v1
with:
targets: ./redturtle
32 changes: 32 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Black
on: [push]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: install black
run: pip install black

- name: run black
run: black redturtle/ --check --diff
32 changes: 32 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Flake8
on: [push]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: install flake8
run: pip install flake8

- name: run flake8
run: flake8 redturtle/ setup.py
32 changes: 32 additions & 0 deletions .github/workflows/isort.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
permissions:
contents: read
name: Run isort
on:
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# - uses: isort/isort-action@v1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: install isort
run: pip install isort

- name: run isort
run: isort --check-only redturtle

32 changes: 32 additions & 0 deletions .github/workflows/pyroma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
permissions:
contents: read
name: Pyroma
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: install pyroma
run: pip install pyroma==4.2

- name: run pyroma
run: pyroma -n 10 -d .
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ jobs:
strategy:
max-parallel: 4
matrix:
python: ["3.8"]
plone: ["52"]
# exclude:
# - python: "3.7"
# plone: "51"
python: ["3.8", "3.11"]
plone: ["60"]
# temporaneamente disabilitati test su plone 5.2
# plone: ["52", "60"]
exclude:
- python: "3.8"
plone: "60"
- python: "3.11"
plone: "52"
steps:
- uses: actions/checkout@v4
- name: Cache eggs
Expand All @@ -26,7 +30,7 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
pip install -r requirements.txt -c constraints_plone${{ matrix.plone }}.txt
pip install -r requirements_${{ matrix.plone }}.txt
cp test_plone${{ matrix.plone }}.cfg buildout.cfg
- name: Install buildout
run: |
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/zpretty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
permissions:
contents: read
name: zpretty
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]

steps:
# git checkout
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

# install zpretty
- name: install zpretty
run: pip install zpretty

# run zpretty
- name: run zpretty
run: find redturtle -name '*.zcml' | xargs zpretty -i

# XXX: this doesn't work on gh actions (https://github.com/plone/plone.restapi/pull/1119/checks?check_run_id=2686474411)
# run git diff
- name: run git diff
run: git diff --exit-code
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ local/
.sass-cache/
__pycache__
.python-version
pyvenv.cfg
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=plone
31 changes: 31 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@

===============
redturtle.bandi
===============

|python| |version| |ci| |downloads| |license|

.. |python| image:: https://img.shields.io/pypi/pyversions/redturtle.bandi.svg
:target: https://pypi.python.org/pypi/redturtle.bandi/

.. |version| image:: http://img.shields.io/pypi/v/redturtle.bandi.svg
:target: https://pypi.python.org/pypi/redturtle.bandi

.. |ci| image:: https://github.com/RedTurtle/redturtle.bandi/actions/workflows/test.yml/badge.svg
:target: https://github.com/RedTurtle/redturtle.bandi/actions

.. |downloads| image:: https://img.shields.io/pypi/dm/redturtle.bandi.svg
:target: https://pypi.org/project/redturtle.bandi/

.. |license| image:: https://img.shields.io/pypi/l/redturtle.bandi.svg
:target: https://pypi.org/project/redturtle.bandi/
:alt: License

Introduction
============

Expand Down Expand Up @@ -73,6 +96,14 @@ Tile

In order to use layout bandi for tile is necessary have installed collective.tiles.collection product.

Behvaiors
=========

redturtle.bandi.forced_state
----------------------------

This behavior allows to set the forced state of an announcement.

plone.restapi integrations
==========================

Expand Down
2 changes: 1 addition & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# use this extend one of the buildout configuration:
extends =
test_plone52.cfg
test_plone60.cfg
1 change: 0 additions & 1 deletion constraints.txt

This file was deleted.

3 changes: 0 additions & 3 deletions constraints_plone52.txt

This file was deleted.

5 changes: 4 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changelog
1.6.1 (unreleased)
------------------

- Nothing changed yet.
- Add redturtle.bandi.forced_state behavior. This behavior allows to set the forced state of an announcement.
[mamico]
- lint/isort
[mamico]


1.6.0 (2025-03-13)
Expand Down
3 changes: 2 additions & 1 deletion redturtle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
14 changes: 0 additions & 14 deletions redturtle/bandi/Extensions/Install.py

This file was deleted.

10 changes: 6 additions & 4 deletions redturtle/bandi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Main product initializer
"""
"""Main product initializer"""

from zope.i18nmessageid import MessageFactory

import logging

logger = logging.getLogger('redturtle.bandi')
bandiMessageFactory = MessageFactory('redturtle.bandi')

logger = logging.getLogger("redturtle.bandi")
bandiMessageFactory = MessageFactory("redturtle.bandi")
_ = bandiMessageFactory
15 changes: 15 additions & 0 deletions redturtle/bandi/behaviors/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="redturtle.bandi"
>


<plone:behavior
name="redturtle.bandi.forced_state"
title="Possibilità di impostare lo stato del bando"
factory=".force.ForcedState"
provides=".force.IForcedState"
marker=".force.IForcedState"
/>
</configure>
43 changes: 43 additions & 0 deletions redturtle/bandi/behaviors/force.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from plone.autoform.interfaces import IFormFieldProvider
from plone.dexterity.interfaces import IDexterityContent
from plone.supermodel import model
from redturtle.bandi import _
from redturtle.bandi.config import STATES
from redturtle.bandi.interfaces.bando import IBando
from zope import schema
from zope.component import adapter
from zope.interface import implementer
from zope.interface import provider
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


@provider(IFormFieldProvider)
class IForcedState(model.Schema):
"""Marker inteerface for content type Bando"""

forced_state = schema.Choice(
title=_("stato_avanzamento_label", default="Stato di avanzamento"),
description=_(
"stato_avanzamento_help",
default=(
"Indica lo stato di avanzamento. Se il campo esiste, viene "
"utilizzato per determinare lo stato del bando. Se non esiste, "
"viene utilizzato il metodo di base per cui lo stato del bando "
"è determinato dalle date di apertura, scadenza e chiusura procedimento."
),
),
required=False,
vocabulary=SimpleVocabulary(
[SimpleTerm(state, state, STATES[state]["label"]) for state in STATES]
),
)


@implementer(IBando)
@adapter(IDexterityContent)
class ForcedState(object):
"""Bando adapter"""

def __init__(self, context):
self.context = context
Loading
Loading