-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
www.job_seekers: add sort on table headers
- Loading branch information
1 parent
899889b
commit ce7bd08
Showing
10 changed files
with
140 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<th scope="col" aria-sort="{% if order == ascending_value %}ascending{% elif order == ascending_value.opposite %}descending{% else %}none{% endif %}"> | ||
<button type="button" data-setter-target="#id_order" data-setter-value="{% if order == ascending_value %}{{ ascending_value.opposite }}{% else %}{{ ascending_value }}{% endif %}"> | ||
{{ name }} | ||
</button> | ||
</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from enum import StrEnum | ||
import enum | ||
|
||
|
||
class JobSeekerSessionKinds(StrEnum): | ||
class JobSeekerSessionKinds(enum.StrEnum): | ||
CHECK_NIR_JOB_SEEKER = "job-seeker-check-nir-job-seeker" | ||
GET_OR_CREATE = "job-seeker-get-or-create" | ||
UPDATE = "job-seeker-update" | ||
|
||
|
||
class JobSeekerOrder(enum.StrEnum): | ||
FULL_NAME_ASC = "full_name" | ||
FULL_NAME_DESC = "-full_name" | ||
LAST_UPDATED_AT_ASC = "last_updated_at" | ||
LAST_UPDATED_AT_DESC = "-last_updated_at" | ||
JOB_APPLICATIONS_NB_ASC = "job_applications_nb" | ||
JOB_APPLICATIONS_NB_DESC = "-job_applications_nb" | ||
|
||
@property | ||
def opposite(self): | ||
if self.value.startswith("-"): | ||
return self.__class__(self.value[1:]) | ||
else: | ||
return self.__class__(f"-{self.value}") | ||
|
||
# Make the Enum work in Django's templates | ||
# See : | ||
# - https://docs.djangoproject.com/en/dev/ref/templates/api/#variables-and-lookups | ||
# - https://github.com/django/django/pull/12304 | ||
do_not_call_in_templates = enum.nonmember(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from itou.www.job_seekers_views.enums import JobSeekerOrder | ||
|
||
|
||
@pytest.mark.parametrize("order", JobSeekerOrder) | ||
@pytest.mark.no_django_db | ||
def test_opposite(order): | ||
assert order.opposite != order | ||
assert order.opposite.opposite == order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters