[fix] [validation] website url should be public
This commit is contained in:
parent
4a9f6ba520
commit
66c9940d73
@ -89,23 +89,29 @@ class Item(WebsiteGenerator):
|
||||
auto_set_website_image = True
|
||||
self.website_image = self.image
|
||||
|
||||
if self.website_image:
|
||||
file = frappe.db.get_value("File", filters={
|
||||
"file_url": self.website_image,
|
||||
"attached_to_doctype": self.doctype,
|
||||
"attached_to_name": self.name
|
||||
}, fieldname=["name", "is_private"], as_dict=True)
|
||||
if not self.website_image:
|
||||
return
|
||||
|
||||
if not file:
|
||||
if not auto_set_website_image:
|
||||
frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found")
|
||||
.format(self.website_image, self.name))
|
||||
self.website_image = None
|
||||
# find if website image url exists as public
|
||||
file = frappe.get_all("File", filters={
|
||||
"file_url": self.website_image
|
||||
}, fields=["name", "is_private"], order_by="is_private asc", limit_poge_length=1)
|
||||
|
||||
elif file.is_private:
|
||||
self.website_image = None
|
||||
if not auto_set_website_image:
|
||||
frappe.msgprint(_("Website Image should be a public file or website URL"))
|
||||
if file:
|
||||
file = file[0]
|
||||
|
||||
if not file:
|
||||
if not auto_set_website_image:
|
||||
frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found")
|
||||
.format(self.website_image, self.name))
|
||||
|
||||
self.website_image = None
|
||||
|
||||
elif file.is_private:
|
||||
if not auto_set_website_image:
|
||||
frappe.msgprint(_("Website Image should be a public file or website URL"))
|
||||
|
||||
self.website_image = None
|
||||
|
||||
def make_thumbnail(self):
|
||||
"""Make a thumbnail of `website_image`"""
|
||||
|
Loading…
Reference in New Issue
Block a user