def __init__(self, endpoint_name, app, service, endpoint_schema=None):
        self.schema = {
            "name": {"type": "string", "required": True, "nullable": False, "empty": False, "iunique": True},
            "source": required_string,
            "feeding_service": {"type": "string", "required": True, "allowed": allowed_feeding_services},
            "feed_parser": {"type": "string", "nullable": True, "allowed": allowed_feed_parsers},
            "content_types": {"type": "list", "default": content_type, "allowed": content_type},
            "allow_remove_ingested": {"type": "boolean", "default": False},
            "content_expiry": {"type": "integer", "default": app.config["INGEST_EXPIRY_MINUTES"]},
            "config": {"type": "dict"},
            "ingested_count": {"type": "integer"},
            "accepted_count": {"type": "integer"},
            "tokens": {"type": "dict"},
            "is_closed": {"type": "boolean", "default": False},
            "update_schedule": {
                "type": "dict",
                "schema": {
                    "hours": {"type": "integer"},
                    "minutes": {"type": "integer", "default": 5},
                    "seconds": {"type": "integer"},
                },
            },
            "idle_time": {"type": "dict", "schema": {"hours": {"type": "integer"}, "minutes": {"type": "integer"}}},
            "last_updated": {"type": "datetime"},
            "last_item_update": {"type": "datetime"},
            "rule_set": Resource.rel("rule_sets", nullable=True),
            "notifications": {
                "type": "dict",
                "schema": {
                    "on_update": {"type": "boolean", "default": True},
                    "on_close": {"type": "boolean", "default": True},
                    "on_open": {"type": "boolean", "default": True},
                    "on_error": {"type": "boolean", "default": True},
                },
            },
            "routing_scheme": Resource.rel("routing_schemes", nullable=True),
            "last_closed": {
                "type": "dict",
                "schema": {
                    "closed_at": {"type": "datetime"},
                    "closed_by": Resource.rel("users", nullable=True),
                    "message": {"type": "string"},
                },
            },
            "last_opened": {
                "type": "dict",
                "schema": {"opened_at": {"type": "datetime"}, "opened_by": Resource.rel("users", nullable=True)},
            },
            "critical_errors": {"type": "dict", "valueschema": {"type": "boolean"}},
        }

        self.item_methods = ["GET", "PATCH", "DELETE"]
        self.privileges = {"POST": "ingest_providers", "PATCH": "ingest_providers", "DELETE": "ingest_providers"}
        self.etag_ignore_fields = ["last_updated", "last_item_update", "last_closed", "last_opened"]

        super().__init__(endpoint_name, app, service, endpoint_schema=endpoint_schema)
예제 #2
0
    def __init__(self, endpoint_name, app, service, endpoint_schema=None):
        self.readonly = True if app.config.get("LDAP_SERVER", None) else False

        self.additional_lookup = {"url": 'regex("[\w]+")', "field": "username"}

        self.schema = {
            "username": {"type": "string", "unique": True, "required": True, "minlength": 1},
            "password": {"type": "string", "minlength": 5, "readonly": self.readonly},
            "first_name": {"type": "string", "readonly": self.readonly},
            "last_name": {"type": "string", "readonly": self.readonly},
            "display_name": {"type": "string", "readonly": self.readonly},
            "email": {"unique": True, "type": "email", "required": True},
            "phone": {"type": "phone_number", "readonly": self.readonly, "nullable": True},
            "language": {"type": "string", "readonly": self.readonly, "nullable": True},
            "user_info": {"type": "dict"},
            "picture_url": {"type": "string", "nullable": True},
            "avatar": Resource.rel("upload", embeddable=True, nullable=True),
            "role": Resource.rel("roles", True),
            "privileges": {"type": "dict"},
            "workspace": {"type": "dict"},
            "user_type": {"type": "string", "allowed": ["user", "administrator"], "default": "user"},
            "is_active": {"type": "boolean", "default": True},
            "is_enabled": {"type": "boolean", "default": True},
            "needs_activation": {"type": "boolean", "default": True},
            "desk": Resource.rel("desks"),  # Default desk of the user, which would be selected when logged-in.
            SIGN_OFF: {  # Used for putting a sign-off on the content when it's created/updated except kill
                "type": "string",
                "required": True,
                "regex": "^[a-zA-Z0-9]+$",
            },
            BYLINE: {"type": "string", "required": False, "nullable": True},
        }

        self.extra_response_fields = [
            "display_name",
            "username",
            "email",
            "user_info",
            "picture_url",
            "avatar",
            "is_active",
            "is_enabled",
            "needs_activation",
            "desk",
        ]

        self.etag_ignore_fields = ["session_preferences", "_etag"]

        self.datasource = {"projection": {"password": 0}, "default_sort": [("username", 1)]}

        self.privileges = {"POST": "users", "DELETE": "users", "PATCH": "users"}
        super().__init__(endpoint_name, app=app, service=service, endpoint_schema=endpoint_schema)
예제 #3
0
파일: common.py 프로젝트: jey07ro/superdesk
def item_schema(extra=None):
    """Create schema for item.

    :param extra: extra fields to be added to schema
    """
    schema = {
        'old_version': {
            'type': 'number',
        },
        'last_version': {
            'type': 'number',
        },
        'task': {'type': 'dict'},
        'destination_groups': {
            'type': 'list',
            'schema': Resource.rel('destination_groups', True)
        },
        'publish_schedule': {
            'type': 'datetime',
            'nullable': True
        },
        'marked_for_not_publication': {
            'type': 'boolean',
            'default': False
        }
    }
    schema.update(metadata_schema)
    if extra:
        schema.update(extra)
    return schema
class DuplicateResource(Resource):
    endpoint_name = "duplicate"
    resource_title = endpoint_name

    schema = {
        "desk": Resource.rel("desks", False, required=True, nullable=True),
        "stage": Resource.rel("stages", False, required=False),
        "type": {
            "type": "string",
            "required": True
        },
        "item_id": {
            "type": "string",
            "required": False
        },
    }

    url = "archive/<{0}:guid>/duplicate".format(item_url)

    resource_methods = ["POST"]
    item_methods = []

    privileges = {"POST": "duplicate"}
예제 #5
0
class ClientItemsResource(ItemsResource):
    datasource = {
        'source': 'archive',
        'elastic_filter': {'term': {'particular_type': 'item'}},
        'default_sort': [('order', -1)]
    }
    public_methods = ['GET', 'POST']
    public_item_methods = ['GET', 'POST']
    item_methods = ['GET']
    resource_methods = ['GET', 'POST']
    schema = {
        'client_blog': Resource.rel('client_blogs', True)
    }
    schema.update(ItemsResource.schema)
