/
feedback_ratings.py
41 lines (31 loc) · 1.09 KB
/
feedback_ratings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
This module contains all constants representing the rating of the :class:`~integreat_cms.cms.models.feedback.feedback.Feedback` model.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from django.utils.translation import gettext_lazy as _
if TYPE_CHECKING:
from typing import Final
from django.utils.functional import Promise
#: Positive
POSITIVE: Final = True
#: Negative
NEGATIVE: Final = False
#: Not stated
NOT_STATED: Final = None
#: Not stated as string (used in the filter form)
NOT_STATED_STR: Final = ""
#: Choices to use these constants in a database field
CHOICES: Final[list[tuple[bool | None, Promise]]] = [
(POSITIVE, _("Positive")),
(NEGATIVE, _("Negative")),
(NOT_STATED, _("Not stated")),
]
#: Choices for the filter form (required because ``None`` is always converted to ``""``)
FILTER_CHOICES: Final[list[tuple[bool | str, Promise]]] = [
(POSITIVE, _("Positive")),
(NEGATIVE, _("Negative")),
(NOT_STATED_STR, _("Not stated")),
]
#: Initial filter options
INITIAL: Final[list[bool | str]] = [key for (key, val) in FILTER_CHOICES]