django-shop icon indicating copy to clipboard operation
django-shop copied to clipboard

Separate OrderDetailSerializer for views & email notifications?

Open racitup opened this issue 7 years ago • 5 comments

The documentation says:

Another method for adding images to HTML emails is to inline their payload. This means that images, instead of referring them by URI, are inlined as a base64-encoded string. Easy-thumbnails offers a template filter named data_uri to perform this operation. This of course blows up the overall size of an email and shall only be used for small an medium sized images.

Both the order views and the notification use OrderDetailSerializer to serialise the data. It would be useful to have separate serialiser settings so that different media can be supplied to views and notifications. I would expect the default implementation to reuse the same serialiser, to be backward compatible.

racitup avatar Aug 09 '17 14:08 racitup

To be compliant with the other templates, I think it would be a better approach to add a snippet template named myshop/products/email-product-media.html. This snippet shall be rendered whenever the ordered items are listed in an email.

What do you think about such a feature?

jrief avatar Aug 10 '17 15:08 jrief

So in models/notification.py the call to OrderDetailSerializer will have an extra render_label set to email?

Sounds perfect!

racitup avatar Aug 11 '17 13:08 racitup

yes, that's the idea.

jrief avatar Aug 11 '17 13:08 jrief

Unfortunately, it didn't make it into 0.11. Maybe the next version.

jrief avatar Aug 24 '17 11:08 jrief

Just for you information. Newer email clients do not accept inlined images as a base64-encoded strings anymore. Instead django-SHOP 1.0 now uses the new feature introduced in django-post_office-3.2.0 to inline images as inline-attachments. The template myshop/products/email-product-media.html is now used to render emails.

jrief avatar May 20 '19 06:05 jrief