예제 #6
0
class DuplicateResource(Resource):
    endpoint_name = 'duplicate'
    resource_title = endpoint_name

    schema = {
        'desk': Resource.rel('desks', False, required=True),
        'stage': Resource.rel('stages', False, required=False),
        'type': {
            'type': 'string',
            'required': True
        },
        'item_id': {
            'type': 'string',
            'required': False
        }
    }

    url = 'archive/<{0}:guid>/duplicate'.format(item_url)

    resource_methods = ['POST']
    item_methods = []

    privileges = {'POST': 'duplicate'}
예제 #7
0
class AuthResource(Resource):
    schema = {
        "username": {"type": "string", "required": True},
        "password": {"type": "string", "required": True},
        "token": {"type": "string"},
        "user": Resource.rel("users", True),
    }

    resource_methods = ["POST"]
    item_methods = ["GET", "DELETE"]
    public_methods = ["POST", "DELETE"]
    extra_response_fields = ["user", "token", "username"]
    datasource = {"source": "auth"}
    mongo_indexes = {"token": ([("token", 1)], {"background": True})}
예제 #8
0
class DuplicateResource(Resource):
    endpoint_name = 'duplicate'
    resource_title = endpoint_name

    schema = {
        'desk': Resource.rel('desks', False, required=True)
    }

    url = 'archive/<{0}:guid>/duplicate'.format(item_url)

    resource_methods = ['POST']
    item_methods = []

    privileges = {'POST': 'duplicate'}
예제 #9
0
class DictionariesResource(Resource):
    """Dictionaries schema"""

    schema = {
        "name": {
            "type": "string",
            "required": True
        },
        "language_id": {
            "type": "string",
            "required": True
        },
        "content": {
            "type": "dict",
            "schema": {},
            "allow_unknown": True,
        },
        "content_list": {
            "type": "string",
        },
        DICTIONARY_FILE: {
            "type": "file",
        },
        "user": Resource.rel("users", nullable=True),
        "is_active": {
            "type": "string",
            "default": "true",
        },
        "type": {
            "type": "string",
            "default": DictionaryType.DICTIONARY.value,
            "allowed": DictionaryType.values()
        },
        "_file_id": {
            "type": "objectid",
            "nullable": True,
            "readonly": True
        },
        "init_version": {
            "type": "integer"
        },
    }
    item_methods = ["GET", "PATCH", "PUT", "DELETE"]
    resource_methods = ["GET", "POST", "DELETE"]
    privileges = {
        "POST": "dictionaries",
        "PATCH": "dictionaries",
        "DELETE": "dictionaries"
    }
    etag_ignore_fields = ["content", "content_list"]
예제 #10
0
class ActivityReportResource(Resource):
    """Activity Report schema
    """

    schema = {
        'operation': {
            'type': 'string',
            'required': True
        },
        'desk': Resource.rel('desks'),
        'operation_start_date': {
            'type': 'datetime',
            'required': True
        },
        'operation_end_date': {
            'type': 'datetime',
            'required': True
        },
        'subject': metadata_schema['subject'],
        'keywords': metadata_schema['keywords'],
        'category': metadata_schema['anpa_category'],
        'urgency_start': metadata_schema['urgency'],
        'urgency_end': metadata_schema['urgency'],
        'priority_start': metadata_schema['priority'],
        'priority_end': metadata_schema['priority'],
        'subscriber': {
            'type': 'string'
        },
        'group_by': {
            'type': 'list'
        },
        'report': {
            'type': 'dict'
        },
        'timestamp': {
            'type': 'datetime'
        },
        'force_regenerate': {
            'type': 'boolean',
            'default': False
        }
    }
    item_methods = ['GET', 'DELETE']
    resource_methods = ['POST']

    privileges = {
        'POST': 'activity_report',
        'DELETE': 'activity_report',
        'GET': 'activity_report'
    }
예제 #11
0
class HighlightsResource(Resource):
    """Highlights schema"""

    schema = {
        "name": {
            "type": "string",
            "iunique": True,
            "required": True
        },
        "template": Resource.rel("content_templates", nullable=True),
        "desks": {
            "type": "list",
            "schema": Resource.rel("desks", True)
        },
        "auto_insert": {
            "type": "string",
            "allowed": allowed_times,
            "default": TODAY_DATE,
        },
        "groups": {
            "type": "list",
            "schema": {
                "type": "string"
            }
        },
    }
    privileges = {
        "POST": "highlights",
        "PATCH": "highlights",
        "DELETE": "highlights"
    }

    mongo_indexes = {
        "name_1": ([("name", 1)], {
            "unique": True
        }),
    }
예제 #12
0
class HighlightsResource(Resource):
    """Highlights schema"""

    schema = {
        'name': {
            'type': 'string',
            'iunique': True,
            'required': True
        },
        'template': Resource.rel('content_templates', nullable=True),
        'desks': {
            'type': 'list',
            'schema': Resource.rel('desks', True)
        },
        'auto_insert': {
            'type': 'string',
            'allowed': allowed_times,
            'default': TODAY_DATE,
        },
        'groups': {
            'type': 'list',
            'schema': {
                'type': 'string'
            }
        }
    }
    privileges = {
        'POST': 'highlights',
        'PATCH': 'highlights',
        'DELETE': 'highlights'
    }

    mongo_indexes = {
        'name_1': ([('name', 1)], {
            'unique': True
        }),
    }
예제 #13
0
class StagesResource(Resource):
    schema = {
        'name': {
            'type': 'string',
            'required': True,
            'minlength': 1,
            'iunique_per_parent': 'desk'
        },
        'description': {
            'type': 'string'
        },
        'working_stage': {
            'type': 'boolean',
            'default': False
        },
        'default_incoming': {
            'type': 'boolean',
            'default': False
        },
        'task_status': {
            'type': 'string',
            'allowed': task_statuses
        },
        'desk_order': {
            'type': 'integer',
            'readonly': True
        },
        'desk': Resource.rel('desks', embeddable=True, required=True),
        'content_expiry': {
            'type': 'integer'
        },
        'is_visible': {
            'type': 'boolean',
            'default': True
        },
        'incoming_macro': {
            'type': 'string'
        },
        'outgoing_macro': {
            'type': 'string'
        },
        'onstage_macro': {
            'type': 'string'
        }
    }

    datasource = {'default_sort': [('desk_order', 1)]}

    privileges = {'POST': 'desks', 'DELETE': 'desks', 'PATCH': 'desks'}
