-
Notifications
You must be signed in to change notification settings - Fork 0
Updated SigningUsersCsv view to send emails to signers #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57cc814
Updated SigningUsersCsv view to send emails to signers
chris-adam 3126c1a
Replaced staging URL with prod URL
chris-adam d567660
Fixed CodeRabbit issues
chris-adam b13d0c2
Updated signing users template and removed default value for related …
chris-adam 45663e1
Improved template mechanism
sgeulette 0ee6f83
Used registry url
sgeulette 1135072
Merge branch 'main' into SE-235/signers_emailing
sgeulette 7e1191c
Corrected typo and unicode
sgeulette File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
| from plone import api | ||
| from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper | ||
| from plone.app.registry.browser.controlpanel import RegistryEditForm | ||
| from plone.registry.interfaces import IRecordModifiedEvent | ||
| from plone.z3cform import layout | ||
| from string import Formatter | ||
| from zope import schema | ||
| from zope.interface import Interface | ||
| from zope.interface import Invalid | ||
|
|
@@ -39,6 +39,17 @@ def validate_vat_number(va_nb): | |
| return True | ||
|
|
||
|
|
||
| def validate_signing_users_email_content(value): | ||
| """Allow only known placeholders in the email template.""" | ||
| allowed = {"fullname", "firstname", "lastname", "email", "userid"} | ||
| for _ignored1, field, _ignored2, _ignored3 in Formatter().parse(value or ""): | ||
| if field and field not in allowed: | ||
| raise Invalid( | ||
| _("Unknown placeholder: ${field}", mapping={"field": field}) | ||
| ) | ||
| return True | ||
|
|
||
|
|
||
| class IImioEsignSettings(Interface): | ||
|
|
||
| enabled = schema.Bool( | ||
|
|
@@ -78,6 +89,16 @@ class IImioEsignSettings(Interface): | |
| required=False, | ||
| ) | ||
|
|
||
| signing_users_email_content = schema.Text( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tu peux en faire un champ riche (comme omail_email_signature de nos settings) et utiliser du tal pour rendre les variables dynamiques. Cela permettra de mettre en forme certaines choses si nécessaire. |
||
| title=_("Email content for signing users"), | ||
| description=_( | ||
| "Email content sent to users when inviting them to Parapheo. " | ||
| "Use {fullname}, {firstname}, {lastname}, {email}, {userid} as placeholders." | ||
| ), | ||
| required=False, | ||
| constraint=validate_signing_users_email_content, | ||
| ) | ||
|
|
||
|
|
||
| class ImioEsignSettings(RegistryEditForm): | ||
| schema = IImioEsignSettings | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: IMIO/imio.esign
Length of output: 143
🏁 Script executed:
Repository: IMIO/imio.esign
Length of output: 612
Handle malformed templates to avoid uncaught
ValueError.Formatter().parse()raisesValueErroron malformed format strings (e.g., unmatched braces). When used as a schema constraint, this will surface as a server error instead of a validation error. Catch it and re‑raiseInvalidwith a friendly message.🔧 Suggested fix
def validate_signing_users_email_content(value): """Allow only known placeholders in the email template.""" allowed = {"fullname", "firstname", "lastname", "email", "userid"} - for _ignored1, field, _ignored2, _ignored3 in Formatter().parse(value or ""): - if field and field not in allowed: - raise Invalid( - _("Unknown placeholder: ${field}", mapping={"field": field}) - ) + try: + for _ignored1, field, _ignored2, _ignored3 in Formatter().parse(value or ""): + if field and field not in allowed: + raise Invalid( + _("Unknown placeholder: ${field}", mapping={"field": field}) + ) + except ValueError as exc: + raise Invalid(_("Invalid email template format.")) from exc return True📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine because this is a setting that will only be edited by the support team or developers, not end users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-adam, understood! I've noted that for admin-only configuration settings in this project, verbose error handling for malformed input is not required.✏️ Learnings added