feat: search jobs from command palette
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -9,7 +9,15 @@ class LearningSearch(SQLiteSearch):
|
||||
INDEX_NAME = "learning.db"
|
||||
|
||||
INDEX_SCHEMA = {
|
||||
"metadata_fields": ["category", "owner", "published", "published_on", "start_date"],
|
||||
"metadata_fields": [
|
||||
"owner",
|
||||
"published",
|
||||
"published_on",
|
||||
"start_date",
|
||||
"status",
|
||||
"company_name",
|
||||
"creation",
|
||||
],
|
||||
"tokenizer": "unicode61 remove_diacritics 2 tokenchars '-_'",
|
||||
}
|
||||
|
||||
@@ -38,6 +46,20 @@ class LearningSearch(SQLiteSearch):
|
||||
{"modified": "start_date"},
|
||||
],
|
||||
},
|
||||
"Job Opportunity": {
|
||||
"fields": [
|
||||
"name",
|
||||
{"title": "job_title"},
|
||||
{"content": "description"},
|
||||
"owner",
|
||||
"location",
|
||||
"country",
|
||||
"company_name",
|
||||
"status",
|
||||
"creation",
|
||||
{"modified": "creation"},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
DOCTYPE_FIELDS = {
|
||||
@@ -61,6 +83,15 @@ class LearningSearch(SQLiteSearch):
|
||||
"modified",
|
||||
"owner",
|
||||
],
|
||||
"Job Opportunity": [
|
||||
"name",
|
||||
"job_title",
|
||||
"company_name",
|
||||
"description",
|
||||
"creation",
|
||||
"modified",
|
||||
"owner",
|
||||
],
|
||||
}
|
||||
|
||||
def build_index(self):
|
||||
|
||||
Reference in New Issue
Block a user