-
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.
Add Content profile name in Production API and Content API [SDESK-744…
…0] (#2811) * add Content profile name in Production API [SDESK-7440] * minor chnages * add new field and refactore changes * update content_types * remove mapping * minor changes * refactore code
- Loading branch information
1 parent
86f3bad
commit 83b2944
Showing
7 changed files
with
89 additions
and
2 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,13 @@ | ||
import superdesk | ||
from .service import ContentTypesService | ||
from .resource import ContentTypesResource | ||
|
||
|
||
def init_app(app) -> None: | ||
"""Initialize the `content_api` API endpoint. | ||
:param app: the API application object | ||
:type app: `Eve` | ||
""" | ||
service = ContentTypesService(datasource="content_types", backend=superdesk.get_backend()) | ||
ContentTypesResource(endpoint_name="content_types", app=app, service=service) |
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,24 @@ | ||
# -*- coding: utf-8; -*- | ||
# | ||
# This file is part of Superdesk. | ||
# | ||
# Copyright 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.resource import Resource | ||
from superdesk.metadata.utils import item_url | ||
|
||
|
||
class ContentTypesResource(Resource): | ||
url = "content_types" | ||
item_url = item_url | ||
item_methods = ["GET"] | ||
resource_methods = ["GET"] | ||
allow_unknown = True | ||
datasource = { | ||
"default_sort": [("priority", -1)], | ||
} | ||
internal_resource = True |
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,24 @@ | ||
# -*- coding: utf-8; -*- | ||
# | ||
# This file is part of Superdesk. | ||
# | ||
# Copyright 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 | ||
|
||
import bson | ||
import re | ||
import superdesk | ||
from superdesk.utils import format_content_type_name | ||
|
||
|
||
class ContentTypesService(superdesk.Service): | ||
def get_output_name(self, profile): | ||
try: | ||
_id = bson.ObjectId(profile) | ||
item = superdesk.get_resource_service("content_types").find_one(req=None, _id=_id) or {} | ||
return format_content_type_name(item, str(_id)) | ||
except bson.errors.InvalidId: | ||
return "None" |
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