-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved to `vocabularies_async` and `types` to be consistent with `dev_async`. - Set `internal_resource` to the old resource. - Added `ResourceConfig`. - Added module to `default_settings`. - Addressed feedbacks.
- Loading branch information
1 parent
27e72bf
commit 72e3733
Showing
7 changed files
with
128 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# -*- coding: utf-8; -*- | ||
# | ||
# This file is part of Superdesk. | ||
# | ||
# Copyright 2013, 2025 Sourcefabric z.u. and contributors. | ||
# | ||
# For the full copyright and license information, please see the | ||
# AUTHORS and LICENSE files distributed with this source code, or | ||
# at https://www.sourcefabric.org/superdesk/license | ||
|
||
|
||
from enum import Enum, unique | ||
import logging | ||
from typing import Annotated, Any | ||
|
||
from pydantic import BaseModel, ConfigDict, Field | ||
from quart_babel import gettext as _ | ||
|
||
from superdesk.core.resources import ResourceModel | ||
from superdesk.core.resources.model import Dataclass, ResourceModel | ||
from superdesk.core.resources.validators import validate_maxlength | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Tag(Dataclass): | ||
text: str | ||
|
||
|
||
class Item(BaseModel): | ||
name: str | ||
qcode: str | ||
is_active: bool = True | ||
|
||
|
||
class DateShortcut(Dataclass): | ||
value: int | ||
term: str | ||
label: str | ||
|
||
|
||
class CustomFieldConfig(Dataclass): | ||
increment_steps: list[int] | ||
initial_offset_minutes: int | ||
|
||
|
||
@unique | ||
class CVAccessType(str, Enum): | ||
MANAGEABLE = "manageable" | ||
UNMANAGEABLE = "unmanageable" | ||
|
||
|
||
@unique | ||
class SelectionType(str, Enum): | ||
SINGLE_SELECTION = "single selection" | ||
MULTI_SELECTION = "multi selection" | ||
DO_NOT_SHOW = "do not show" | ||
|
||
|
||
class VocabulariesResourceModel(ResourceModel): | ||
display_name: str | ||
description: str | None = None | ||
helper_text: Annotated[str | None, validate_maxlength(120)] = None | ||
tags: list[Tag] | None = None | ||
popup_width: int | None = None | ||
management_type: Annotated[CVAccessType, Field(alias="type")] | ||
items: list[Item] | ||
selection_type: SelectionType | None = None | ||
read_only: bool | None = None | ||
schema_field: str | None = None | ||
dependent: bool = False | ||
service: dict[str, int] = Field(default_factory=dict) | ||
priority: int = 0 | ||
unique_field: str | None = None | ||
schema_: dict[str, dict] | ||
field_type_: str | None = None | ||
field_options_: dict[str, Any] = Field(default_factory=dict) | ||
init_version: int = 0 | ||
preffered_items: bool = False | ||
disable_entire_category_selection: bool = False | ||
date_shortcuts: list[DateShortcut] | None = None | ||
custom_field_type: str | None = None | ||
custom_field_config: CustomFieldConfig | None = None | ||
translations: dict[str, dict[str, Any]] = Field(default_factory=dict) |
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,7 @@ | ||
from superdesk.core.module import Module | ||
from .service import VocabulariesService | ||
from .module import desks_resource_config | ||
|
||
__all__ = ["VocabulariesService"] | ||
|
||
module = Module(name="apps.desks_async", resources=[desks_resource_config]) |
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,28 @@ | ||
# -*- coding: utf-8; -*- | ||
# | ||
# This file is part of Superdesk. | ||
# | ||
# Copyright 2013, 2025 Sourcefabric z.u. and contributors. | ||
# | ||
# For the full copyright and license information, please see the | ||
# AUTHORS and LICENSE files distributed with this source code, or | ||
# at https://www.sourcefabric.org/superdesk/license | ||
|
||
from superdesk.core.resources import ResourceConfig, MongoResourceConfig, MongoIndexOptions | ||
from superdesk.types import VocabulariesResourceModel | ||
from .service import VocabulariesService | ||
|
||
|
||
desks_resource_config = ResourceConfig( | ||
name="vocabularies", | ||
data_class=VocabulariesResourceModel, | ||
service=VocabulariesService, | ||
mongo=MongoResourceConfig( | ||
indexes=[ | ||
MongoIndexOptions( | ||
name="field_type", | ||
keys=[("field_type", 1)], | ||
), | ||
], | ||
), | ||
) |
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