예제 #14
0
class InternalDestinationsResource(Resource):
    schema = {
        'name': {
            'type': 'string',
            'required': True
        },
        'is_active': {
            'type': 'boolean',
            'required': True
        },
        'filter': Resource.rel('content_filters', nullable=True),
        'desk': Resource.rel('desks', nullable=False, required=True),
        'stage': Resource.rel('stages', nullable=True),
        'macro': {
            'type': 'string',
            'nullable': True
        },
    }

    privileges = {
        'POST': 'internal_destinations',
        'PATCH': 'internal_destinations',
        'DELETE': 'internal_destinations'
    }
예제 #15
0
class ActivityResource(Resource):
    endpoint_name = 'activity'
    resource_methods = ['GET']
    item_methods = ['GET', 'PATCH']
    schema = {
        'name': {'type': 'string'},
        'message': {'type': 'string'},
        'data': {'type': 'dict'},
        'read': {'type': 'dict'},
        'item': Resource.rel('archive', type='string'),
        'user': Resource.rel('users'),
        'desk': Resource.rel('desks')
    }
    exclude = {endpoint_name, 'notification'}
    datasource = {
        'default_sort': [('_created', -1)]
    }
    superdesk.register_default_user_preference('email:notification', {
        'type': 'bool',
        'enabled': True,
        'default': True,
        'label': 'Send notifications via email',
        'category': 'notifications'
    })
예제 #16
0
class ActivityResource(Resource):
    endpoint_name = 'activity'
    resource_methods = ['GET']
    item_methods = ['GET', 'PATCH']
    schema = {
        'name': {'type': 'string'},
        'message': {'type': 'string'},
        'data': {'type': 'dict'},
        'recipients': {
            'type': 'list',
            'schema': {
                'type': 'dict',
                'schema': {
                    'user_id': Resource.rel('users'),
                    'read': {'type': 'boolean', 'default': False},
                    'desk_id': Resource.rel('desks')
                }
            }
        },
        'item': Resource.rel('archive', type='string'),
        'user': Resource.rel('users'),
        'desk': Resource.rel('desks'),
        'resource': {'type': 'string'}
    }
    exclude = {endpoint_name, 'notification'}
    datasource = {
        'default_sort': [('_created', -1)],
        'filter': {'_created': {'$gte': utcnow() - datetime.timedelta(days=1)}}
    }
    superdesk.register_default_user_preference('email:notification', {
        'type': 'bool',
        'enabled': True,
        'default': True,
        'label': 'Send notifications via email',
        'category': 'notifications',
    })
예제 #17
0
class PlanningPublishResource(PlanningResource):
    schema = {
        'planning': Resource.rel('planning', type='string', required=True),
        'etag': {'type': 'string', 'required': True},
        'pubstatus': {
            'type': 'string',
            'required': True,
            'allowed': published_state
        },
    }

    url = 'planning/publish'
    resource_title = endpoint_name = 'planning_publish'
    resource_methods = ['POST']
    item_methods = []
class TranslateResource(Resource):
    endpoint_name = "translate"
    resource_title = endpoint_name

    schema = {
        "guid": {"type": "string", "required": True},
        "language": {"type": "string", "required": True},
        "desk": Resource.rel("desks", nullable=True),
    }

    url = "archive/translate"

    resource_methods = ["POST"]
    item_methods = []

    privileges = {"POST": "translate"}
예제 #19
0
class DictionariesResource(Resource):
    """Dictionaries schema

    """

    schema = {
        'name': {
            'type': 'string',
            'required': True
        },
        'language_id': {
            'type': 'string',
            'required': True
        },
        'content': {
            'type': 'dict',
        },
        'content_list': {
            'type': 'string',
        },
        DICTIONARY_FILE: {
            'type': 'file',
        },
        'user': Resource.rel('users', nullable=True),
        'is_active': {
            'type': 'string',
            'default': 'true',
        },
        'type': {
            'type': 'string',
            'default': DictionaryType.DICTIONARY.value,
            'allowed': DictionaryType.values()
        },
        '_file_id': {
            'type': 'objectid',
            'nullable': True,
            'readonly': True
        },
    }
    item_methods = ['GET', 'PATCH', 'PUT', 'DELETE']
    resource_methods = ['GET', 'POST', 'DELETE']
    privileges = {
        'POST': 'dictionaries',
        'PATCH': 'dictionaries',
        'DELETE': 'dictionaries'
    }
    etag_ignore_fields = ['content', 'content_list']
예제 #20
0
class AuditResource(Resource):
    endpoint_name = 'audit'
    resource_methods = ['GET']
    item_methods = ['GET']
    schema = {
        'resource': {
            'type': 'string'
        },
        'action': {
            'type': 'string'
        },
        'extra': {
            'type': 'dict'
        },
        'user': Resource.rel('users', False)
    }
    exclude = {endpoint_name, 'activity', 'dictionaries'}
예제 #21
0
class OutputChannelsResource(Resource):
    schema = {
        'name': {
            'type': 'string',
            'iunique': True,
            'required': True,
        },
        'description': {
            'type': 'string'
        },
        'format': {
            'type': 'string'
        },
        'channel_type': {
            'type': 'string'
        },
        'destinations': {
            'type': 'list',
            'schema': Resource.rel('subscribers', True)
        },
        'is_active': {
            'type': 'boolean',
            'default': True
        },
        'sequence_num_settings': {
            'type': 'dict',
            'schema': {
                'min': {
                    'type': 'integer'
                },
                'max': {
                    'type': 'integer'
                },
                'start_from': {
                    'type': 'integer'
                }
            }
        }
    }

    datasource = {'default_sort': [('_created', -1)]}
    privileges = {
        'POST': 'output_channels',
        'DELETE': 'output_channels',
        'PATCH': 'output_channels'
    }
예제 #22
0
class ArchiveHistoryResource(Resource):
    endpoint_name = 'archive_history'
    resource_methods = ['GET']
    item_methods = ['GET']
    schema = {
        'item_id': {'type': 'string'},
        'user_id': Resource.rel('users', True),
        'operation': {'type': 'string'},
        'update': {'type': 'dict', 'nullable': True},
        'version': {'type': 'integer'},
        'original_item_id': {'type': 'string'}
    }

    mongo_indexes = {
        'item_id': ([('item_id', 1)], {'background': True}),
        '_id_document': ([('_id_document', 1)], {'background': True}),
    }
