Skip to content

Commit

Permalink
Merge e4b4b2c into bb53da4
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Jul 22, 2022
2 parents bb53da4 + e4b4b2c commit 7e4eb7a
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 96 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,56 @@
name: tests

on:
push:
pull_request:
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
strategy:
# We want to see all failures:
fail-fast: false
matrix:
os:
- ubuntu
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.9", "coverage"]

runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.config[0] }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test
run: tox -e ${{ matrix.config[1] }}
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 7 additions & 3 deletions .gitignore
@@ -1,7 +1,11 @@
*.egg-info
*.mo
*.py?
.*
dist/
!.gitattributes
!.gitignore
.coverage
.coverage.*
.eggs/
.installed.cfg
.mr.developer.cfg
.tox/
.vscode/
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,8 @@ Changelog
3.0.2 (unreleased)
------------------

- Nothing changed yet.
- Implements IDateRangeIndex to exclude DateRecurringIndex by indexes with value in the keys of the catalog plan
[mamico]


3.0.1 (2019-10-03)
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
@@ -1,4 +1,7 @@
include *.rst
include buildout.cfg
include tox.ini
include buildout4.cfg
recursive-include docs *
recursive-include src *
global-include *.mo
Expand Down
23 changes: 23 additions & 0 deletions buildout.cfg
@@ -0,0 +1,23 @@
[buildout]
extends =
https://zopefoundation.github.io/Zope/releases/master/versions.cfg
develop = .
parts =
interpreter
test

[versions]
Products.DateRecurringIndex =
RestrictedPython = >= 5.1

[interpreter]
recipe = zc.recipe.egg
interpreter = py
eggs =
Products.DateRecurringIndex
tox

[test]
recipe = zc.recipe.testrunner
eggs =
Products.DateRecurringIndex
7 changes: 7 additions & 0 deletions buildout4.cfg
@@ -0,0 +1,7 @@
[buildout]
extends =
buildout.cfg
http://zopefoundation.github.io/Zope/releases/4.x/versions.cfg

[versions]
Products.DateRecurringIndex =
8 changes: 5 additions & 3 deletions setup.py
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
"""Installer for the bda.aaf.site package."""

from setuptools import find_packages
from setuptools import setup

from setuptools import find_packages, setup

version = '3.0.2.dev0'
short_description = "Zope 2 date index with support for recurring events."
Expand Down Expand Up @@ -31,6 +29,9 @@
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
keywords='zope zope2 index catalog date recurring',
Expand All @@ -45,6 +46,7 @@
zip_safe=False,
install_requires=[
'setuptools',
'six',
'BTrees',
'plone.event',
'Products.ZCatalog',
Expand Down
28 changes: 18 additions & 10 deletions src/Products/DateRecurringIndex/index.py
@@ -1,26 +1,25 @@
# -*- coding: utf-8 -*-
from logging import getLogger

from AccessControl.class_init import InitializeClass
from App.special_dtml import DTMLFile
from BTrees.IIBTree import difference
from BTrees.IIBTree import IISet
from logging import getLogger
from BTrees.IIBTree import IISet, difference
from OFS.PropertyManager import PropertyManager
from plone.event.recurrence import recurrence_sequence_ical
from plone.event.utils import dt2int
from plone.event.utils import pydt
from plone.event.utils import dt2int, pydt
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluginIndexes.interfaces import IDateRangeIndex
from Products.PluginIndexes.unindex import UnIndex
from Products.PluginIndexes.util import safe_callable
from ZODB.POSException import ConflictError
from zope.interface import implementer
from zope.interface import Interface
from zope.schema import Text


LOG = getLogger('Products.DateRecurringIndex')
_marker = object()


class IDateRecurringIndex(Interface):
class IDateRecurringIndex(IDateRangeIndex):
attr_recurdef = Text(
title=u"Attribute- or fieldname of recurrence rule definition."
u"RFC2445 compatible string or timedelta."
Expand Down Expand Up @@ -48,7 +47,6 @@ class DateRecurringIndex(UnIndex, PropertyManager):
{'label': 'Browse', 'action': 'manage_browse'},
) + PropertyManager.manage_options


def __init__(self, id, ignore_ex=None, call_methods=None,
extra=None, caller=None):
""" Initialize the index
Expand Down Expand Up @@ -87,7 +85,7 @@ def index_object(self, documentId, obj, threshold=None):
if not recurdef:
dates = [pydt(date_attr)]
else:
until = getattr(obj, self.attr_until, None)
until = getattr(obj, self.getUntilField(), None)
if safe_callable(until):
until = until()

Expand Down Expand Up @@ -156,6 +154,16 @@ def _convert(self, value, default=None):
"""
return dt2int(value) or default

def getSinceField(self):
"""Get the name of the attribute indexed as start date.
"""
return None

def getUntilField(self):
"""Get the name of the attribute indexed as end date.
"""
return self.attr_until


manage_addDRIndexForm = DTMLFile('www/addDRIndex', globals())

Expand Down
3 changes: 1 addition & 2 deletions src/Products/DateRecurringIndex/testing.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from plone.testing import z2
from plone.testing import Layer
from plone.testing import Layer, z2


class DRILayer(Layer):
Expand Down

0 comments on commit 7e4eb7a

Please sign in to comment.