Skip to content

Commit

Permalink
Add a way to check for backend support of version-dependent features …
Browse files Browse the repository at this point in the history
…via the site service (#1826)

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

* lint & changelog
  • Loading branch information
davisagli authored Oct 18, 2024
1 parent b9a56e1 commit d6815a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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

0 comments on commit d6815a4

Please sign in to comment.