예제 #23
0
class AutoSaveResource(Resource):
    endpoint_name = 'archive_autosave'
    item_url = item_url
    schema = {
        '_id': {
            'type': 'string'
        },
        'destination_groups': {
            'type': 'list',
            'schema': Resource.rel('destination_groups', True)
        }
    }
    schema.update(metadata_schema)
    resource_methods = ['POST']
    item_methods = ['GET', 'PUT', 'PATCH']
    resource_title = endpoint_name
    privileges = {'POST': 'archive', 'PATCH': 'archive', 'PUT': 'archive'}
예제 #24
0
파일: items.py 프로젝트: darconny/liveblog
class ItemsResource(ArchiveResource):
    datasource = {
        'source': 'archive',
        'elastic_filter': {
            'term': {
                'particular_type': 'item'
            }
        },
        'default_sort': [('_updated', -1)]
    }

    item_methods = ['GET', 'PATCH', 'PUT', 'DELETE']

    schema = ArchiveResource.schema
    schema.update(schema)
    schema.update({
        'text': {
            'type': 'string'
        },
        'blog': Resource.rel('blogs', True),
        'particular_type': {
            'type': 'string',
            'allowed': ['post', 'item'],
            'default': 'item'
        },
        'item_type': {
            'type': 'string'
        },
        'meta': {
            'type': 'dict'
        },
        'deleted': {
            'type': 'string'
        },
        'commenter': {
            'type': 'string',
            'minlength': 1,
            'maxlength': 30
        }
    })
    privileges = {
        'GET': 'posts',
        'POST': 'posts',
        'PATCH': 'posts',
        'DELETE': 'posts'
    }
예제 #25
0
class XMPPAuthResource(Resource):
    schema = {
        'jid': {
            'type': 'string',
            'required': True
        },
        'transactionId': {
            'type': 'string',
            'required': True
        },
        'token': {
            'type': 'string'
        },
        'user': Resource.rel('users', True)
    }
    resource_methods = ['POST']
    public_methods = ['POST']
    extra_response_fields = ['user', 'token', 'username']
예제 #26
0
class XMPPAuthResource(Resource):
    schema = {
        "jid": {
            "type": "string",
            "required": True
        },
        "transactionId": {
            "type": "string",
            "required": True
        },
        "token": {
            "type": "string"
        },
        "user": Resource.rel("users", True),
    }
    resource_methods = ["POST"]
    public_methods = ["POST"]
    extra_response_fields = ["user", "token", "username"]
예제 #27
0
class EventsPublishResource(EventsResource):
    schema = {
        'event': Resource.rel('events', type='string', required=True),
        'etag': {
            'type': 'string',
            'required': True
        },
        'pubstatus': {
            'type': 'string',
            'required': True,
            'allowed': published_state
        },
    }

    url = 'events/publish'
    resource_title = endpoint_name = 'events_publish'
    resource_methods = ['POST']
    item_methods = []
예제 #28
0
class ProductsResource(Resource):
    """Products schema"""

    schema = {
        'name': {
            'type': 'string',
            'iunique': True,
            'required': True
        },
        'description': {
            'type': 'string'
        },
        'codes': {
            'type': 'string'
        },
        'content_filter': {
            'type': 'dict',
            'schema': {
                'filter_id': Resource.rel('content_filters', nullable=True),
                'filter_type': {
                    'type': 'string',
                    'allowed': ['blocking', 'permitting'],
                    'default': 'blocking'
                }
            },
            'nullable': True
        },
        'geo_restrictions': {
            'type': 'string',
            'nullable': True
        },
        'product_type': {
            'type': 'string',
            'default': ProductTypes.BOTH.value,
            'allowed': ProductTypes.values(),
            'required': True
        }
    }

    privileges = {
        'POST': 'products',
        'PATCH': 'products',
        'DELETE': 'products'
    }
예제 #29
0
class AuthResource(Resource):
    schema = {
        'username': {
            'type': 'string',
            'required': True
        },
        'password': {
            'type': 'string',
            'required': True
        },
        'token': {
            'type': 'string'
        },
        'user': Resource.rel('users', True)
    }
    resource_methods = ['POST']
    item_methods = ['GET', 'DELETE']
    public_methods = ['POST', 'DELETE']
    extra_response_fields = ['user', 'token', 'username']
예제 #30
0
class HighlightsResource(Resource):
    '''
    Highlights schema
    '''
    schema = {
        'name': {
            'type': 'string',
            'required': True
        },
        'desks': {
            'type': 'list',
            'schema': Resource.rel('desks', True)
        }
    }
    privileges = {
        'POST': 'highlights',
        'PATCH': 'highlights',
        'DELETE': 'highlights'
    }
예제 #31
0
class FormattedItemResource(Resource):
    schema = {
        'item_id': Resource.rel('archive', type='string'),
        'item_version': {
            'type': 'string',
            'nullable': False,
        },
        'formatted_item': {
            'type': 'string',
            'nullable': False,
        },
        'format': {
            'type': 'string',
            'nullable': False,
        }
    }

    datasource = {'default_sort': [('_created', -1)]}
    privileges = {'POST': 'publish_queue', 'PATCH': 'publish_queue'}
예제 #32
0
class PlanningPostResource(PlanningResource):
    schema = {
        'planning': Resource.rel('planning', type='string', required=True),
        'etag': {
            'type': 'string',
            'required': True
        },
        'pubstatus': {
            'type': 'string',
            'required': True,
            'allowed': post_state
        },
    }

    url = 'planning/post'
    resource_title = endpoint_name = 'planning_post'
    resource_methods = ['POST']
    privileges = {'POST': 'planning_planning_post'}
    item_methods = []
예제 #33
0
class EventsPostResource(EventsResource):
    schema = {
        'event': Resource.rel('events', type='string', required=True),
        'etag': {'type': 'string', 'required': True},
        'pubstatus': {'type': 'string', 'required': True, 'allowed': post_state},

        # The update method used for recurring events
        'update_method': {
            'type': 'string',
            'allowed': UPDATE_METHODS,
            'mapping': not_analyzed,
            'nullable': True
        },
    }

    url = 'events/post'
    resource_title = endpoint_name = 'events_post'
    resource_methods = ['POST']
    privileges = {'POST': 'planning_event_post'}
    item_methods = []
예제 #34
0
import superdesk
from superdesk.resource import Resource
from superdesk.notification import push_notification
from apps.activity import add_activity
from superdesk.services import BaseService


comments_schema = {
    'text': {
        'type': 'string',
        'minlength': 1,
        'maxlength': 500,
        'required': True,
    },
    'item': Resource.rel('archive', True, True, type='string'),
    'user': Resource.rel('users', True),
    'mentioned_users': {
        'type': 'dict'
    }
}


