diff --git a/requirements/base.in b/requirements/base.in index 74494e9d..82102590 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -11,7 +11,6 @@ jsonschema django~=3.2 django-admin-index django-axes -django-choices django-redis django-rosetta maykin-django-two-factor-auth diff --git a/requirements/base.txt b/requirements/base.txt index 22696aa3..52579bad 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -70,9 +70,7 @@ django-admin-index==3.1.0 django-axes==5.41.1 # via -r requirements/base.in django-choices==2.0.0 - # via - # -r requirements/base.in - # vng-api-common + # via vng-api-common django-filter==2.4.0 # via # -r requirements/base.in diff --git a/src/objects/api/constants.py b/src/objects/api/constants.py index 25a0e5a5..0765673b 100644 --- a/src/objects/api/constants.py +++ b/src/objects/api/constants.py @@ -1,12 +1,11 @@ +from django.db import models from django.utils.translation import gettext_lazy as _ -from djchoices import ChoiceItem, DjangoChoices - -class Operators(DjangoChoices): - exact = ChoiceItem("exact", _("equal to")) - gt = ChoiceItem("gt", _("greater than")) - gte = ChoiceItem("gte", _("greater than or equal to")) - lt = ChoiceItem("lt", _("lower than")) - lte = ChoiceItem("lte", _("lower than or equal to")) - icontains = ChoiceItem("icontains", _("case-insensitive partial match")) +class Operators(models.TextChoices): + exact = "exact", _("equal to") + gt = "gt", _("greater than") + gte = "gte", _("greater than or equal to") + lt = "lt", _("lower than") + lte = "lte", _("lower than or equal to") + icontains = "icontains", _("case-insensitive partial match") diff --git a/src/objects/api/utils.py b/src/objects/api/utils.py index 3b5330e4..40385aff 100644 --- a/src/objects/api/utils.py +++ b/src/objects/api/utils.py @@ -1,7 +1,7 @@ from datetime import date from typing import Union -from djchoices import DjangoChoices +from django.db import models from objects.typing import JSONValue @@ -33,15 +33,11 @@ def is_number(value: str) -> bool: return True -def display_choice_values_for_help_text(choices: DjangoChoices) -> str: +def display_choice_values_for_help_text(Choices: type[models.TextChoices]) -> str: items = [] - for key, value in choices.choices: - description = getattr(choices.get_choice(key), "description", None) - if description: - item = f"* `{key}` - ({value}) {description}" - else: - item = f"* `{key}` - {value}" + for key, value in Choices.choices: + item = f"* `{key}` - {value}" items.append(item) return "\n".join(items) diff --git a/src/objects/token/constants.py b/src/objects/token/constants.py index bc583bee..10d0a1cc 100644 --- a/src/objects/token/constants.py +++ b/src/objects/token/constants.py @@ -1,8 +1,7 @@ +from django.db import models from django.utils.translation import gettext_lazy as _ -from djchoices import ChoiceItem, DjangoChoices - -class PermissionModes(DjangoChoices): - read_only = ChoiceItem("read_only", _("Read-only")) - read_and_write = ChoiceItem("read_and_write", _("Read and write")) +class PermissionModes(models.TextChoices): + read_only = "read_only", _("Read-only") + read_and_write = "read_and_write", _("Read and write")