[fix] Website Image validation

This commit is contained in:
Nabin Hait 2015-12-11 11:47:05 +05:30
parent a1a712b0c6
commit fc4eca5cc7

View File

@ -89,21 +89,23 @@ class Item(WebsiteGenerator):
auto_set_website_image = True auto_set_website_image = True
self.website_image = self.image self.website_image = self.image
file = frappe.db.get_value("File", filters={ if self.website_image:
"file_url": self.website_image, file = frappe.db.get_value("File", filters={
"attached_to_doctype": self.doctype, "file_url": self.website_image,
"attached_to_name": self.name "attached_to_doctype": self.doctype,
}, fieldname=["name", "is_private"], as_dict=True) "attached_to_name": self.name
}, fieldname=["name", "is_private"], as_dict=True)
if not file: if not file:
self.website_image = None if not auto_set_website_image:
if not auto_set_website_image: frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found")
frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found").format(self.website_image, self.name)) .format(self.website_image, self.name))
self.website_image = None
elif file.is_private: elif file.is_private:
self.website_image = None self.website_image = None
if not auto_set_website_image: if not auto_set_website_image:
frappe.msgprint(_("Website Image should be a public file or website URL")) frappe.msgprint(_("Website Image should be a public file or website URL"))
def make_thumbnail(self): def make_thumbnail(self):
"""Make a thumbnail of `website_image`""" """Make a thumbnail of `website_image`"""