@@ -257,12 +257,12 @@
|
||||
"length": 0,
|
||||
"link_filters": null,
|
||||
"mandatory_depends_on": null,
|
||||
"modified": "2025-12-24 12:56:32.110405",
|
||||
"modified": "2025-12-24 12:56:32.110406",
|
||||
"module": null,
|
||||
"name": "User-open_to",
|
||||
"no_copy": 0,
|
||||
"non_negative": 0,
|
||||
"options": "\nOpportunities\nHiring",
|
||||
"options": "\nWork\nHiring",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
|
||||
@@ -331,8 +331,8 @@ def get_certification_query(filters):
|
||||
)
|
||||
if field == "member_name":
|
||||
query = query.where(Certificate.member_name.like(value[1]))
|
||||
if field == "open_to_opportunities":
|
||||
query = query.where(User.open_to == "Opportunities")
|
||||
if field == "open_to_work":
|
||||
query = query.where(User.open_to == "Work")
|
||||
if field == "hiring":
|
||||
query = query.where(User.open_to == "Hiring")
|
||||
return query
|
||||
|
||||
@@ -277,14 +277,14 @@ class TestUtils(UnitTestCase):
|
||||
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)
|
||||
def test_certified_participants_with_open_to_work(self):
|
||||
filters = {"open_to_work": 1}
|
||||
certified_participants_open_to_work = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_open_to_work), 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", "Work")
|
||||
certified_participants_open_to_work = get_certified_participants(filters=filters)
|
||||
self.assertEqual(len(certified_participants_open_to_work), 1)
|
||||
frappe.db.set_value("User", self.student1.email, "open_to", "")
|
||||
|
||||
def test_certified_participants_with_open_to_hiring(self):
|
||||
|
||||
@@ -114,4 +114,5 @@ 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.open_to_opportunities
|
||||
lms.patches.v2_0.open_to_opportunities
|
||||
lms.patches.v2_0.open_to_work
|
||||
12
lms/patches/v2_0/open_to_work.py
Normal file
12
lms/patches/v2_0/open_to_work.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
open_to_field_exists = frappe.db.exists("Custom Field", {"dt": "User", "fieldname": "open_to"})
|
||||
|
||||
if not open_to_field_exists:
|
||||
return
|
||||
|
||||
open_to_opportunities = frappe.get_all("User", {"open_to": "Opportunities"}, ["name"])
|
||||
for user in open_to_opportunities:
|
||||
frappe.db.set_value("User", user.name, "open_to", "Work")
|
||||
@@ -1,6 +1,7 @@
|
||||
import frappe
|
||||
from frappe.tests.test_api import FrappeAPITestCase
|
||||
|
||||
from lms.auth import authenticate
|
||||
from lms.lms.test_utils import TestUtils
|
||||
|
||||
|
||||
@@ -11,24 +12,16 @@ class TestAuth(FrappeAPITestCase):
|
||||
)
|
||||
|
||||
def test_allowed_path(self):
|
||||
site_url = frappe.utils.get_site_url(frappe.local.site)
|
||||
headers = {"Authorization": "Bearer set_test_example_user"}
|
||||
url = site_url + "/api/method/lms.lms.utils.get_courses"
|
||||
response = self.get(
|
||||
url,
|
||||
headers=headers,
|
||||
)
|
||||
self.assertNotEqual(response.json.get("exc_type"), "PermissionError")
|
||||
frappe.form_dict.cmd = "ping"
|
||||
frappe.session.user = self.normal_user.name
|
||||
authenticate()
|
||||
frappe.session.user = "Administrator"
|
||||
|
||||
def test_not_allowed_path(self):
|
||||
site_url = frappe.utils.get_site_url(frappe.local.site)
|
||||
headers = {"Authorization": "Bearer set_test_example_user"}
|
||||
url = site_url + "/api/method/frappe.auth.get_logged_user"
|
||||
response = self.get(
|
||||
url,
|
||||
headers=headers,
|
||||
)
|
||||
self.assertEqual(response.json.get("exc_type"), "PermissionError")
|
||||
frappe.form_dict.cmd = "frappe.auth.get_logged_user"
|
||||
frappe.session.user = self.normal_user.name
|
||||
self.assertRaises(frappe.PermissionError, authenticate)
|
||||
frappe.session.user = "Administrator"
|
||||
|
||||
def tearDown(self):
|
||||
frappe.delete_doc("User", self.normal_user.name)
|
||||
|
||||
Reference in New Issue
Block a user