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

feat: Job Portal Enhancements (copy #835) #1166

Merged
merged 88 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
aa2105d
feat: add Posted On, Closes On, Employment Type, and Location fields
krantheman Aug 22, 2023
7b9ed80
refactor: set Naming Rule as Expression
krantheman Aug 22, 2023
59c1a8f
feat: add validation for dates
krantheman Aug 22, 2023
88f6422
feat: add validation for Posted On date
krantheman Aug 22, 2023
78299f1
feat: add scheduler event to close expired job openings
krantheman Aug 22, 2023
e786814
feat: add Closed On field
krantheman Aug 23, 2023
cff5dbf
feat: add Salary Type field
krantheman Aug 23, 2023
9558158
feat: add link to job route
krantheman Aug 23, 2023
2bae21f
feat(Job Portal): add Location
krantheman Aug 23, 2023
ee84d3c
feat: improve ui
krantheman Aug 23, 2023
7cfbcaf
refactor: improve UI
krantheman Aug 24, 2023
bea8789
feat: add no. of applications received
krantheman Aug 24, 2023
0a1e5da
feat: better spacing and other ui changes
krantheman Aug 24, 2023
434991a
refactor: Closes on and Applications Received on same line
krantheman Aug 25, 2023
0f6c47d
feat: add portal page
krantheman Aug 25, 2023
b989090
refactor: use portal pages instead of doctype list view
krantheman Aug 25, 2023
5060bf4
feat: add branch and employment type to portal page
krantheman Aug 25, 2023
2d4eb3b
feat: add closes on and company to portal page
krantheman Aug 25, 2023
a537aad
fix: move closes on down
krantheman Aug 25, 2023
d91c165
feat: add search box
krantheman Aug 25, 2023
ed29c27
feat: add employment_type badge
krantheman Aug 25, 2023
2e27dcc
fix: spacing
krantheman Aug 25, 2023
cc1d664
refactor: change Apply Now to View Job
krantheman Aug 25, 2023
0c7e5d1
refactor: use flex instead of columns
krantheman Aug 25, 2023
f6d19f0
feat: add filters ui
krantheman Aug 28, 2023
a1cabe1
feat: improve filters ui
krantheman Aug 28, 2023
29b67d2
refactor: clean up filters code
krantheman Aug 28, 2023
586ac61
feat: filter functionality
krantheman Aug 29, 2023
d334b9d
fix: selection of filters with meta-characters
krantheman Aug 29, 2023
afcb0cc
feat(ux): scroll up before updating filters
krantheman Aug 29, 2023
a6de8de
feat(ui): update search bar and bg color
krantheman Aug 29, 2023
a3fa7c5
feat: add search functionality
krantheman Aug 30, 2023
a1624e7
feat: add sort by
krantheman Aug 30, 2023
535b42d
fix: losing sort from the params while using input fields
krantheman Aug 30, 2023
d5a2f4f
refactor: allowed_filters set on the basis of all_filters
krantheman Aug 30, 2023
b745e97
feat: add sorting functionality
krantheman Aug 31, 2023
48fcac0
fix: dirty bg color on clicking order item
krantheman Aug 31, 2023
aa21c5e
fix: .format instead of f strings for translations
krantheman Aug 31, 2023
05be798
feat: better ui(?)
krantheman Aug 31, 2023
a598211
feat: company name smaller and in blue
krantheman Aug 31, 2023
8031fb8
feat: make card directly clickable
krantheman Aug 31, 2023
08b5d05
feat: more ui changes
krantheman Aug 31, 2023
f749375
feat: improve footer spacing
krantheman Sep 1, 2023
a4f63e7
refactor: change salary_type to salary_per
krantheman Sep 1, 2023
58c00a7
feat: improve ui
krantheman Sep 1, 2023
ffe6d48
feat(ui): use circles for everything
krantheman Sep 1, 2023
7bf0766
feat: render fields conditionally
krantheman Sep 1, 2023
f9ab5fa
feat: add color to footer
krantheman Sep 1, 2023
287675d
refactor(ui): add matching icon stroke colors
krantheman Sep 11, 2023
6cadaf4
refactor: use frappe.db.count for counting applicants
krantheman Sep 11, 2023
4d7d614
fix: card footer alignment
krantheman Sep 11, 2023
5218eb6
refactor: removed hover scaling and other ui changes
krantheman Sep 11, 2023
ae61dbd
fix: icon stroke color
krantheman Sep 11, 2023
4da0954
fix: transaltion string
krantheman Sep 12, 2023
4d0eb7e
fix: handle empty filter values and simplify `get_all_filters`
ruchamahabal Sep 13, 2023
cdefbb2
refactor: show only Month and Year for Salary Paid Per
krantheman Sep 14, 2023
dd74bfd
fix: spacing between groups of filters
krantheman Sep 14, 2023
d6ceb61
fix: picking up of openings without closing dates
krantheman Sep 14, 2023
db1f3b1
fix: single value for salary range
krantheman Sep 14, 2023
b97ba3d
refactor: use doc update instead of db update to facilitate triggerin…
krantheman Sep 14, 2023
a20b806
feat: add description to Closes On field
krantheman Sep 14, 2023
1c72723
refactor: clean up date validation
krantheman Sep 14, 2023
57ea95a
fix: inclusion of unpublished openings
krantheman Sep 14, 2023
be67aab
chore: use tabs instead of spaces
krantheman Sep 14, 2023
04af024
perf: index Job Opening in Job Applicant for faster reads
krantheman Sep 14, 2023
c0ff098
chore: use scoped styles
krantheman Sep 14, 2023
6dfb7b0
fix: checkbox and icon alignment
krantheman Sep 15, 2023
84056fd
feat: handle view for closed openings
krantheman Sep 15, 2023
df4b09c
refactor: toggle sort instead of dropdown
krantheman Sep 15, 2023
2c69e49
fix: sort buttons ui
krantheman Sep 15, 2023
a1f15b9
refactor: use toggle button instead of tabs for sorting
krantheman Oct 6, 2023
deb0322
feat: use grid view with two cards per row
krantheman Oct 6, 2023
727ae77
fix: card height
krantheman Oct 9, 2023
8b7e418
feat: pagination ui
krantheman Oct 9, 2023
de6209e
feat: update params with pagination buttons
krantheman Oct 9, 2023
28c745e
fix: disable previous/next button on first/last page
krantheman Oct 9, 2023
d09bda5
feat: add pagination functionality
krantheman Oct 9, 2023
8f5972c
chore: cleanup code
krantheman Oct 9, 2023
9087c28
fix: search bar icon placement
krantheman Nov 20, 2023
1944555
chore: add comments for job opening page blocks to improve readability
ruchamahabal Dec 7, 2023
fafedba
fix: use the standard search icon & fix translation
ruchamahabal Dec 7, 2023
76be207
refactor: fix formatting, translations and make jobs page jinja more …
ruchamahabal Dec 11, 2023
c1f9cf8
refactor: fix formatting & translations in Job Opening details page
ruchamahabal Dec 11, 2023
5ed1f68
feat: set company in job opening route
ruchamahabal Dec 11, 2023
5b548b1
refactor: close expired job opening & add test for the same
ruchamahabal Dec 11, 2023
a6c28bc
fix: update closing dates on validate
ruchamahabal Dec 11, 2023
3aac36e
chore: fix conflicts
krantheman Dec 12, 2023
c1e1e8a
Merge branch 'version-15-hotfix' into mergify/copy/version-15-hotfix/…
ruchamahabal Dec 14, 2023
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
2 changes: 1 addition & 1 deletion hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
website_generators = ["Job Opening"]

website_route_rules = [
{"from_route": "/jobs", "to_route": "Job Opening"},
{"from_route": "/hrms/<path:app_path>", "to_route": "hrms"},
]
# Jinja
Expand Down Expand Up @@ -215,6 +214,7 @@
"hrms.controllers.employee_reminders.send_work_anniversary_reminders",
"hrms.hr.doctype.daily_work_summary_group.daily_work_summary_group.send_summary",
"hrms.hr.doctype.interview.interview.send_daily_feedback_reminder",
"hrms.hr.doctype.job_opening.job_opening.close_expired_job_openings",
],
"daily_long": [
"hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry.process_expired_allocation",
Expand Down
5 changes: 3 additions & 2 deletions hrms/hr/doctype/job_applicant/job_applicant.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Job Opening",
"options": "Job Opening"
"options": "Job Opening",
"search_index": 1
},
{
"fieldname": "source",
Expand Down Expand Up @@ -193,7 +194,7 @@
"idx": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-14 16:50:39.316079",
"modified": "2023-09-14 17:03:48.838409",
"modified_by": "Administrator",
"module": "HR",
"name": "Job Applicant",
Expand Down
84 changes: 77 additions & 7 deletions hrms/hr/doctype/job_opening/job_opening.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
{
"actions": [],
"allow_import": 1,
"autoname": "field:route",
"autoname": "HR-OPN-.YYYY.-.#### ",
"creation": "2013-01-15 16:13:36",
"description": "Description of a Job Opening",
"doctype": "DocType",
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
"job_details_section",
"job_title",
"company",
"status",
"column_break_5",
"designation",
"column_break_5",
"status",
"posted_on",
"closes_on",
"closed_on",
"section_break_nngy",
"company",
"department",
"column_break_dxpv",
"employment_type",
"location",
"references_section",
"staffing_plan",
"planned_vacancies",
Expand All @@ -31,6 +39,7 @@
"lower_range",
"upper_range",
"column_break_20",
"salary_per",
"publish_salary_range"
],
"fields": [
Expand Down Expand Up @@ -181,16 +190,67 @@
"fieldtype": "Int",
"label": "Vacancies",
"read_only": 1
},
{
"default": "Now",
"fieldname": "posted_on",
"fieldtype": "Datetime",
"label": "Posted On"
},
{
"depends_on": "eval:doc.status == 'Open'",
"description": "If set, the job opening will be closed automatically after this date",
"fieldname": "closes_on",
"fieldtype": "Date",
"label": "Closes On"
},
{
"fieldname": "employment_type",
"fieldtype": "Link",
"label": "Employment Type",
"options": "Employment Type"
},
{
"fieldname": "location",
"fieldtype": "Link",
"label": "Location",
"options": "Branch"
},
{
"fieldname": "section_break_nngy",
"fieldtype": "Section Break",
"label": "Company Details"
},
{
"fieldname": "column_break_dxpv",
"fieldtype": "Column Break"
},
{
"fieldname": "job_details_section",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:doc.status == 'Closed'",
"fieldname": "closed_on",
"fieldtype": "Date",
"label": "Closed On"
},
{
"default": "Month",
"fieldname": "salary_per",
"fieldtype": "Select",
"label": "Salary Paid Per",
"options": "Month\nYear"
}
],
"icon": "fa fa-bookmark",
"idx": 1,
"links": [],
"modified": "2023-09-14 16:50:39.316079",
"modified": "2023-09-15 13:41:54.111743",
"modified_by": "Administrator",
"module": "HR",
"name": "Job Opening",
"naming_rule": "By fieldname",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
Expand All @@ -211,5 +271,15 @@
],
"sort_field": "modified",
"sort_order": "ASC",
"states": []
"states": [
{
"color": "Green",
"title": "Open"
},
{
"color": "Gray",
"title": "Closed"
}
],
"title_field": "job_title"
}
83 changes: 50 additions & 33 deletions hrms/hr/doctype/job_opening/job_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import frappe
from frappe import _
from frappe.utils import get_link_to_form, getdate
from frappe.model.naming import set_name_from_naming_options
from frappe.utils import get_link_to_form, getdate, pretty_date
from frappe.website.website_generator import WebsiteGenerator

