Skip to content

Commit

Permalink
refactor: clean up filters code
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Aug 28, 2023
1 parent 0deb9f6 commit 2dc7cc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
47 changes: 11 additions & 36 deletions hrms/www/jobs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,17 @@ <h3 class="mt-0 mb-10">{{ _("Job Openings") }}</h3>
<p class="lg-text font-weight-bold">Filters</p>
<a class="ml-auto sm-text" href="/jobs">{{ _("Clear All") }}</a>
</div>
<div class="mb-10">
<p class="font-weight-bold mb-4">Companies</p>
{% for company in companies %}
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="{{ company }}">
<label class="form-check-label" for="{{ company }}">{{ company }}</label>
</div>
{% endfor %}
</div>
<div class="mb-10">
<p class="font-weight-bold mb-4">Departments</p>
{% for department in departments %}
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="{{ department }}">
<label class="form-check-label" for="{{ department }}">{{ department }}</label>
</div>
{% endfor %}
</div>
<div class="mb-10">
<p class="font-weight-bold mb-4">Location</p>
{% for location in locations %}
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="{{ location }}">
<label class="form-check-label" for="{{ location }}">{{ location }}</label>
</div>
{% endfor %}
</div>
<div class="mb-10">
<p class="font-weight-bold mb-4">Employment Type</p>
{% for type in employment_types %}
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="{{ type }}">
<label class="form-check-label" for="{{ type }}">{{ type }}</label>
</div>
{% endfor %}
</div>
{% for name, values in filters.items() %}
<div class="mb-10">
<p class="font-weight-bold mb-4">{{ name }}</p>
{% for value in values %}
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="{{ value }}">
<label class="form-check-label" for="{{ value }}">{{ value }}</label>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<div class="col-9">
<div class="mb-12">
Expand Down
11 changes: 7 additions & 4 deletions hrms/www/jobs/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
def get_context(context):
context.parents = [{"name": _("My Account"), "route": "/"}]
context.job_openings = get_job_openings()
context.companies, context.departments, context.locations, context.employment_types = get_filters(
context.job_openings
)
context.filters = get_filters(context.job_openings)


def get_job_openings(txt=None, filters=None, limit_start=0, limit_page_length=20, order_by=None):
Expand Down Expand Up @@ -88,4 +86,9 @@ def get_filters(job_openings):
departments.sort()
locations.sort()
employment_types.sort()
return companies, departments, locations, employment_types
return {
"Company": companies,
"Department": departments,
"Location": locations,
"Employment Type": employment_types,
}

0 comments on commit 2dc7cc3

Please sign in to comment.