class ArchivedResource(Resource): datasource = { "search_backend": "elastic", "aggregations": aggregations, "default_sort": [("_updated", -1)], "elastic_filter_callback": get_content_filter, "projection": { "old_version": 0, "last_version": 0 }, } mongo_prefix = "ARCHIVED" extra_fields = published_item_fields.copy() # item_id + _current_version will be used fetch archived item. extra_fields["archived_id"] = {"type": "string", "mapping": not_analyzed} schema = item_schema(extra_fields) resource_methods = ["GET"] item_methods = ["GET", "PATCH", "DELETE"] privileges = {"PATCH": "archived", "DELETE": "archived"} additional_lookup = {"url": 'regex("[\w,.:-]+")', "field": "archived_id"} mongo_indexes = { "item_id_1": ([("item_id", 1)], { "background": True }), }
class ContentTemplatesApplyResource(Resource): endpoint_name = "content_templates_apply" resource_title = endpoint_name schema = { "template_name": { "type": "string", "required": True }, "item": { "type": "dict", "required": True, "schema": item_schema() }, "_links": { "type": "dict" }, } # in response there can be anything.. schema.update(get_schema()) resource_methods = ["POST"] item_methods = [] privileges = {"POST": ARCHIVE} url = "content_templates_apply"
class ArchivedResource(Resource): datasource = { 'search_backend': 'elastic', 'aggregations': aggregations, 'default_sort': [('_updated', -1)], 'elastic_filter_callback': get_content_filter, 'projection': { 'old_version': 0, 'last_version': 0 } } mongo_prefix = 'ARCHIVED' extra_fields = published_item_fields.copy() # item_id + _current_version will be used fetch archived item. extra_fields['archived_id'] = {'type': 'string', 'mapping': not_analyzed} schema = item_schema(extra_fields) resource_methods = ['GET'] item_methods = ['GET', 'PATCH', 'DELETE'] privileges = {'PATCH': 'archived', 'DELETE': 'archived'} additional_lookup = {'url': 'regex("[\w,.:-]+")', 'field': 'archived_id'} mongo_indexes = { 'item_id_1': ([('item_id', 1)], { 'background': True }), }
class PublishedItemResource(Resource): datasource = { "search_backend": "elastic", "aggregations": aggregations, "es_highlight": get_elastic_highlight_query, "default_sort": [("_updated", -1)], "elastic_filter_callback": get_content_filter, "projection": { "old_version": 0, "last_version": 0, }, } schema = item_schema(published_item_fields) etag_ignore_fields = [ config.ID_FIELD, "highlights", "item_id", LAST_PUBLISHED_VERSION, "moved_to_legal" ] privileges = {"POST": "publish_queue", "PATCH": "publish_queue"} item_methods = ["GET", "PATCH"] additional_lookup = {"url": 'regex("[\w,.:-]+")', "field": "item_id"} mongo_indexes = { "guid_1": ([("guid", 1)], { "background": True }), "item_id_1": ([("item_id", 1)], { "background": True }), }
class ContentTemplatesApplyResource(Resource): endpoint_name = 'content_templates_apply' resource_title = endpoint_name schema = { 'template_name': { 'type': 'string', 'required': True }, 'item': { 'type': 'dict', 'required': True, 'schema': item_schema() } } resource_methods = ['POST'] item_methods = [] privileges = {'POST': ARCHIVE} url = 'content_templates_apply'
class PublishedItemResource(Resource): datasource = { 'search_backend': 'elastic', 'aggregations': aggregations, 'default_sort': [('_updated', -1)], 'projection': { 'old_version': 0, 'last_version': 0 } } schema = item_schema(published_item_fields) etag_ignore_fields = [ config.ID_FIELD, 'highlights', 'item_id', LAST_PUBLISHED_VERSION ] privileges = {'POST': 'publish_queue', 'PATCH': 'publish_queue'} item_methods = ['GET', 'PATCH'] additional_lookup = {'url': 'regex("[\w,.:-]+")', 'field': 'item_id'}
class ContentTemplatesApplyResource(Resource): endpoint_name = 'content_templates_apply' resource_title = endpoint_name schema = { 'template_name': { 'type': 'string', 'required': True }, 'item': { 'type': 'dict', 'required': True, 'schema': item_schema() }, '_links': {'type': 'dict'}, } # in response there can be anything.. schema.update(get_schema()) resource_methods = ['POST'] item_methods = [] privileges = {'POST': ARCHIVE} url = 'content_templates_apply'
class PublishedItemResource(Resource): datasource = { 'search_backend': 'elastic', 'aggregations': aggregations, 'elastic_filter': { 'and': [{ 'term': { 'allow_post_publish_actions': True } }, { 'terms': { ITEM_STATE: [ CONTENT_STATE.SCHEDULED, CONTENT_STATE.PUBLISHED, CONTENT_STATE.KILLED, CONTENT_STATE.CORRECTED ] } }] }, 'default_sort': [('_updated', -1)], 'projection': { 'old_version': 0, 'last_version': 0 } } published_item_fields = { 'item_id': { 'type': 'string', 'mapping': not_analyzed }, # last_published_version field is set to true for last published version of the item in the published collection # and for the older version is set to false. This field is used to display the last version of the digital copy # in the published view. LAST_PUBLISHED_VERSION: { 'type': 'boolean', 'default': True }, 'rewritten_by': { 'type': 'string', 'mapping': not_analyzed, 'nullable': True }, # This field is set to False if the item is expired and is not killed after publishing/correcting. 'allow_post_publish_actions': { 'type': 'boolean', 'default': True }, # This field is set to True, when user uses "delete from archived" option. # When the article is expired, 'can be removed' flag is True and 'allow post publish actions' flag is False # then the article will be removed from published collection. 'can_be_removed': { 'type': 'boolean', 'default': False } } schema = item_schema(published_item_fields) etag_ignore_fields = [ config.ID_FIELD, 'highlights', 'item_id', LAST_PUBLISHED_VERSION ] privileges = {'POST': 'publish_queue', 'PATCH': 'publish_queue'} additional_lookup = {'url': 'regex("[\w,.:-]+")', 'field': 'item_id'}