def check_item_valid(item_id):
    item = app.data.find_one('archive', req=None, _id=item_id)
    if not item:
        msg = 'Invalid content item ID provided: %s' % item_id
        raise superdesk.SuperdeskError(payload=msg)


def get_users_mentions(text):
예제 #35
0
파일: desks.py 프로젝트: copyfun/superdesk
import superdesk
from superdesk.notification import push_notification
from superdesk.activity import add_activity, ACTIVITY_UPDATE
from superdesk.metadata.item import FAMILY_ID
from eve.utils import ParsedRequest


class DeskTypes(SuperdeskBaseEnum):
    authoring = "authoring"
    production = "production"


desks_schema = {
    "name": {"type": "string", "required": True, "nullable": False, "empty": False, "iunique": True},
    "description": {"type": "string"},
    "members": {"type": "list", "schema": {"type": "dict", "schema": {"user": Resource.rel("users", True)}}},
    "incoming_stage": Resource.rel("stages", True),
    "working_stage": Resource.rel("stages", True),
    "content_expiry": {"type": "integer"},
    "source": {"type": "string"},
    "monitoring_settings": {
        "type": "list",
        "schema": {
            "type": "dict",
            "schema": {
                "_id": {"type": "string", "required": True},
                "type": {"type": "string", "allowed": ["search", "stage", "deskOutput", "personal"], "required": True},
                "max_items": {"type": "integer", "required": True},
            },
        },
    },
예제 #36
0
import superdesk
from superdesk.users.services import is_admin
from superdesk.errors import SuperdeskApiError
import logging


logger = logging.getLogger('superdesk')

blogs_schema = {
    'title': metadata_schema['headline'],
    'description': metadata_schema['description'],
    'picture_url': {
        'type': 'string',
        'nullable': True
    },
    'picture': Resource.rel('archive', embeddable=True, nullable=True, type='string'),
    'original_creator': metadata_schema['original_creator'],
    'version_creator': metadata_schema['version_creator'],
    'versioncreated': metadata_schema['versioncreated'],
    'posts_order_sequence': {
        'type': 'number',
        'default': 0
    },
    'blog_status': {
        'type': 'string',
        'allowed': ['open', 'closed'],
        'default': 'open'
    },
    'members': {
        'type': 'list',
        'schema': {
예제 #37
0
desks_schema = {
    'name': {
        'type': 'string',
        'iunique': True,
        'required': True,
    },
    'description': {
        'type': 'string'
    },
    'members': {
        'type': 'list',
        'schema': {
            'type': 'dict',
            'schema': {
                'user': Resource.rel('users', True)
            }
        }
    },
    'incoming_stage': Resource.rel('stages', True),
    'published_stage': Resource.rel('stages', False),
    'spike_expiry': {
        'type': 'integer'
    }
}


def init_app(app):
    endpoint_name = 'desks'
    service = DesksService(endpoint_name, backend=superdesk.get_backend())
    DesksResource(endpoint_name, app=app, service=service)
예제 #38
0
        'mapping': not_analyzed
    },
    'version': {
        'type': 'integer'
    },
    'ingest_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'family_id': {
        'type': 'string',
        'mapping': not_analyzed
    },

    # Audit Information
    'original_creator': Resource.rel('users'),
    'version_creator': Resource.rel('users'),
    'firstcreated': {
        'type': 'datetime'
    },
    'versioncreated': {
        'type': 'datetime'
    },

    # Ingest Details
    'ingest_provider': Resource.rel('ingest_providers'),
    'source': {     # The value is copied from the ingest_providers vocabulary
        'type': 'string',
        'mapping': not_analyzed
    },
    'original_source': {    # This value is extracted from the ingest
예제 #39
0
파일: blogs.py 프로젝트: cbenhagen/liveblog
from superdesk.emails import send_email
import liveblog.embed
from bson.objectid import ObjectId
import superdesk
from superdesk.users.services import is_admin
from superdesk.errors import SuperdeskApiError
import logging


logger = logging.getLogger("superdesk")

blogs_schema = {
    "title": metadata_schema["headline"],
    "description": metadata_schema["description"],
    "picture_url": {"type": "string", "nullable": True},
    "picture": Resource.rel("archive", embeddable=True, nullable=True, type="string"),
    "original_creator": metadata_schema["original_creator"],
    "version_creator": metadata_schema["version_creator"],
    "versioncreated": metadata_schema["versioncreated"],
    "posts_order_sequence": {"type": "number", "default": 0},
    "blog_status": {"type": "string", "allowed": ["open", "closed"], "default": "open"},
    "members": {"type": "list", "schema": {"type": "dict", "schema": {"user": Resource.rel("users", True)}}},
    "blog_preferences": {"type": "dict"},
    "public_url": {"type": "string"},
}


class BlogsResource(Resource):
    datasource = {"source": "blogs", "search_backend": "elastic", "default_sort": [("_updated", -1)]}

    item_methods = ["GET", "PATCH", "PUT", "DELETE"]
    def __init__(self, endpoint_name, app, service, endpoint_schema=None):
        self.schema = {
            'name': {
                'type': 'string',
                'required': True,
                'nullable': False,
                'empty': False,
                'iunique': True
            },
            'source': required_string,
            'feeding_service': {
                'type': 'string',
                'required': True,
                'allowed': allowed_feeding_services
            },
            'feed_parser': {
                'type': 'string',
                'nullable': True,
                'allowed': allowed_feed_parsers
            },
            'content_types': {
                'type': 'list',
                'default': content_type,
                'allowed': content_type
            },
            'allow_remove_ingested': {
                'type': 'boolean',
                'default': False
            },
            'content_expiry': {
                'type': 'integer',
                'default': app.config['INGEST_EXPIRY_MINUTES']
            },
            'config': {
                'type': 'dict'
            },
            'ingested_count': {
                'type': 'integer'
            },
            'accepted_count': {
                'type': 'integer'
            },
            'tokens': {
                'type': 'dict'
            },
            'is_closed': {
                'type': 'boolean',
                'default': False
            },
            'update_schedule': {
                'type': 'dict',
                'schema': {
                    'hours': {'type': 'integer'},
                    'minutes': {'type': 'integer', 'default': 5},
                    'seconds': {'type': 'integer'},
                }
            },
            'idle_time': {
                'type': 'dict',
                'schema': {
                    'hours': {'type': 'integer'},
                    'minutes': {'type': 'integer'},
                }
            },
            'last_updated': {'type': 'datetime'},
            'last_ingested_id': {'type': 'string'},  # this id is ingest provider internal value
            'last_item_update': {'type': 'datetime'},
            'rule_set': Resource.rel('rule_sets', nullable=True),
            'routing_scheme': Resource.rel('routing_schemes', nullable=True),
            'notifications': {
                'type': 'dict',
                'schema': {
                    'on_update': {'type': 'boolean', 'default': True},
                    'on_close': {'type': 'boolean', 'default': True},
                    'on_open': {'type': 'boolean', 'default': True},
                    'on_error': {'type': 'boolean', 'default': True}
                }
            },
            'last_closed': {
                'type': 'dict',
                'schema': {
                    'closed_at': {'type': 'datetime'},
                    'closed_by': Resource.rel('users', nullable=True),
                    'message': {'type': 'string'}
                }
            },
            'last_opened': {
                'type': 'dict',
                'schema': {
                    'opened_at': {'type': 'datetime'},
                    'opened_by': Resource.rel('users', nullable=True)
                }
            },
            'critical_errors': {
                'type': 'dict',
                'valueschema': {
                    'type': 'boolean'
                }
            },
        }

        self.item_methods = ['GET', 'PATCH', 'DELETE']
        self.privileges = {'POST': 'ingest_providers', 'PATCH': 'ingest_providers', 'DELETE': 'ingest_providers'}
        self.etag_ignore_fields = ['last_updated', 'last_item_update', 'last_closed', 'last_opened']

        super().__init__(endpoint_name, app, service, endpoint_schema=endpoint_schema)
예제 #41
0
#
# Copyright 2013, 2014 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 superdesk
from superdesk.resource import Resource
from superdesk.services import BaseService
from apps.comments import CommentsService, CommentsResource, comments_schema
from superdesk.errors import SuperdeskApiError


comments_schema = dict(comments_schema)
comments_schema.update({'item': Resource.rel('archive', True, True, type='string')})


class ItemCommentsResource(CommentsResource):
    schema = comments_schema
    resource_methods = ['GET', 'POST', 'DELETE']
    datasource = {'default_sort': [('_created', -1)]}
    privileges = {'POST': 'archive', 'DELETE': 'archive'}


class ItemCommentsService(CommentsService):
    notification_key = 'item:comment'


class ItemCommentsSubResource(Resource):
    url = 'archive/<path:item>/comments'
예제 #42
0
    },
    'ingest_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'family_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'related_to': {  # this field keeps a reference to the related item from which metadata has been copied
        'type': 'string',
        'mapping': not_analyzed
    },

    # Audit Information
    'original_creator': Resource.rel('users'),
    'version_creator': Resource.rel('users'),
    'firstcreated': {
        'type': 'datetime'
    },
    'versioncreated': {
        'type': 'datetime'
    },
    'firstpublished': {
        'type': 'datetime',
        'required': False,
        'nullable': True,
    },

    # Ingest Details
    'ingest_provider': Resource.rel('ingest_providers'),
예제 #43
0
    def __init__(self, endpoint_name, app, service, endpoint_schema=None):
        self.readonly = True if app.config.get('LDAP_SERVER', None) else False

        self.additional_lookup = {
            'url': r'regex("[\w]+")',
            'field': 'username'
        }

        self.schema = {
            'username': {
                'type': 'string',
                'unique': True,
                'required': True,
                'minlength': 1
            },
            'password': {
                'type': 'string',
                'minlength': 5
            },
            'password_changed_on': {
                'type': 'datetime',
                'nullable': True
            },
            'first_name': {
                'type': 'string',
                'readonly': self.readonly
            },
            'last_name': {
                'type': 'string',
                'readonly': self.readonly
            },
            'display_name': {
                'type': 'string'
            },
            'email': {
                'unique': True,
                'type': 'email',
                'required': True,
                'coerce': lambda s: s.lower()
            },
            'phone': {
                'type': 'string',
                'nullable': True
            },
            'job_title': {
                'type': 'string',
                'required': False,
            },
            'biography': {
                'type': 'string',
                'required': False,
                'nullable': True,
            },
            'facebook': {
                'type': 'string',
                'required': False,
                'nullable': True,
            },
            'instagram': {
                'type': 'string',
                'required': False,
                'nullable': True,
            },
            'twitter': {
                'type': 'string',
                'required': False,
                'nullable': True,
                'twitter': True,
            },
            'jid': {
                'unique': True,
                'type': 'string',
                'required': False,
            },
            'language': {
                'type': 'string',
                'nullable': True
            },
            'user_info': {
                'type': 'dict'
            },
            'picture_url': {
                'type': 'string',
                'nullable': True
            },
            'avatar': Resource.rel('upload', embeddable=True, nullable=True),
            'avatar_renditions': {'type': 'dict'},
            'role': Resource.rel('roles', True),
            'privileges': {'type': 'dict'},
            'workspace': {
                'type': 'dict'
            },
            'user_type': {
                'type': 'string',
                'allowed': ['user', 'administrator'],
                'default': 'user'
            },
            'is_support': {
                'type': 'boolean',
                'default': False
            },
            'is_author': {
                'type': 'boolean',
                'default': True
            },
            'is_active': {
                'type': 'boolean',
                'default': True
            },
            'is_enabled': {
                'type': 'boolean',
                'default': True
            },
            'needs_activation': {
                'type': 'boolean',
                'default': True
            },
            # Default desk of the user, which would be selected when logged-in.
            'desk': Resource.rel('desks', nullable=True),
            SIGN_OFF: {  # Used for putting a sign-off on the content when it's created/updated except kill
                'type': 'string',
                'required': False,
                'nullable': True,
                'regex': '^[a-zA-Z0-9]+$'
            },
            BYLINE: {
                'type': 'string',
                'required': False,
                'nullable': True
            },
            # list to hold invisible stages.
            # This field is updated under following scenario:
            # 1. stage visible flag is updated
            # 2. desk membership is modified
            # 3. new user is created
            'invisible_stages': {
                'type': 'list',
                'required': False,
                'nullable': True
            },
            # If Slack notifications are configured and enabled for the user
            # the Slack username is stored here.
            'slack_username': {
                'type': 'string',
                'required': False,
                'nullable': True
            },
            # The Slack user id is stored here, to avoid repeatedly having to look it up
            'slack_user_id': {
                'type': 'string',
                'required': False,
                'nullable': True
            }
        }

        self.extra_response_fields = [
            'display_name',
            'username',
            'email',
            'user_info',
            'picture_url',
            'avatar',
            'is_active',
            'is_enabled',
            'needs_activation',
            'desk'
        ]

        self.etag_ignore_fields = ['session_preferences', '_etag', 'invisible_stages']

        self.datasource = {
            'projection': {'password': 0},
            'default_sort': [('username', 1)],
        }

        self.mongo_indexes = {
            'username_1': ([('username', 1)], {'unique': True}),
            'first_name_1_last_name_-1': [('first_name', 1), ('last_name', -1)],
        }

        self.privileges = {'POST': 'users', 'DELETE': 'users', 'PATCH': 'users'}
        super().__init__(endpoint_name, app=app, service=service, endpoint_schema=endpoint_schema)
예제 #44
0
from superdesk.services import BaseService
from superdesk.notification import push_notification
from superdesk.activity import add_activity, ACTIVITY_UPDATE
from superdesk.metadata.item import FAMILY_ID
from eve.utils import ParsedRequest


class DeskTypes(SuperdeskBaseEnum):
    authoring = "authoring"
    production = "production"


desks_schema = {
    "name": {"type": "string", "required": True, "nullable": False, "empty": False, "iunique": True},
    "description": {"type": "string"},
    "members": {"type": "list", "schema": {"type": "dict", "schema": {"user": Resource.rel("users", True)}}},
    "incoming_stage": Resource.rel("stages", True),
    "working_stage": Resource.rel("stages", True),
    "content_expiry": {"type": "integer"},
    "source": {"type": "string"},
    "monitoring_settings": {
        "type": "list",
        "schema": {
            "type": "dict",
            "schema": {
                "_id": {"type": "string", "required": True},
                "type": {
                    "type": "string",
                    "allowed": ["search", "stage", "scheduledDeskOutput", "deskOutput", "personal"],
                    "required": True,
                },
예제 #45
0
파일: blogs.py 프로젝트: catalyst/liveblog
from bson.objectid import ObjectId
import flask
import superdesk
import eve.io.base

blogs_schema = {
    'guid': metadata_schema['guid'],
    'title': metadata_schema['headline'],
    'description': metadata_schema['description'],
    'theme': {
        'type': 'dict'
    },
    'picture_url': {
        'type': 'string',
    },
    'picture': Resource.rel('upload', True),
    'original_creator': metadata_schema['original_creator'],
    'version_creator': metadata_schema['version_creator'],
    'versioncreated': metadata_schema['versioncreated'],
    'blog_status': {
        'type': 'string',
        'allowed': ['open', 'closed'],
        'default': 'open'
    },
    'particular_type': {
        'type': 'string',
        'allowed': ['blog'],
        'default': 'blog'
    },
    'members': {
        'type': 'list',
예제 #46
0
blogs_schema = {
    'title': {
        'type': 'string',
        'required': True,
    },
    'description': {
        'type': 'string'
    },
    'language': {
        'type': 'string'
    },
    'settings': {
        'type': 'dict'
    },
    'original_creator': Resource.rel('users', True),
    'version_creator': Resource.rel('users', True),
    'state': {
        'type': 'string',
        'allowed': ['open', 'closed'],
        'default': 'open'
    }
}


class BlogsResource(Resource):
    schema = blogs_schema
    datasource = {
        'default_sort': [('_updated', -1)]
    }
예제 #47
0
    },
    'ingest_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'family_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'related_to': {  # this field keeps a reference to the related item from which metadata has been copied
        'type': 'string',
        'mapping': not_analyzed
    },

    # Audit Information
    'original_creator': Resource.rel('users'),
    'version_creator': Resource.rel('users'),
    'firstcreated': {
        'type': 'datetime'
    },
    'versioncreated': {
        'type': 'datetime'
    },

    # Ingest Details
    'ingest_provider': Resource.rel('ingest_providers'),
    'source': {     # The value is copied from the ingest_providers vocabulary
        'type': 'string',
        'mapping': not_analyzed
    },
    'original_source': {    # This value is extracted from the ingest
예제 #48
0
    'unique_name': {
        'type': 'string',
        'unique': True,
        'mapping': not_analyzed
    },
    'parent_id': {
        'type': 'string',
        'unique': True,
        'mapping': not_analyzed
    },
    'version': {
        'type': 'integer'
    },

    # Audit Information
    'original_creator': Resource.rel('users'),
    'version_creator': Resource.rel('users'),
    'firstcreated': {
        'type': 'datetime'
    },
    'versioncreated': {
        'type': 'datetime'
    },

    # Ingest Details
    'ingest_provider': Resource.rel('ingest_providers'),
    'source': {     # The value is copied from the ingest_providers vocabulary
        'type': 'string',
        'mapping': not_analyzed
    },
    'original_source': {    # This value is extracted from the ingest
예제 #49
0
    },
    'ingest_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'family_id': {
        'type': 'string',
        'mapping': not_analyzed
    },
    'related_to': {  # this field keeps a reference to the related item from which metadata has been copied
        'type': 'string',
        'mapping': not_analyzed
    },

    # Audit Information
    'original_creator': Resource.rel('users'),
    'version_creator': Resource.rel('users'),
    'firstcreated': {
        'type': 'datetime'
    },
    'versioncreated': {
        'type': 'datetime'
    },

    # Ingest Details
    'ingest_provider': Resource.rel('ingest_providers'),
    'source': {     # The value is copied from the ingest_providers vocabulary
        'type': 'string',
        'mapping': not_analyzed
    },
    'original_source': {    # This value is extracted from the ingest
예제 #50
0
    def __init__(self, endpoint_name, app, service, endpoint_schema=None):
        self.readonly = True if app.config.get('LDAP_SERVER', None) else False

        self.additional_lookup = {
            'url': 'regex("[\w]+")',
            'field': 'username'
        }

        self.schema = {
            'username': {
                'type': 'string',
                'unique': True,
                'required': True,
                'minlength': 1
            },
            'password': {
                'type': 'string',
                'minlength': 5
            },
            'first_name': {
                'type': 'string',
                'readonly': self.readonly
            },
            'last_name': {
                'type': 'string',
                'readonly': self.readonly
            },
            'display_name': {
                'type': 'string'
            },
            'email': {
                'unique': True,
                'type': 'email',
                'required': True
            },
            'phone': {
                'type': 'string',
                'nullable': True
            },
            'language': {
                'type': 'string',
                'nullable': True
            },
            'user_info': {
                'type': 'dict'
            },
            'picture_url': {
                'type': 'string',
                'nullable': True
            },
            'avatar': Resource.rel('upload', embeddable=True, nullable=True),
            'role': Resource.rel('roles', True),
            'privileges': {'type': 'dict'},
            'workspace': {
                'type': 'dict'
            },
            'user_type': {
                'type': 'string',
                'allowed': ['user', 'administrator'],
                'default': 'user'
            },
            'is_active': {
                'type': 'boolean',
                'default': True
            },
            'is_enabled': {
                'type': 'boolean',
                'default': True
            },
            'needs_activation': {
                'type': 'boolean',
                'default': True
            },
            'desk': Resource.rel('desks'),  # Default desk of the user, which would be selected when logged-in.
            SIGN_OFF: {  # Used for putting a sign-off on the content when it's created/updated except kill
                'type': 'string',
                'required': False,
                'regex': '^[a-zA-Z0-9]+$'
            },
            BYLINE: {
                'type': 'string',
                'required': False,
                'nullable': True
            }
        }

        self.extra_response_fields = [
            'display_name',
            'username',
            'email',
            'user_info',
            'picture_url',
            'avatar',
            'is_active',
            'is_enabled',
            'needs_activation',
            'desk'
        ]

        self.etag_ignore_fields = ['session_preferences', '_etag']

        self.datasource = {
            'projection': {'password': 0},
            'default_sort': [('username', 1)],
        }

        self.privileges = {'POST': 'users', 'DELETE': 'users', 'PATCH': 'users'}
        super().__init__(endpoint_name, app=app, service=service, endpoint_schema=endpoint_schema)
예제 #51
0
 'name': {
     'type': 'string',
     'required': True,
     'nullable': False,
     'empty': False,
     'iunique': True
 },
 'description': {
     'type': 'string'
 },
 'members': {
     'type': 'list',
     'schema': {
         'type': 'dict',
         'schema': {
             'user': Resource.rel('users', True)
         }
     }
 },
 'incoming_stage': Resource.rel('stages', True),
 'working_stage': Resource.rel('stages', True),
 'content_expiry': {
     'type': 'integer'
 },
 'source': {
     'type': 'string'
 },
 'monitoring_settings': {
     'type': 'list',
     'schema': {
         'type': 'dict',
예제 #52
0
파일: blogs.py 프로젝트: hlmnrmr/liveblog
import flask
import superdesk
import eve.io.base

blogs_schema = {
    'guid': metadata_schema['guid'],
    'title': metadata_schema['headline'],
    'description': metadata_schema['description'],
    'theme': {
        'type': 'dict'
    },
    'picture_url': {
        'type': 'string',
        'nullable': True
    },
    'picture': Resource.rel('upload', embeddable=True, nullable=True),
    'original_creator': metadata_schema['original_creator'],
    'version_creator': metadata_schema['version_creator'],
    'versioncreated': metadata_schema['versioncreated'],
    'blog_status': {
        'type': 'string',
        'allowed': ['open', 'closed'],
        'default': 'open'
    },
    'particular_type': {
        'type': 'string',
        'allowed': ['blog'],
        'default': 'blog'
    },
    'members': {
        'type': 'list',
예제 #53
0
 'name': {
     'type': 'string',
     'required': True,
     'nullable': False,
     'empty': False,
     'iunique': True
 },
 'description': {
     'type': 'string'
 },
 'members': {
     'type': 'list',
     'schema': {
         'type': 'dict',
         'schema': {
             'user': Resource.rel('users', True)
         }
     }
 },
 'incoming_stage': Resource.rel('stages', True),
 'working_stage': Resource.rel('stages', True),
 'content_expiry': {
     'type': 'integer'
 },
 'source': {
     'type': 'string'
 },
 'monitoring_settings': {
     'type': 'list',
     'schema': {
         'type': 'dict',
예제 #54
0
        username = g.user.get('display_name') or g.user.get('username')
        url = '{}/#/liveblog/settings/{}'.format(origin, doc['_id'])
        title = blog['title']
        admins = app.config['ADMINS']
        app_name = app.config['APPLICATION_NAME']
        subject = render_template("owner_email_subject.txt", app_name=app_name)
        text_body = render_template("owner_request.txt", app_name=app_name, link=url,
                                    name_of_user=username, title=title)
        html_body = render_template("owner_request.html", app_name=app_name, link=url,
                                    name_of_user=username, title=title)
        send_email.delay(subject=subject, sender=admins[0], recipients=recipients,
                         text_body=text_body, html_body=html_body)


request_schema = {
    'blog': Resource.rel('blogs', True),
    'original_creator': Resource.rel('users', True),
    'message': {
        'type': 'string'
    }
}


class MembershipResource(Resource):
    schema = request_schema
    datasource = {
        'source': 'request_membership',
        'default_sort': [('_updated', -1)]
    }
    resource_methods = ['POST', 'GET']
    item_methods = ['GET', 'DELETE']
예제 #55
0
EMBARGO = "embargo"

metadata_schema = {
    # Identifiers
    "guid": {"type": "string", "unique": True, "mapping": not_analyzed},
    "unique_id": {"type": "integer", "unique": True},
    "unique_name": {"type": "string", "unique": True, "mapping": not_analyzed},
    "version": {"type": "integer"},
    "ingest_id": {"type": "string", "mapping": not_analyzed},
    "family_id": {"type": "string", "mapping": not_analyzed},
    "related_to": {  # this field keeps a reference to the related item from which metadata has been copied
        "type": "string",
        "mapping": not_analyzed,
    },
    # Audit Information
    "original_creator": Resource.rel("users"),
    "version_creator": Resource.rel("users"),
    "firstcreated": {"type": "datetime"},
    "versioncreated": {"type": "datetime"},
    # Ingest Details
    "ingest_provider": Resource.rel("ingest_providers"),
    "source": {"type": "string", "mapping": not_analyzed},  # The value is copied from the ingest_providers vocabulary
    "original_source": {"type": "string", "mapping": not_analyzed},  # This value is extracted from the ingest
    "ingest_provider_sequence": {"type": "string", "mapping": not_analyzed},
    # Copyright Information
    "usageterms": {"type": "string", "mapping": not_analyzed, "nullable": True},
    # Category Details
    "anpa_category": {
        "type": "list",
        "nullable": True,
        "mapping": {"type": "object", "properties": {"qcode": not_analyzed, "name": not_analyzed}},
예제 #56
0
 'urgency': {
     'type': 'integer'
 },
 'groups': {
     'type': 'list'
 },
 'keywords': {
     'type': 'list'
 },
 'body_html': {
     'type': 'string'
 },
 'creator': {
     'type': 'dict',
     'schema': {
         'user': Resource.rel('users', True)
     }
 },
 'media_file': {
     'type': 'string'
 },
 'contents': {
     'type': 'list'
 },
 'media': {
     'type': 'media'
 },
 'task_id': {
     'type': 'string'
 },
 'lock_user': {