Skip to content

SerializeToJson: Cannot find a permission with name 'collective.easyform.DownloadSavedInput' #431

Description

@mbarde

Serializer throws this error (plone.api.exc.InvalidParameterError: Cannot find a permission with name 'collective.easyform.DownloadSavedInput') when you try to retrieve an Easyform via the REST-API with an unauthenticated user or as an user who does not have this permission.

Reproduce

  1. Setup Plone 6.x and collective.easyform 4.2.0
  2. Create easyform named my-easyform & publish
  3. Retrieve it via REST-API (curl -i -X GET http://localhost:8080/Plone/my-easyform -H "Accept: application/json")

Possible solutions

Variant A

Wrap if api.user.has_permission(DOWNLOAD_SAVED_PERMISSION, obj=self.context): in serializer.py into a try-except-block. If the InvalidParameterError exception is thrown, we know the user does not have this permission.

Variant B

Instead of using 'collective.easyform.DownloadSavedInput' (via DOWNLOAD_SAVED_PERMISSION) we can use 'collective.easyform: Download Saved Input'. For reasons I dont understand this solves the issue:

if api.user.has_permission('collective.easyform: Download Saved Input', obj=self.context):

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions