|
| 1 | +# This file is part of Superdesk. |
| 2 | +# |
| 3 | +# Copyright 2013, 2025 Sourcefabric z.u. and contributors. |
| 4 | +# |
| 5 | +# For the full copyright and license information, please see the |
| 6 | +# AUTHORS and LICENSE files distributed with this source code, or |
| 7 | +# at https://www.sourcefabric.org/superdesk/license |
| 8 | + |
| 9 | +from apps.content_types.content_types import CONTENT_TYPE_PRIVILEGE |
| 10 | +from superdesk.core.resources import ResourceConfig, MongoResourceConfig, MongoIndexOptions |
| 11 | +from superdesk.core.resources.resource_rest_endpoints import RestEndpointConfig |
| 12 | +from superdesk.types.content_types import ContentTypes |
| 13 | +from .service import ContentTypesService |
| 14 | +from superdesk.core.auth.privilege_rules import http_method_privilege_based_rules |
| 15 | + |
| 16 | + |
| 17 | +content_types_resource_config = ResourceConfig( |
| 18 | + name="content_types", |
| 19 | + data_class=ContentTypes, |
| 20 | + service=ContentTypesService, |
| 21 | + mongo=MongoResourceConfig( |
| 22 | + indexes=[ |
| 23 | + MongoIndexOptions(name="label_1", keys=[("label", 1)], unique=True), |
| 24 | + ], |
| 25 | + ), |
| 26 | + default_sort=[("priority", -1)], |
| 27 | + rest_endpoints=RestEndpointConfig( |
| 28 | + id_param_type=r'regex("[\w,.:-]+")', |
| 29 | + auth=http_method_privilege_based_rules( |
| 30 | + { |
| 31 | + "POST": CONTENT_TYPE_PRIVILEGE, |
| 32 | + "PATCH": CONTENT_TYPE_PRIVILEGE, |
| 33 | + "DELETE": CONTENT_TYPE_PRIVILEGE, |
| 34 | + } |
| 35 | + ), |
| 36 | + ), |
| 37 | +) |
0 commit comments