Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Whitelist reapply_all function for Renovation Image Settings #73

Merged
merged 1 commit into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@

class RenovationImageSettings(Document):

def reapply_all(self):
from frappe.utils.background_jobs import enqueue
from frappe.core.page.background_jobs.background_jobs import get_info as get_running_jobs
@frappe.whitelist()
def reapply_all(self):
from frappe.utils.background_jobs import enqueue
from frappe.core.page.background_jobs.background_jobs import get_info as get_running_jobs

job_name = "reapply_all_image_watermarks"
job_name = "reapply_all_image_watermarks"

if job_name not in [job.get("job_name") for job in get_running_jobs()]:
from renovation_core.utils.images import reapply_all_watermarks
enqueue(method=reapply_all_watermarks, queue="long",
job_name=job_name, timeout=7200) # 2hr
frappe.msgprint(
"The thumbnails will be regenerated in the background. Please handle CDN cache if any.")
else:
frappe.msgprint(
"A reapply request is already in process, please try again later")
if job_name not in [job.get("job_name") for job in get_running_jobs()]:
from renovation_core.utils.images import reapply_all_watermarks
enqueue(method=reapply_all_watermarks, queue="long",
job_name=job_name, timeout=7200) # 2hr
frappe.msgprint(
"The thumbnails will be regenerated in the background."
" Please handle CDN cache if any.")
else:
frappe.msgprint(
"A reapply request is already in process, please try again later")
2 changes: 1 addition & 1 deletion renovation_core/utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def generate_thumbnail(doc):
thumb_width = cint(frappe.get_value(
"Renovation Image Settings", "Renovation Image Settings", "thumb_width"))
if not thumb_width:
frappe.msgpring("Please define thumbnail width in Image Settings")
frappe.msgprint("Please define thumbnail width in Image Settings")
thumb_width = 256
im = Image.open(get_file_path(doc.file_url))
width, height = im.size
Expand Down