示例#1
0
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
        }),
    }
示例#2
0
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
        }),
    }