4

We use PloneFormGen 1.7.12 using Plone 4.3.3. I have a request to include the current data in the email that the form is sending. We normally give editors access to the data to download, but the people he wants to send these to are not editors and I don't want to give them editor's permissions.

If it can't be added to the mailer, I guess I could create a role and give it just enough permissions for an authenticated user to download data. Would it work to copy the authenticated permissions over to a new role and add the PloneFormGen: Download Saved Input permission as well? I really don't like creating extra roles. In addition we would need to set up accounts for these people.

Ida
  • 3,994
  • 21
  • 40
Joe Bigler
  • 179
  • 1
  • 8
  • With "the current data" you mean *all* records of the save-adapter or the *one* record of the submitted form? It could be helpful to describe what exactly you want to achieve in a user-story-like manner, f.e.: "When a user enters a form, I want a group of users to be notified via Email, including the submitted data". Please be as specific as possible. Granting download-perms without creating new roles, is no prob, in case that's what you want. – Ida Sep 23 '15 at 05:19

2 Answers2

2

AFAIK not without coding :-)

  1. Create a new DataSaveAdapter content type

    Best way ist to inherit from the existing one and add a new field:

from Products.PloneFormGen.content.saveDataAdapter import FormSaveDataAdapter


SendDataAdapterSchema = FormSaveDataAdapter.schema.copy() + atapi.Schema((
    atapi.StringField(
        name='csv_recipients',
        required=False,
        widget=atapi.LinesWidget(
            label=_(u'label_csv_recipients', default=u'CSV recipients'),
        )
    )
))

class SendDataAdapter(FormSaveDataAdapter):
    implements(IPloneFormGenActionAdapter)
    ...
    schema = SendDataAdapterSchema
    ...
  1. The SaveDataAdapter provides a onSuccess method, where you can hook in and send your email
class SendDataAdapter(FormSaveDataAdapter):
...

    def onSuccess(self, fields, REQUEST=None, loopstop=False):
        """ saves input data and initiates mail"""
        super(SendDataAdapter, self).onSuccess(fields, REQUEST, loopstop)
        self.send_csv()  # This is where you may implement sending the email.

Of course it needs some work to get it done (registering content type, etc.), but this should point you in the right direction.

Community
  • 1
  • 1
Mathias
  • 6,777
  • 2
  • 20
  • 32
0

Not really sure about your requirements, but in case you want to send the single-record in CSV-format as a mail when a form is submitted, you can customize the template of the mailer-adapter, like this:

    <tal:block repeat="field options/wrappedFields | nothing">
        "<span tal:replace="structure python:field.htmlValue(request)" />",
    </tal:block>

Note, that this only works, if the mail's format is HTML, in plain text tal:repeat comes in the way, adding linebreaks between the values.

If you want to give a group of users permissions to view and download a save-adapter, go to PFG's controlpanel (append /prefs_pfg_permits to the site's URL), where it says "Download Saved Input" check the box for "Reader", then assign "Can edit"-permissioins via the sharing-tab of your save-adapter to the users and groups you want to be privileged.

Ida
  • 3,994
  • 21
  • 40
  • The form is a registration form. Each time it is sent, they want the complete list sent to them. It is not going to be huge, maybe 50 max. – Joe Bigler Sep 24 '15 at 23:42
  • @JoeBigler: Thanks for clarifying! Hope you get Mathias' proposal working. – Ida Sep 25 '15 at 06:43