Repository navigation
Conversation
Documentation build overview
6 files changed ·
|
|
@jenkins-plone-org please run jobs |
|
@davisagli I just found that: The GitHub Actions workflows only run for pull requests whose base branch is master or main. plone/plone.restapi#2070 · Add content type settings and… is stacked on issue-2061-acceptance-server, so they never start. meta.yml, tests.yml and test-matrix.yml all use the same trigger: Pushes to a feature branch don’t trigger them either, because the push trigger has the same branch filter. That’s why the PR only shows the checks GitHub Actions doesn’t run (Read the Docs, the changelog verifier and the contributor agreement check). Why is it configured like this? |
5a8d433 to
4dd29d0
Compare
4dd29d0 to
fc4dbec
Compare
7d1f2d0 to
4da3752
Compare
4da3752 to
fae2a02
Compare
|
@jenkins-plone-org please run jobs |
fae2a02 to
01c21f2
Compare
List, configure, create, copy, and delete content types at the site root (step 2 of #2061). - Settings come from named ITypeSettings adapters, one fieldset each. The core settings (general, contents, visibility, comments, versioning) use the same mechanism as add-ons, which can also require a permission per fieldset. - Responses use the control panel format: a JSON schema with fieldsets, and data converted by the shared field serializers, so choices have a token and a title. - Allowed content types are two flat fields, allowed_content_types_mode (all, selected, none) and allowed_content_types, which standard form widgets can render. The selection is kept while all types are allowed. - Updates validate every change, including invariants against current values, before writing any. - Creating a type uses the defaults of the classic add form. Copying keeps the actions, behavior order, settings, repository policies and workflow of the source, with its own factory and add view. - Deleting is limited to Dexterity types without items, and clears the type's settings, workflow assignment and use as an allowed type. - Create, copy and remove are plain functions in plone.restapi.typesettings.manage, reusable outside the service.
The endpoints content-types page only showed GET examples of the default content types, which belong with the content services. Move them to the content manipulation page and use endpoints/content-types for the @Content-Types service.
01c21f2 to
b1d0652
Compare
davisagli
left a comment
There was a problem hiding this comment.
@sneridagh I reviewed the docs, but not the implementation yet.
| | `read()` | Return the current values. | | ||
| | `validate(data)` | Return a list of errors for the changed values, each with `field` and `message`. | | ||
| | `write(data)` | Store the changed values. | | ||
| | `remove()` | Delete what the settings store outside the FTI, before the type is deleted. | |
There was a problem hiding this comment.
We will probably want an enabled method that returns a boolean, so that the adapter can show the fields only when its add-on is installed (for example).
We should implement the allow_discussion setting in plone.app.discussion this way, to prove the use case.
There was a problem hiding this comment.
Added enabled() to ITypeSettings (the base class returns True), and the comments settings use it to show only when plone.app.discussion is installed. Moving the allow_discussion setting into plone.app.discussion itself would be a separate PR there, so I'm leaving this thread open for that. Partly done in a129590.
Assisted-by: Claude Opus 5.5
… only when enabled - The service requires the permission of the content settings control panel, so access to types can be given without other control panels. - ITypeSettings adapters have an enabled() method. The comments settings show only when plone.app.discussion is installed. - Allowed content types link to the plone.app.vocabularies.PortalTypes vocabulary instead of listing the choices inline. The settings are serialized under the site, so the link resolves. - Docs: what global_allow means, the schema format, and the copy response. Assisted-by: Claude Opus 5.5
…default page - A type's number of items is content_count: items_total is the batching name next to items. The error for deleting a type with items uses it too. - The visibility settings have in_navigation (plone.displayed_types) instead of default_page, which Volto and Plone Aurora don't use. Assisted-by: Claude Opus 5.5
- default_page is back in the visibility settings, next to in_navigation: UIs that don't use default pages hide it, but the API keeps it. - The list and copy examples save their responses too, so changes to them show in reviews, although the docs only show the requests. Assisted-by: Claude Opus 5.5
The list example includes every type. Plone 6.2's Discussion Item has a shorter description than older versions, so the example must match it. Assisted-by: Claude Opus 5.5
Add
@content-typesat the site root, so frontends can list, configure, create, copy, and delete content types without depending on the Dexterity types control panel.Step 2b of #2061, stacked on #2071 (shared schema helpers), which is stacked on #2069. Review it against
issue-2061-schema-helpers. Behavior editing and workflow changes come in steps 3 and 4. Import and export remain deferred.Note
This branch was rewritten after review. The previous version is still in the PR's history (
5a8d433c). The rewrite moves the generic schema and value handling to #2071, and replaces the seven settings-specific field adapters with the shared converters.API
GET/@content-typesGET/@content-types/{type}POST/@content-typescopy_fromPATCH/@content-types/{type}DELETE/@content-types/{type}A type's representation has
schemaanddatain the control panel format: a JSON schema whosefieldsetslist the fields of each settings adapter, and values converted by the shared field serializers. A frontend can render it with the same form as control panels. Choices have atokenand atitle, as in control panels and content. A read-onlyworkflowsummary anditems_totalcomplete the representation.Core settings:
title,descriptionglobal_allow,allowed_content_types_mode(all,selected, ornone), andallowed_content_typessearchable,default_pageallow_discussionversioning(off,manual, orautomatic)Design
ITypeSettingsadapter of the FTI and the request, withtitle,order,schema, an optionalpermission, andread(),validate(),write(), andremove()methods. The core fieldsets use the same mechanism, through theTypeSettingsbase class.validate(), and schema invariants against the merged current values.allowed_content_typeskeeps the selection whileallowed_content_types_modeisall, so switching back toselectedrestores it. The two fields are flat on purpose, so standard form widgets render them. Endpoints for per-type content settings, behavior order and workflow assignment #2061 sketched a nested{mode, types}object, but that neededschema.Objectvalue converters, which broke datagridfield (see Share schema and value conversion helpers #2071).remove()), and its use as an allowed type of other types, so a later type with the same ID starts clean. Only Dexterity types can be deleted, and never the site type.plone.restapi.typesettings.manage, so they can be reused outside the service, for example by a later import step.typeinfodeletes and re-adds every FTI, so a removal subscriber would wipe workflow chains, policies, and registry entries that other import steps had just set.portal_typeindex for the whole listing, rather than one catalog query per type.Known limitations
vocabulary.@idpointing to@sources, which doesn't resolve outside content. Control panels have the same quirk today. The choices are inlined in the schema, so frontends don't need the link.workflow.idshows the first workflow of a multi-workflow chain. Step 4 owns workflow details.Validation
test_services_contenttypes.pyhas 38 tests, covering:test_documentationcases generate thecontent_types_*http-examples. The listing and copy examples save only the request, to avoid a 4,000-line response file.