from hrms.hr.doctype.staffing_plan.staffing_plan import (
Expand All @@ -22,12 +23,40 @@ class JobOpening(WebsiteGenerator):
page_title_field="job_title",
)

def autoname(self):
self.name = set_name_from_naming_options(frappe.get_meta(self.doctype).autoname, self)

def validate(self):
if not self.route:
self.route = frappe.scrub(self.job_title).replace("_", "-")
self.route = (
f"jobs/{frappe.scrub(self.company)}/{frappe.scrub(self.job_title).replace('_', '-')}"
)
self.update_closing_date()
self.validate_dates()
self.validate_current_vacancies()

def on_update(self):
self.update_job_requisition_status()

def update_closing_date(self):
old_doc = self.get_doc_before_save()
if not old_doc:
return

if old_doc.status == "Open" and self.status == "Closed":
self.closes_on = None
if not self.closed_on:
self.closed_on = getdate()

elif old_doc.status == "Closed" and self.status == "Open":
self.closed_on = None

def validate_dates(self):
if self.status == "Open":
self.validate_from_to_dates("posted_on", "closes_on")
if self.status == "Closed":
self.validate_from_to_dates("posted_on", "closed_on")

def validate_current_vacancies(self):
if not self.staffing_plan:
staffing_plan = get_active_staffing_plan_details(self.company, self.designation)
Expand Down Expand Up @@ -73,38 +102,26 @@ def update_job_requisition_status(self):
job_requisition.save()

