feat: country filter in job list

This commit is contained in:
Jannat Patel
2025-04-24 18:22:00 +05:30
parent 097d541391
commit 26a278c5f4
8 changed files with 122 additions and 58 deletions

View File

@@ -9,10 +9,11 @@
"field_order": [
"job_title",
"location",
"disabled",
"country",
"column_break_5",
"type",
"status",
"disabled",
"section_break_6",
"company_name",
"company_website",
@@ -36,7 +37,7 @@
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Location",
"label": "City",
"reqd": 1
},
{
@@ -111,6 +112,13 @@
{
"fieldname": "column_break_phkm",
"fieldtype": "Column Break"
},
{
"fieldname": "country",
"fieldtype": "Link",
"label": "Country",
"options": "Country",
"reqd": 1
}
],
"grid_page_length": 50,
@@ -122,7 +130,7 @@
}
],
"make_attachments_public": 1,
"modified": "2025-04-24 13:21:24.311596",
"modified": "2025-04-24 14:34:35.920242",
"modified_by": "sayali@frappe.io",
"module": "Job",
"name": "Job Opportunity",

View File

@@ -306,6 +306,7 @@ def get_job_opportunities(filters=None, orFilters=None):
fields=[
"job_title",
"location",
"country",
"type",
"company_name",
"company_logo",

View File

@@ -101,4 +101,5 @@ lms.patches.v2_0.allow_guest_access #05-02-2025
lms.patches.v2_0.migrate_batch_student_data #10-02-2025
lms.patches.v2_0.delete_old_enrollment_doctypes
lms.patches.v2_0.delete_unused_custom_fields
lms.patches.v2_0.update_certificate_request_status
lms.patches.v2_0.update_certificate_request_status
lms.patches.v2_0.update_job_city_and_country

View File

@@ -0,0 +1,28 @@
import frappe
def execute():
jobs = frappe.get_all("Job Opportunity", fields=["name", "location"])
for job in jobs:
if "," in job.location:
city, country = job.location.split(",", 1)
city = city.strip()
country = country.strip()
save_country(country, job)
frappe.db.set_value("Job Opportunity", job.name, "location", city)
else:
save_country(job.location, job)
def save_country(country, job):
if frappe.db.exists("Country", country):
frappe.db.set_value("Job Opportunity", job.name, "country", country)
else:
country_mapping = {
"US": "United States",
"USA": "United States",
"UAE": "United Arab Emirates",
}
country = country_mapping.get(country, country)
frappe.db.set_value("Job Opportunity", job.name, "country", country)