当前位置: 首页>>代码示例>>Python>>正文


Python Resource.rel方法代码示例

本文整理汇总了Python中superdesk.resource.Resource.rel方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.rel方法的具体用法?Python Resource.rel怎么用?Python Resource.rel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在superdesk.resource.Resource的用法示例。


在下文中一共展示了Resource.rel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    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)
开发者ID:liveblog,项目名称:superdesk-core,代码行数:58,代码来源:ingest_provider_model.py

示例2: __init__

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    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)
开发者ID:copyfun,项目名称:superdesk-core,代码行数:54,代码来源:users.py

示例3: item_schema

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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
开发者ID:jey07ro,项目名称:superdesk,代码行数:32,代码来源:common.py

示例4: dict

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
#
# 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'
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:33,代码来源:item_comments.py

示例5:

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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': {
开发者ID:4D4M-W34V3R,项目名称:liveblog,代码行数:33,代码来源:blogs.py

示例6: __init__

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    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'
                }
            },
        }
#.........这里部分代码省略.........
开发者ID:nistormihai,项目名称:superdesk-core,代码行数:103,代码来源:ingest_provider_model.py

示例7: __init__

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    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
#.........这里部分代码省略.........
开发者ID:jerome-poisson,项目名称:superdesk-core,代码行数:103,代码来源:users.py

示例8: check_item_valid

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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):
开发者ID:chupym,项目名称:superdesk-server,代码行数:32,代码来源:item_comments.py

示例9: BlogsResource

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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)]
    }
开发者ID:nistormihai,项目名称:liveblog-server,代码行数:31,代码来源:blogs.py

示例10:

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    },
    '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'),
开发者ID:jerome-poisson,项目名称:superdesk-core,代码行数:33,代码来源:item.py

示例11: DeskTypes

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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,
                },
开发者ID:liveblog,项目名称:superdesk-core,代码行数:33,代码来源:desks.py

示例12:

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
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',
开发者ID:hlmnrmr,项目名称:liveblog,代码行数:33,代码来源:blogs.py

示例13: __init__

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    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']
#.........这里部分代码省略.........
开发者ID:MiczFlor,项目名称:superdesk-core,代码行数:103,代码来源:users.py

示例14:

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
    },
    '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
开发者ID:verifiedpixel,项目名称:verifiedpixel,代码行数:33,代码来源:item.py

示例15:

# 需要导入模块: from superdesk.resource import Resource [as 别名]
# 或者: from superdesk.resource.Resource import rel [as 别名]
 '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',
开发者ID:sjunaid,项目名称:superdesk-core,代码行数:33,代码来源:desks.py


注:本文中的superdesk.resource.Resource.rel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。