diff --git a/frontend/src/components/Modals/JobApplicationModal.vue b/frontend/src/components/Modals/JobApplicationModal.vue index 3280c727..035e8d04 100644 --- a/frontend/src/components/Modals/JobApplicationModal.vue +++ b/frontend/src/components/Modals/JobApplicationModal.vue @@ -1,49 +1,144 @@ diff --git a/frontend/src/pages/JobDetail.vue b/frontend/src/pages/JobDetail.vue index b7bfd35e..42d7d8bb 100644 --- a/frontend/src/pages/JobDetail.vue +++ b/frontend/src/pages/JobDetail.vue @@ -23,13 +23,24 @@ {{ __('Report') }} - +
+ +
@@ -70,16 +81,22 @@ class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6" >

+
diff --git a/lms/job/doctype/lms_job_application/__init__.py b/lms/job/doctype/lms_job_application/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lms/job/doctype/lms_job_application/lms_job_application.js b/lms/job/doctype/lms_job_application/lms_job_application.js new file mode 100644 index 00000000..69d48596 --- /dev/null +++ b/lms/job/doctype/lms_job_application/lms_job_application.js @@ -0,0 +1,14 @@ +// Copyright (c) 2024, Frappe and contributors +// For license information, please see license.txt + +frappe.ui.form.on("LMS Job Application", { + refresh(frm) { + frm.set_query("user", function (doc) { + return { + filters: { + ignore_user_type: 1, + }, + }; + }); + }, +}); diff --git a/lms/job/doctype/lms_job_application/lms_job_application.json b/lms/job/doctype/lms_job_application/lms_job_application.json new file mode 100644 index 00000000..682b7937 --- /dev/null +++ b/lms/job/doctype/lms_job_application/lms_job_application.json @@ -0,0 +1,97 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-02-20 12:15:08.957843", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "user", + "resume", + "column_break_deax", + "job", + "job_title", + "company" + ], + "fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "User", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "resume", + "fieldtype": "Attach", + "label": "Resume", + "reqd": 1 + }, + { + "fieldname": "column_break_deax", + "fieldtype": "Column Break" + }, + { + "fieldname": "job", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Job", + "options": "Job Opportunity", + "reqd": 1 + }, + { + "fetch_from": "job.job_title", + "fieldname": "job_title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Job Title", + "read_only": 1 + }, + { + "fetch_from": "job.company_name", + "fieldname": "company", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Company", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-02-20 20:10:46.943871", + "modified_by": "Administrator", + "module": "Job", + "name": "LMS Job Application", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "LMS Student", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "user" +} \ No newline at end of file diff --git a/lms/job/doctype/lms_job_application/lms_job_application.py b/lms/job/doctype/lms_job_application/lms_job_application.py new file mode 100644 index 00000000..70196243 --- /dev/null +++ b/lms/job/doctype/lms_job_application/lms_job_application.py @@ -0,0 +1,39 @@ +# Copyright (c) 2024, Frappe and contributors +# For license information, please see license.txt + +import frappe +from frappe import _ +from frappe.model.document import Document + + +class LMSJobApplication(Document): + def validate(self): + self.validate_duplicate() + + def after_insert(self): + self.send_email_to_employer() + + def validate_duplicate(self): + if frappe.db.exists("LMS Job Application", {"job": self.job, "user": self.user}): + frappe.throw(_("You have already applied for this job.")) + + def send_email_to_employer(self): + company_email = frappe.get_value("Job Opportunity", self.job, "company_email_address") + print(company_email) + if company_email: + subject = _("New Job Applicant") + + args = { + "full_name": frappe.db.get_value("User", self.user, "full_name"), + "job_title": self.job_title, + } + + frappe.sendmail( + recipients=company_email, + subject=subject, + template="job_application", + args=args, + attachments=[self.resume], + header=[subject, "green"], + retry=3, + ) diff --git a/lms/job/doctype/lms_job_application/test_lms_job_application.py b/lms/job/doctype/lms_job_application/test_lms_job_application.py new file mode 100644 index 00000000..acc28b34 --- /dev/null +++ b/lms/job/doctype/lms_job_application/test_lms_job_application.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestLMSJobApplication(FrappeTestCase): + pass diff --git a/lms/templates/emails/job_application.html b/lms/templates/emails/job_application.html new file mode 100644 index 00000000..23b17530 --- /dev/null +++ b/lms/templates/emails/job_application.html @@ -0,0 +1,14 @@ +

+ {{ _("New Job Applicant") }} +

+
+

+ {{ _("{0} has applied for the job position {1}").format(full_name, job_title) }} +

+
+

+ + {{ _("You can find their resume attached to this email.") }} + +

+