Browse Source

Merge pull request #4127 from mbauskar/file

[minor] update the image field value if file's is_private value changed
version-14
Rushabh Mehta 7 years ago
committed by GitHub
parent
commit
a5caeb335e
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      frappe/core/doctype/file/file.py

+ 6
- 0
frappe/core/doctype/file/file.py View File

@@ -76,6 +76,7 @@ class File(NestedSet):


if frappe.db.exists('File', {'name': self.name, 'is_folder': 0}): if frappe.db.exists('File', {'name': self.name, 'is_folder': 0}):
if not self.is_folder and (self.is_private != self.db_get('is_private')): if not self.is_folder and (self.is_private != self.db_get('is_private')):
old_file_url = self.file_url
private_files = frappe.get_site_path('private', 'files') private_files = frappe.get_site_path('private', 'files')
public_files = frappe.get_site_path('public', 'files') public_files = frappe.get_site_path('public', 'files')


@@ -91,6 +92,11 @@ class File(NestedSet):


self.file_url = "/private/files/{0}".format(self.file_name) self.file_url = "/private/files/{0}".format(self.file_name)


# update documents image url with new file url
if self.attached_to_doctype and self.attached_to_name and \
frappe.db.get_value(self.attached_to_doctype, self.attached_to_name, "image") == old_file_url:
frappe.db.set_value(self.attached_to_doctype, self.attached_to_name, "image", self.file_url)

def set_folder_size(self): def set_folder_size(self):
"""Set folder size if folder""" """Set folder size if folder"""
if self.is_folder and not self.is_new(): if self.is_folder and not self.is_new():


Loading…
Cancel
Save