-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1769] Replace deprecated djchoices with native Django choices
- Loading branch information
Showing
20 changed files
with
238 additions
and
159 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
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
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,18 +1,17 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from djchoices import ChoiceItem, DjangoChoices | ||
|
||
class IndicatorChoices(models.TextChoices): | ||
plan_new_contacts = "plan_new_contacts", _("Plans > new contacts") | ||
inbox_new_messages = "inbox_new_messages", _("Inbox > new messages") | ||
|
||
class IndicatorChoices(DjangoChoices): | ||
plan_new_contacts = ChoiceItem("plan_new_contacts", _("Plans > new contacts")) | ||
inbox_new_messages = ChoiceItem("inbox_new_messages", _("Inbox > new messages")) | ||
|
||
|
||
class Icons(DjangoChoices): | ||
person = ChoiceItem("person", _("Home")) | ||
description = ChoiceItem("description", _("Products")) | ||
inbox = ChoiceItem("inbox", _("Inbox")) | ||
inventory_2 = ChoiceItem("inventory_2", _("Cases")) | ||
group = ChoiceItem("group", _("Collaborate")) | ||
help_outline = ChoiceItem("help_outline", _("Help")) | ||
euro_outline = ChoiceItem("euro_outline", _("Benefits")) | ||
class Icons(models.TextChoices): | ||
person = "person", _("Home") | ||
description = "description", _("Products") | ||
inbox = "inbox", _("Inbox") | ||
inventory_2 = "inventory_2", _("Cases") | ||
group = "group", _("Collaborate") | ||
help_outline = "help_outline", _("Help") | ||
euro_outline = "euro_outline", _("Benefits") |
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,13 +1,12 @@ | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from djchoices import ChoiceItem, DjangoChoices | ||
|
||
class ColorTypeChoices(models.TextChoices): | ||
light = "#FFFFFF", _("light") | ||
dark = "#4B4B4B", _("dark") | ||
|
||
class ColorTypeChoices(DjangoChoices): | ||
light = ChoiceItem("#FFFFFF", _("light")) | ||
dark = ChoiceItem("#4B4B4B", _("dark")) | ||
|
||
|
||
class OpenIDDisplayChoices(DjangoChoices): | ||
admin = ChoiceItem("admin", _("Admin")) | ||
regular = ChoiceItem("regular", _("Regular user")) | ||
class OpenIDDisplayChoices(models.TextChoices): | ||
admin = "admin", _("Admin") | ||
regular = "regular", _("Regular user") |
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,55 +1,49 @@ | ||
from djchoices import ChoiceItem, DjangoChoices | ||
from django.db import models | ||
|
||
|
||
class CSPDirective(DjangoChoices): | ||
class CSPDirective(models.TextChoices): | ||
# via https://django-csp.readthedocs.io/en/latest/configuration.html | ||
DEFAULT_SRC = ChoiceItem("default-src", label="default-src") | ||
SCRIPT_SRC = ChoiceItem("script-src", label="script-src") | ||
SCRIPT_SRC_ATTR = ChoiceItem("script-src-attr", label="script-src-attr") | ||
SCRIPT_SRC_ELEM = ChoiceItem("script-src-elem", label="script-src-elem") | ||
IMG_SRC = ChoiceItem("img-src", label="img-src") | ||
OBJECT_SRC = ChoiceItem("object-src", label="object-src") | ||
PREFETCH_SRC = ChoiceItem("prefetch-src", label="prefetch-src") | ||
MEDIA_SRC = ChoiceItem("media-src", label="media-src") | ||
FRAME_SRC = ChoiceItem("frame-src", label="frame-src") | ||
FONT_SRC = ChoiceItem("font-src", label="font-src") | ||
CONNECT_SRC = ChoiceItem("connect-src", label="connect-src") | ||
STYLE_SRC = ChoiceItem("style-src", label="style-src") | ||
STYLE_SRC_ATTR = ChoiceItem("style-src-attr", label="style-src-attr") | ||
STYLE_SRC_ELEM = ChoiceItem("style-src-elem", label="style-src-elem") | ||
BASE_URI = ChoiceItem( | ||
"base-uri", label="base-uri" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
CHILD_SRC = ChoiceItem( | ||
"child-src", label="child-src" | ||
) # Note: Deprecated in CSP v3. Use frame-src and worker-src instead. | ||
FRAME_ANCESTORS = ChoiceItem( | ||
"frame-ancestors", label="frame-ancestors" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
NAVIGATE_TO = ChoiceItem( | ||
"navigate-to", label="navigate-to" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
FORM_ACTION = ChoiceItem( | ||
"form-action", label="form-action" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
SANDBOX = ChoiceItem( | ||
"sandbox", label="sandbox" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
REPORT_URI = ChoiceItem( | ||
"report-uri", label="report-uri" | ||
) # Each URI can be a full or relative URI. None Note: This doesn’t use default-src as a fall-back. | ||
REPORT_TO = ChoiceItem( | ||
"report-to", label="report-to" | ||
) # A string describing a reporting group. None Note: This doesn’t use default-src as a fall-back. See Section 1.2: https://w3c.github.io/reporting/#group | ||
MANIFEST_SRC = ChoiceItem("manifest-src", label="manifest-src") | ||
WORKER_SRC = ChoiceItem("worker-src", label="worker-src") | ||
PLUGIN_TYPES = ChoiceItem( | ||
"plugin-types", label="plugin-types" | ||
) # Note: This doesn’t use default-src as a fall-back. | ||
REQUIRE_SRI_FOR = ChoiceItem( | ||
"require-sri-for", label="require-sri-for" | ||
) # Valid values: script, style, or both. See: require-sri-for-known-tokens Note: This doesn’t use default-src as a fall-back. | ||
|
||
# CSP_UPGRADE_INSECURE_REQUESTS # Include upgrade-insecure-requests directive. A boolean. False See: upgrade-insecure-requests | ||
# CSP_BLOCK_ALL_MIXED_CONTENT # Include block-all-mixed-content directive. A boolean. False See: block-all-mixed-content | ||
# CSP_INCLUDE_NONCE_IN # Include dynamically generated nonce in all listed directives, e.g. CSP_INCLUDE_NONCE_IN=['script-src'] will add 'nonce-<b64-value>' to the script-src directive. | ||
DEFAULT_SRC = "default-src", "default-src" | ||
SCRIPT_SRC = "script-src", "script-src" | ||
SCRIPT_SRC_ATTR = "script-src-attr", "script-src-attr" | ||
SCRIPT_SRC_ELEM = "script-src-elem", "script-src-elem" | ||
IMG_SRC = "img-src", "img-src" | ||
OBJECT_SRC = "object-src", "object-src" | ||
PREFETCH_SRC = "prefetch-src", "prefetch-src" | ||
MEDIA_SRC = "media-src", "media-src" | ||
FRAME_SRC = "frame-src", "frame-src" | ||
FONT_SRC = "font-src", "font-src" | ||
CONNECT_SRC = "connect-src", "connect-src" | ||
STYLE_SRC = "style-src", "style-src" | ||
STYLE_SRC_ATTR = "style-src-attr", "style-src-attr" | ||
STYLE_SRC_ELEM = "style-src-elem", "style-src-elem" | ||
BASE_URI = ( | ||
"base-uri", | ||
"base-uri", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
CHILD_SRC = ( | ||
"child-src", | ||
"child-src", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
FRAME_ANCESTORS = ( | ||
"frame-ancestors", | ||
"frame-ancestors", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
NAVIGATE_TO = ( | ||
"navigate-to", | ||
"navigate-to", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
FORM_ACTION = ( | ||
"form-action", | ||
"form-action", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
SANDBOX = "sandbox", "sandbox" # Note: This doesn’t use default-src as a fall-back | ||
REPORT_URI = ( | ||
"report-uri", | ||
"report-uri", | ||
) # Note: This doesn’t use default-src as a fall-back | ||
REPORT_TO = "report-to", "report-to" | ||
MANIFEST_SRC = "manifest-src", "manifest-src" | ||
WORKER_SRC = "worker-src", "worker-src" | ||
PLUGIN_TYPES = "plugin-types", "plugin-types" | ||
REQUIRE_SRI_FOR = "require-sri-for", "require-sri-for" |
Empty file.
Empty file.
Oops, something went wrong.