Merge pull request #1953 from pateljannat/open-to-hiring
feat: open to hiring
This commit is contained in:
@@ -238,8 +238,8 @@
|
||||
"dt": "User",
|
||||
"fetch_from": null,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "looking_for_job",
|
||||
"fieldtype": "Check",
|
||||
"fieldname": "open_to",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"hide_border": 0,
|
||||
"hide_days": 0,
|
||||
@@ -253,16 +253,16 @@
|
||||
"insert_after": "verify_terms",
|
||||
"is_system_generated": 1,
|
||||
"is_virtual": 0,
|
||||
"label": "Open to Opportunities",
|
||||
"label": "Open to",
|
||||
"length": 0,
|
||||
"link_filters": null,
|
||||
"mandatory_depends_on": null,
|
||||
"modified": "2021-12-31 12:56:32.110405",
|
||||
"modified": "2025-12-24 12:56:32.110405",
|
||||
"module": null,
|
||||
"name": "User-looking_for_job",
|
||||
"name": "User-open_to",
|
||||
"no_copy": 0,
|
||||
"non_negative": 0,
|
||||
"options": null,
|
||||
"options": "\nOpportunities\nHiring",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
|
||||
@@ -136,7 +136,7 @@ def delete_custom_fields():
|
||||
"medium",
|
||||
"linkedin",
|
||||
"profession",
|
||||
"looking_for_job",
|
||||
"open_to",
|
||||
"cover_image" "work_environment",
|
||||
"dream_companies",
|
||||
"career_preference_column",
|
||||
|
||||
@@ -281,10 +281,34 @@ def get_evaluator_details(evaluator):
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_certified_participants(filters=None, start=0, page_length=100):
|
||||
filters, or_filters, open_to_opportunities, hiring = update_certification_filters(filters)
|
||||
|
||||
participants = frappe.db.get_all(
|
||||
"LMS Certificate",
|
||||
filters=filters,
|
||||
or_filters=or_filters,
|
||||
fields=["member", "issue_date", "batch_name", "course", "name"],
|
||||
group_by="member",
|
||||
order_by="issue_date desc",
|
||||
start=start,
|
||||
page_length=page_length,
|
||||
)
|
||||
|
||||
for participant in participants:
|
||||
details = get_certified_participant_details(participant.member)
|
||||
participant.update(details)
|
||||
|
||||
participants = filter_by_open_to_criteria(participants, open_to_opportunities, hiring)
|
||||
|
||||
return participants
|
||||
|
||||
|
||||
def update_certification_filters(filters):
|
||||
open_to_opportunities = False
|
||||
hiring = False
|
||||
or_filters = {}
|
||||
if not filters:
|
||||
filters = {}
|
||||
|
||||
filters.update({"published": 1})
|
||||
|
||||
category = filters.get("category")
|
||||
@@ -293,27 +317,38 @@ def get_certified_participants(filters=None, start=0, page_length=100):
|
||||
or_filters["course_title"] = ["like", f"%{category}%"]
|
||||
or_filters["batch_title"] = ["like", f"%{category}%"]
|
||||
|
||||
participants = frappe.db.get_all(
|
||||
"LMS Certificate",
|
||||
filters=filters,
|
||||
or_filters=or_filters,
|
||||
fields=["member", "issue_date"],
|
||||
group_by="member",
|
||||
order_by="issue_date desc",
|
||||
start=start,
|
||||
page_length=page_length,
|
||||
)
|
||||
if filters.get("open_to_opportunities"):
|
||||
del filters["open_to_opportunities"]
|
||||
open_to_opportunities = True
|
||||
|
||||
for participant in participants:
|
||||
count = frappe.db.count("LMS Certificate", {"member": participant.member})
|
||||
details = frappe.db.get_value(
|
||||
"User",
|
||||
participant.member,
|
||||
["full_name", "user_image", "username", "country", "headline", "looking_for_job"],
|
||||
as_dict=1,
|
||||
)
|
||||
details["certificate_count"] = count
|
||||
participant.update(details)
|
||||
if filters.get("hiring"):
|
||||
del filters["hiring"]
|
||||
hiring = True
|
||||
|
||||
return filters, or_filters, open_to_opportunities, hiring
|
||||
|
||||
|
||||
def get_certified_participant_details(member):
|
||||
count = frappe.db.count("LMS Certificate", {"member": member})
|
||||
details = frappe.db.get_value(
|
||||
"User",
|
||||
member,
|
||||
["full_name", "user_image", "username", "country", "headline", "open_to"],
|
||||
as_dict=1,
|
||||
)
|
||||
details["certificate_count"] = count
|
||||
return details
|
||||
|
||||
|
||||
def filter_by_open_to_criteria(participants, open_to_opportunities, hiring):
|
||||
if not open_to_opportunities and not hiring:
|
||||
return participants
|
||||
|
||||
if open_to_opportunities:
|
||||
participants = [participant for participant in participants if participant.open_to == "Opportunities"]
|
||||
|
||||
if hiring:
|
||||
participants = [participant for participant in participants if participant.open_to == "Hiring"]
|
||||
|
||||
return participants
|
||||
|
||||
@@ -1635,7 +1670,7 @@ def get_profile_details(username):
|
||||
"headline",
|
||||
"language",
|
||||
"cover_image",
|
||||
"looking_for_job",
|
||||
"open_to",
|
||||
"linkedin",
|
||||
"github",
|
||||
"twitter",
|
||||
|
||||
@@ -52,8 +52,14 @@ class TestCourseEvaluator(UnitTestCase):
|
||||
return first_date
|
||||
|
||||
def calculated_last_date_of_schedule(self, first_date):
|
||||
last_date = add_days(first_date, 56) # 8 weeks course
|
||||
return last_date
|
||||
last_day = add_days(first_date, 56)
|
||||
offset_monday = (0 - last_day.weekday() + 7) % 7 # 0 for Monday
|
||||
offset_wednesday = (2 - last_day.weekday() + 7) % 7 # 2 for Wednesday
|
||||
if offset_monday > offset_wednesday and offset_monday < 4:
|
||||
last_day = add_days(last_day, offset_monday)
|
||||
else:
|
||||
last_day = add_days(last_day, offset_wednesday)
|
||||
return last_day
|
||||
|
||||
def test_unavailability_dates(self):
|
||||
unavailable_from = getdate(self.evaluator.unavailable_from)
|
||||
|
||||
@@ -2,6 +2,7 @@ import frappe
|
||||
from frappe.tests import UnitTestCase
|
||||
from frappe.utils import add_days, nowdate
|
||||
|
||||
from lms.lms.api import get_certified_participants
|
||||
from lms.lms.doctype.lms_certificate.lms_certificate import get_default_certificate_template, is_certified
|
||||
|
||||
from .utils import (
|
||||
@@ -147,6 +148,7 @@ class TestUtils(UnitTestCase):
|
||||
certificate.member = member
|
||||
certificate.issue_date = frappe.utils.nowdate()
|
||||
certificate.template = get_default_certificate_template()
|
||||
certificate.published = 1
|
||||
certificate.save()
|
||||
return certificate
|
||||
|
||||
@@ -265,6 +267,36 @@ class TestUtils(UnitTestCase):
|
||||
self.assertIsNone(is_certified(self.course.name))
|
||||
frappe.session.user = "Administrator"
|
||||
|
||||
def test_certified_participants_with_category(self):
|
||||
filters = {"category": "Utility Course"}
|
||||
certified_participants = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants), 1)
|
||||
self.assertEqual(certified_participants[0].member, self.student1.email)
|
||||
|
||||
filters = {"category": "Nonexistent Category"}
|
||||
certified_participants_no_match = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_no_match), 0)
|
||||
|
||||
def test_certified_participants_with_open_to_opportunities(self):
|
||||
filters = {"open_to_opportunities": 1}
|
||||
certified_participants_open_to_oppo = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_open_to_oppo), 0)
|
||||
|
||||
frappe.db.set_value("User", self.student1.email, "open_to", "Opportunities")
|
||||
certified_participants_open_to_oppo = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_open_to_oppo), 1)
|
||||
frappe.db.set_value("User", self.student1.email, "open_to", "")
|
||||
|
||||
def test_certified_participants_with_open_to_hiring(self):
|
||||
filters = {"hiring": 1}
|
||||
certified_participants_hiring = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_hiring), 0)
|
||||
|
||||
frappe.db.set_value("User", self.student1.email, "open_to", "Hiring")
|
||||
certified_participants_hiring = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_hiring), 1)
|
||||
frappe.db.set_value("User", self.student1.email, "open_to", "")
|
||||
|
||||
def test_rating_validation(self):
|
||||
student3 = self.create_user("student3@example.com", "Emily", "Cooper", ["LMS Student"])
|
||||
with self.assertRaises(frappe.exceptions.ValidationError):
|
||||
|
||||
@@ -113,4 +113,5 @@ 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
|
||||
lms.patches.v2_0.fix_job_application_resume_urls
|
||||
lms.patches.v2_0.fix_job_application_resume_urls
|
||||
lms.patches.v2_0.open_to_opportunities
|
||||
10
lms/patches/v2_0/open_to_opportunities.py
Normal file
10
lms/patches/v2_0/open_to_opportunities.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
looking_for_job = frappe.get_all("User", {"looking_for_job": 1}, ["name"])
|
||||
|
||||
for user in looking_for_job:
|
||||
frappe.db.set_value("User", user.name, "open_to", "Opportunities")
|
||||
|
||||
frappe.db.delete("Custom Field", {"dt": "User", "fieldname": "looking_for_job"})
|
||||
Reference in New Issue
Block a user