Skip to main content

A EDTF behavior for Plone.

Project description

https://secure.travis-ci.org/collective/collective.edtf_behavior.png?branch=master Coveralls License Join the chat at https://gitter.im/collective/collective.edtf_behavior

collective.edtf_behavior

A Plone behavior which provides a EDTF Date field and some indexes to search and sort on complex and historic dates.

Note: the current implementation of the used library python-edtf , still uses an earlier draft of the standard: http://www.loc.gov/standards/datetime/pre-submission.html

Features

  • Allows unspecific dates or date intervals: “1989-11” or “1989-11~” or “1989-11-01/1989-11-30”

  • Seasons: 2001-21 >> Spring, 2001

  • old dates like 03.08.1492

  • Search indexes: date_earliest and date_latest

  • Sort indexes: date_sort_ascending and date_sort_descending

Installation

Install collective.edtf_behavior by adding it to your buildout:

[buildout]

...

eggs =
    collective.edtf_behavior

and then running bin/buildout

After you activated the add-on in the Plone Add-ons section, you can Enable this behavior on any Dexterity based content type.

Querying

from plone import api

find any document which earliest date is 06.02.1920 or later.

results = api.content.find(
    portal_type='Document',
    date_earliest={
        'query': datetime.date(1920, 2, 6),
        'range': 'min',
    },
)

find any document which latest date is 11.11.1711 or earlier.

results = api.content.find(
    portal_type='Document',
    date_latest={
        'query': datetime.date(1711, 11, 11),
        'range': 'max',
    },
)

This package provides a DateRangeInRangeIndex named edtf_start_end_range.

find all documents that fall at least with one start/end date of there interval into the range:

results = api.content.find(
    portal_type='Document',
    edtf_start_end_range={
        'start': datetime.date(1711, 11, 11),
        'end':   datetime.date(1920, 2, 6),
    },
)

For more examples how to query the indexes, have a look at the tests .

Extending it

One could improve indexing by using a DateRangeIndex, like the effectiveRange index in Plone if needed.

<!-- Example of a DateRangeIndex like the effectiveRange index in Plone -->
<index name="edtf_date_range" meta_type="DateRangeIndex"
  since_field="date_earliest" until_field="date_latest" />

Contribute

Support

If you are having issues, please let us know. You can reach us on Gitter.

License

The project is licensed under the GPLv2.

Contributors

Changelog

1.0.1 (2019-03-18)

  • Add absolute_import statement to all files, to improve Py3 support, fix README syntax [MrTango]

1.0 (2019-03-18)

  • Add edtf_start_end_range index and document querying in the readme. [MrTango]

1.0a1 (2019-03-14)

  • Initial release, with EDTF behavior and 4 main indexes. [MrTango]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.edtf_behavior-1.0.1.tar.gz (17.1 kB view details)

Uploaded Source

File details

Details for the file collective.edtf_behavior-1.0.1.tar.gz.

File metadata

  • Download URL: collective.edtf_behavior-1.0.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16rc1

File hashes

Hashes for collective.edtf_behavior-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8a70a338bcc97b69bd1f674c8f4e7f90961bc8436c7055feec49c44ecbbf2c87
MD5 a02b7b4af2d91ef9a778ed8eb8c053e5
BLAKE2b-256 88751f33fb18b21f0f610273e6aff1c047a82734c0d2da443d7ff04943bf6db4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page