feat: search jobs from command palette

This commit is contained in:
Jannat Patel
2025-12-12 19:14:25 +05:30
parent f49bb98b92
commit 1bc610bd76
4 changed files with 75 additions and 12 deletions

View File

@@ -23,11 +23,14 @@ def prepare_search_results(result):
for r in result["results"]:
doctype = r["doctype"]
if doctype == "LMS Course" and can_access_course(r, roles):
r["instructors_info"] = get_instructor_info(doctype, r)
r["author_info"] = get_instructor_info(doctype, r)
groups.setdefault("Courses", []).append(r)
elif doctype == "LMS Batch" and can_access_batch(r, roles):
r["instructors_info"] = get_instructor_info(doctype, r)
r["author_info"] = get_instructor_info(doctype, r)
groups.setdefault("Batches", []).append(r)
elif doctype == "Job Opportunity" and can_access_job(r, roles):
r["author_info"] = get_instructor_info(doctype, r)
groups.setdefault("Job Opportunities", []).append(r)
out = []
for key in groups:
@@ -52,6 +55,12 @@ def can_access_batch(batch, roles):
return False
def can_access_job(job, roles):
if "Moderator" in roles:
return True
return job.get("status") == "Open"
def can_create_course(roles):
return "Course Creator" in roles or "Moderator" in roles