mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-18 15:50:21 +02:00
These methods were involved in a bug that was fixed without first evidencing the error in a test: https://github.com/suitenumerique/docs/pull/556 Fixes https://github.com/suitenumerique/docs/issues/567
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""
|
|
Core application enums declaration
|
|
"""
|
|
|
|
import re
|
|
|
|
from django.conf import global_settings, settings
|
|
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
ATTACHMENTS_FOLDER = "attachments"
|
|
UUID_REGEX = (
|
|
r"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
|
|
)
|
|
FILE_EXT_REGEX = r"\.[a-zA-Z]{3,4}"
|
|
MEDIA_STORAGE_URL_PATTERN = re.compile(
|
|
f"{settings.MEDIA_URL:s}(?P<pk>{UUID_REGEX:s})/"
|
|
f"(?P<key>{ATTACHMENTS_FOLDER:s}/{UUID_REGEX:s}{FILE_EXT_REGEX:s})$"
|
|
)
|
|
COLLABORATION_WS_URL_PATTERN = re.compile(rf"(?:^|&)room=(?P<pk>{UUID_REGEX})(?:&|$)")
|
|
|
|
|
|
# In Django's code base, `LANGUAGES` is set by default with all supported languages.
|
|
# We can use it for the choice of languages which should not be limited to the few languages
|
|
# active in the app.
|
|
# pylint: disable=no-member
|
|
ALL_LANGUAGES = {language: _(name) for language, name in global_settings.LANGUAGES}
|
|
|
|
|
|
class MoveNodePositionChoices(models.TextChoices):
|
|
"""Defines the possible positions when moving a django-treebeard node."""
|
|
|
|
FIRST_CHILD = "first-child", _("First child")
|
|
LAST_CHILD = "last-child", _("Last child")
|
|
FIRST_SIBLING = "first-sibling", _("First sibling")
|
|
LAST_SIBLING = "last-sibling", _("Last sibling")
|
|
LEFT = "left", _("Left")
|
|
RIGHT = "right", _("Right")
|