def get_context(self, context):
context.no_of_applications = frappe.db.count("Job Applicant", {"job_title": self.name})
context.parents = [{"route": "jobs", "title": _("All Jobs")}]
context.posted_on = pretty_date(self.posted_on)


def get_list_context(context):
context.title = _("Jobs")
context.introduction = _("Current Job Openings")
context.get_list = get_job_openings


def get_job_openings(
doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by=None
):
fields = [
"name",
"status",
"job_title",
"description",
"publish_salary_range",
"lower_range",
"upper_range",
"currency",
"job_application_route",
]

filters = filters or {}
filters.update({"status": "Open"})

if txt:
filters.update(
{"job_title": ["like", "%{0}%".format(txt)], "description": ["like", "%{0}%".format(txt)]}
)
def close_expired_job_openings():
today = getdate()

return frappe.get_all(
doctype, filters, fields, start=limit_start, page_length=limit_page_length, order_by=order_by
)
Opening = frappe.qb.DocType("Job Opening")
openings = (
frappe.qb.from_(Opening)
.select(Opening.name)
.where(
(Opening.status == "Open") & (Opening.closes_on.isnotnull()) & (Opening.closes_on < today)
)
).run(pluck=True)

for d in openings:
doc = frappe.get_doc("Job Opening", d)
doc.status = "Closed"
doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True
doc.save()
18 changes: 0 additions & 18 deletions hrms/hr/doctype/job_opening/templates/job_opening_row.html

This file was deleted.

20 changes: 20 additions & 0 deletions hrms/hr/doctype/job_opening/test_job_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from erpnext.setup.doctype.employee.test_employee import make_employee

from hrms.hr.doctype.job_opening.job_opening import close_expired_job_openings
from hrms.hr.doctype.staffing_plan.test_staffing_plan import make_company


Expand Down Expand Up @@ -55,6 +56,25 @@ def test_vacancies_fulfilled(self):
opening_1.status = "Closed"
opening_1.save()

def test_close_expired_job_openings(self):
today = getdate()

opening_1 = get_job_opening()
opening_1.posted_on = add_days(today, -2)
opening_1.closes_on = add_days(today, -1)
opening_1.insert()

opening_2 = get_job_opening(job_title="Designer New")
opening_2.insert()

close_expired_job_openings()
opening_1.reload()
opening_2.reload()

self.assertEqual(opening_1.status, "Closed")
self.assertEqual(opening_1.closed_on, today)
self.assertEqual(opening_2.status, "Open")


def get_job_opening(**args):
args = frappe._dict(args)
Expand Down
Loading
Loading