Skip to content

Commit

Permalink
Merge branch 'main' into datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico authored Jul 1, 2024
2 parents 60d213a + c225296 commit 9f394b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Changelog
- Fix: if there are multiple forms on a page, each csv button downloads the record of all the forms,
now if there is a block_id parameter, the csv is filtered on that.
[mamico]
- Subject templating
[folix-01]
- Handle the edge cases where the `blocks` attribute is not set.
[mamico]

Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ This is useful for some SMTP servers that have problems with `quoted-printable`
By default the content-transfer-encoding is `quoted-printable` as overridden in
https://github.com/zopefoundation/Products.MailHost/blob/master/src/Products/MailHost/MailHost.py#L65


Email subject templating
========================
You can also interpolate the form values to the email subject using the field id, in this way: ${123321123}


Header forwarding
=========================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,26 @@ def get_acknowledgement_field_value(self):
if data.get("field_id", "") == field.get("field_id"):
return data.get("value")

def send_data(self):
def get_subject(self):
subject = self.form_data.get("subject", "") or self.block.get(
"default_subject", ""
)

for i in self.form_data.get("data", []):
# Handle `field_name_321323` kind of id used by frontend package
field_id = i.get("field_id", "").split("_")[-1]

if not field_id:
continue

subject = subject.replace("${" + i.get("field_id") + "}", i.get("value"))

return subject

def send_data(self):

subject = self.get_subject()

mfrom = self.form_data.get("from", "") or self.block.get("default_from", "")
mreply_to = self.get_reply_to()

Expand Down

0 comments on commit 9f394b0

Please sign in to comment.