Is there a way to bind current data (like a .csv file) in PloneFormGen to a mail agent?

We are using PloneFormGen 1.7.12 using Plone 4.3.3. I have a request to include current data in the email that the form sends. Usually we give editors access to downloadable data, but the people he wants to send are not editors, and I do not want to give them permission to edit.

If it cannot be added to the mail program, I can create a role and give it enough permissions for an authenticated user to download data. Will it work to copy authenticated permissions for the new role and add PloneFormGen: load permission with saved input? I really don't like creating additional roles. In addition, we will need to set up accounts for these people.

+4
source share
2 answers

AFAIK is not without coding :-)

  • Create a new DataSaveAdapter content type

    The best way ist to inherit from an 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. SaveDataAdapter onSuccess, .
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.

, ( ..), .

+2

, CSV , , :

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

, , HTML, tal:repeat , .

, PFG ( /prefs_pfg_permits URL- ), : " " "Reader", "Can edit" -permissioins , .

0

Source: https://habr.com/ru/post/1608392/


All Articles