forked from superdesk/superdesk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1669efa
commit 2664e79
Showing
6 changed files
with
449 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from superdesk.core.module import Module | ||
|
||
from .model import Content | ||
from .resources import ContentResourceService, content_model_config | ||
|
||
__all__ = [ | ||
"Content", | ||
"ContentResourceService", | ||
"content_model_config", | ||
] | ||
|
||
module = Module( | ||
name="tests.content", | ||
resources=[content_model_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,7 @@ | ||
from superdesk.core.resources import ResourceModel, ModelWithVersions | ||
|
||
|
||
class Content(ResourceModel, ModelWithVersions): | ||
guid: str | ||
lock_user: str | None = None | ||
headline: str | None = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from superdesk.core.resources import ( | ||
ResourceConfig, | ||
RestEndpointConfig, | ||
AsyncResourceService, | ||
MongoResourceConfig, | ||
MongoIndexOptions, | ||
ElasticResourceConfig, | ||
) | ||
from .model import Content | ||
|
||
|
||
class ContentResourceService(AsyncResourceService[Content]): | ||
resource_name = "content_async" | ||
|
||
|
||
content_model_config = ResourceConfig( | ||
name="content_async", | ||
data_class=Content, | ||
service=ContentResourceService, | ||
versioning=True, | ||
ignore_fields_in_versions=["lock_user"], | ||
rest_endpoints=RestEndpointConfig(), | ||
mongo=MongoResourceConfig( | ||
indexes=[ | ||
MongoIndexOptions( | ||
name="guid", | ||
keys=[("guid", 1)], | ||
background=True, | ||
unique=False, | ||
), | ||
], | ||
version_indexes=[ | ||
MongoIndexOptions( | ||
name="_id_document_1", | ||
keys=[("_id_document", 1)], | ||
background=True, | ||
unique=False, | ||
) | ||
], | ||
), | ||
) |
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
Oops, something went wrong.