indico icon indicating copy to clipboard operation
indico copied to clipboard

Add email placeholder for picture

Open vtran99 opened this issue 1 year ago • 6 comments

Request to add a placeholder to display the personal data picture in email.

vtran99 avatar Oct 15 '24 09:10 vtran99

I updated the code using cid, but for the preview it doesn't work as attachments can't be done. Do you have a solution for it ?

vtran99 avatar Oct 16 '24 11:10 vtran99

I updated the code using cid, but for the preview it doesn't work as attachments can't be done. Do you have a solution for it ?

Damn, forgot about the preview... One solution could be to use a base64 data url for this placeholder while rendering the preview. Or use your original solution for the preview and the cid only when generating the actual mail.

ThiefMaster avatar Oct 16 '24 11:10 ThiefMaster

To render differently the picture in preview, I need to know the context "preview". I see 3 ways to do it:

  1. check directly flask.request in PicturePlaceHolder.render();
  2. add context preview when calling replace_placeholder of email_body, then add '**kwargs' to all placeholders 'render':
email_body = replace_placeholders('registration-email', request.form['body'], regform=self.regform,
                                  registration=registration, preview=True)

def render(cls, regform, registration, **kwargs):
       if kwargs['preview']...
  1. get new placeholders for 'registration-email-preview' with a PicturePreviewPlaceHolder:
email_body = replace_placeholders('registration-email-preview', request.form['body'], regform=self.regform,
                                  registration=registration)
@signals.core.get_placeholders.connect_via('registration-email-preview')
def _get_registration_placeholders_preview(sender, regform, registration, **kwargs):
	yield PicturePreviewPlaceHolder
	yield ...

What would be your suggestion ?

vtran99 avatar Oct 16 '24 16:10 vtran99

i had option 2 in mind, but i somehow thought we already accept kwargs and thus would not need to modify every placeholder... maybe checking if request.endpoint == 'event_registration.email_registrants_preview' (so kind of option 1) is not too ugly

ThiefMaster avatar Oct 16 '24 16:10 ThiefMaster

One last point: in picture rendering, you use a fixed max-height/width = 250px, we would like to have a different value. Can I use a parameter in config for that value ? (same for REGISTRATION_PICTURE_THUMBNAIL_SIZE which is in a constants.py file)

vtran99 avatar Oct 16 '24 16:10 vtran99

constant in python sure, but I don't think having an indico.conf setting for this would really make sense - it's SO specific and probably you guys are the only ones who would change this...

ThiefMaster avatar Oct 16 '24 16:10 ThiefMaster