From 9f81bf695cbf694a3bb6d9a9031642a9109b12c0 Mon Sep 17 00:00:00 2001 From: Rehan Ansari Date: Thu, 30 Oct 2025 01:03:01 +0530 Subject: [PATCH 1/3] fix: use file_url instead of file_name --- .../src/components/Modals/JobApplicationModal.vue | 2 +- lms/patches.txt | 3 ++- .../v2_0/fix_job_application_resume_urls.py | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 lms/patches/v2_0/fix_job_application_resume_urls.py diff --git a/frontend/src/components/Modals/JobApplicationModal.vue b/frontend/src/components/Modals/JobApplicationModal.vue index 1f7cf0fc..38705288 100644 --- a/frontend/src/components/Modals/JobApplicationModal.vue +++ b/frontend/src/components/Modals/JobApplicationModal.vue @@ -95,7 +95,7 @@ const jobApplication = createResource({ doc: { doctype: 'LMS Job Application', user: user.data?.name, - resume: resume.value?.file_name, + resume: resume.value?.file_url, job: props.job, }, } diff --git a/lms/patches.txt b/lms/patches.txt index 0426a4d9..16c4ef72 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -112,4 +112,5 @@ lms.patches.v2_0.move_batch_instructors_to_evaluators lms.patches.v2_0.enable_programming_exercises_in_sidebar lms.patches.v2_0.count_in_program lms.patches.v2_0.fix_scorm_lesson_reference_idx #02-09-2025 -lms.patches.v2_0.certified_members_to_certifications #05-10-2025 \ No newline at end of file +lms.patches.v2_0.certified_members_to_certifications #05-10-2025 +lms.patches.v2_0.fix_job_application_resume_urls \ No newline at end of file diff --git a/lms/patches/v2_0/fix_job_application_resume_urls.py b/lms/patches/v2_0/fix_job_application_resume_urls.py new file mode 100644 index 00000000..2d9a2291 --- /dev/null +++ b/lms/patches/v2_0/fix_job_application_resume_urls.py @@ -0,0 +1,14 @@ +import frappe + + +def execute(): + applications = frappe.get_all("LMS Job Application", fields=["name", "resume"]) + + 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 file_doc and file_doc.file_url: + frappe.db.set_value("LMS Job Application", application.name, "resume", file_doc.file_url) From a5f9adc8758856e2b6bf234d2dd4af7da70c7a95 Mon Sep 17 00:00:00 2001 From: Rehan Ansari Date: Sat, 1 Nov 2025 14:48:45 +0530 Subject: [PATCH 2/3] fix: patch old resumes to be private, link to job application, and share with job owner --- .../lms_job_application.json | 6 ++-- .../v2_0/fix_job_application_resume_urls.py | 31 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lms/job/doctype/lms_job_application/lms_job_application.json b/lms/job/doctype/lms_job_application/lms_job_application.json index 682b7937..029ba969 100644 --- a/lms/job/doctype/lms_job_application/lms_job_application.json +++ b/lms/job/doctype/lms_job_application/lms_job_application.json @@ -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" -} \ No newline at end of file +} diff --git a/lms/patches/v2_0/fix_job_application_resume_urls.py b/lms/patches/v2_0/fix_job_application_resume_urls.py index 2d9a2291..ba57a60e 100644 --- a/lms/patches/v2_0/fix_job_application_resume_urls.py +++ b/lms/patches/v2_0/fix_job_application_resume_urls.py @@ -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 + ) From 9c38444c4b24c07d87797a85cc27bec54e44fb72 Mon Sep 17 00:00:00 2001 From: Rehan Ansari Date: Sat, 1 Nov 2025 19:08:36 +0530 Subject: [PATCH 3/3] fix: make resumes private, linked and shared with job owner --- frontend/src/components/Modals/JobApplicationModal.vue | 1 + lms/job/doctype/lms_job_application/lms_job_application.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Modals/JobApplicationModal.vue b/frontend/src/components/Modals/JobApplicationModal.vue index 38705288..06072243 100644 --- a/frontend/src/components/Modals/JobApplicationModal.vue +++ b/frontend/src/components/Modals/JobApplicationModal.vue @@ -29,6 +29,7 @@