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

Add a way to check for backend support of version-dependent features via the site service #1826

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
1 change: 1 addition & 0 deletions news/1826.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Site service: Indicate whether the site supports filtering URL aliases by date. @davisagli
14 changes: 14 additions & 0 deletions src/plone/restapi/services/site/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from Products.CMFPlone.interfaces import IImagingSchema
from Products.CMFPlone.interfaces import ISiteSchema
from Products.CMFPlone.utils import getSiteLogo
from Products.CMFPlone.controlpanel.browser.redirects import RedirectionSet
from zope.component import adapter
from zope.component import getMultiAdapter
from zope.component import getUtility
Expand Down Expand Up @@ -49,6 +50,7 @@ def __call__(self, expand=False):
"plone.default_language": language_settings.default_language,
"plone.available_languages": language_settings.available_languages,
"plone.portal_timezone": self.plone_timezone(),
"features": self.features(),
}
)

Expand All @@ -73,6 +75,18 @@ def plone_timezone(self):

return portal_timezone

def features(self):
"""Indicates which features are supported by this site.

This can be used by a client to check for version-dependent features.
"""
result = {
"filter_aliases_by_date": hasattr(
RedirectionSet, "supports_date_range_filtering"
),
}
return result


class SiteGet(Service):
def reply(self):
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/site_get.resp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Content-Type: application/json

{
"@id": "http://localhost:55001/plone/@site",
"features": {
"filter_aliases_by_date": false
},
"plone.allowed_sizes": [
"huge 1600:65536",
"great 1200:65536",
Expand Down
Loading