mirror of
https://github.com/frappe/lms.git
synced 2026-04-27 02:59:31 +03:00
fix: patch old resumes to be private, link to job application, and share with job owner
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-02-20 20:10:46.943871",
|
||||
"modified": "2025-11-01 14:03:02.903943",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Job",
|
||||
"name": "LMS Job Application",
|
||||
@@ -82,6 +82,7 @@
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
@@ -90,8 +91,9 @@
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "user"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,30 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
applications = frappe.get_all("LMS Job Application", fields=["name", "resume"])
|
||||
applications = frappe.get_all(
|
||||
"LMS Job Application",
|
||||
fields=["name", "resume", "job.owner as job_owner"],
|
||||
filters={"resume": ["not like", "/files/%"]},
|
||||
)
|
||||
|
||||
for application in applications:
|
||||
if application.resume and not application.resume.startswith("/files/"):
|
||||
file_doc = frappe.db.get_value(
|
||||
"File", {"file_name": application.resume}, ["file_url", "name"], as_dict=True
|
||||
)
|
||||
if not application.resume:
|
||||
continue
|
||||
|
||||
if file_doc and file_doc.file_url:
|
||||
frappe.db.set_value("LMS Job Application", application.name, "resume", file_doc.file_url)
|
||||
file_name = frappe.db.get_value(
|
||||
"File", {"file_name": application.resume, "attached_to_name": ["is", "not set"]}, "name"
|
||||
)
|
||||
|
||||
if file_name:
|
||||
file_doc = frappe.get_doc("File", file_name)
|
||||
|
||||
file_doc.is_private = 1
|
||||
file_doc.attached_to_doctype = "LMS Job Application"
|
||||
file_doc.attached_to_name = application.name
|
||||
file_doc.attached_to_field = "resume"
|
||||
file_doc.save()
|
||||
|
||||
if application.job_owner:
|
||||
frappe.share.add_docshare(
|
||||
"LMS Job Application", application.name, application.job_owner, read=1
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user