Search code examples
csvploneploneformgen

Allowing normal users to download PloneFormGen CSV


We are using PloneFormGen's SaveDataAdapter, and would like users who are not site admins to be able to download the CSV. The normal permissions don't seem to allow this. Is this possible in PloneFormGen?


Solution

  • You're right, there is a custom permission made for the download-view named "PloneFormGen: Download Saved Input", and Products/PloneFormGen/config.py defines that Managers, Owners and Site-admins get this permission by default.

    In one of your add-on's profile-folder add a file named rolemap.xml to additionally assign roles (the default-roles will remain untouched, as they are assigned via a Python-script, not a GenericSetup-file):

    <?xml version="1.0"?>
    <rolemap>
      <permissions>
        <permission name="PloneFormGen: Download Saved Input" acquire="True">
          <role name="Member" />
        </permission>
      </permissions>
    </rolemap>
    

    Note: This will set the permission globally, meaning you cannot restrict it to locations. For finer control per location, create a role "Downloaders", assign the download-permission to it in rolemap.xml and make the permission assignable locally via the sharing-tab of an item. For the last step one could give https://pypi.org/project/collective.sharingroles/ a try.


    An alternative solution for the case that exactly one user needs to get the additional privilege for downloading the content of a save-adapter:

    Append /ownership_form to the URL of the save adapter, choose new owner and save.