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


Python restplus.Namespace类代码示例

本文整理汇总了Python中flask.ext.restplus.Namespace的典型用法代码示例。如果您正苦于以下问题:Python Namespace类的具体用法?Python Namespace怎么用?Python Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Namespace

import json
from flask.ext.restplus import Resource, Namespace
from flask_jwt import JWTError

from .helpers.errors import NotAuthorizedError
from .helpers import custom_fields as fields

api = Namespace('login', description='Login')

LOGIN = api.model('Login', {
    'email': fields.Email(required=True),
    'password': fields.String(required=True)
})

TOKEN = api.model('Token', {
    'access_token': fields.String()
})


@api.route('')
class Login(Resource):
    @api.doc('get_token')
    @api.expect(LOGIN)
    @api.marshal_with(TOKEN)
    @api.response(401, 'Authentication Failed')
    def post(self):
        from .. import jwt
        try:
            response = jwt.auth_request_callback()
            return json.loads(response.data)
        except JWTError as e:
开发者ID:agwisniewska,项目名称:open-event-orga-server,代码行数:31,代码来源:login.py

示例2: Namespace

import os

from flask import send_file, make_response, jsonify, url_for, current_app
from flask.ext.restplus import Resource, Namespace, marshal

from app.helpers.data import record_activity
from helpers import custom_fields as fields
from helpers.export_helpers import export_event_json, create_export_job, send_export_mail
from helpers.helpers import nocache, can_access, requires_auth, replace_event_id
from helpers.utils import TASK_RESULTS

api = Namespace('exports', description='Exports', path='/')

EXPORT_SETTING = api.model('ExportSetting', {
    'image': fields.Boolean(default=False),
    'video': fields.Boolean(default=False),
    'document': fields.Boolean(default=False),
    'audio': fields.Boolean(default=False)
})


@nocache
@api.route('/events/<string:event_id>/export/json')
@api.hide
class EventExportJson(Resource):
    @requires_auth
    @replace_event_id
    @can_access
    @api.expect(EXPORT_SETTING)
    def post(self, event_id):
        from helpers.tasks import export_event_task
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:31,代码来源:exports.py

示例3: import

from flask.ext.restplus import Namespace

from app.models.microlocation import Microlocation as MicrolocationModel
from .helpers import custom_fields as fields
from .helpers.helpers import (
    can_create,
    can_update,
    can_delete,
    requires_auth
)
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES
from .helpers.utils import Resource, ETAG_HEADER_DEFN

api = Namespace('microlocations', description='Microlocations', path='/')

MICROLOCATION = api.model('Microlocation', {
    'id': fields.Integer(required=True),
    'name': fields.String(required=True),
    'latitude': fields.Float(),
    'longitude': fields.Float(),
    'floor': fields.Integer(),
    'room': fields.String(),
})

MICROLOCATION_PAGINATED = api.clone('MicrolocationPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(MICROLOCATION))
})

MICROLOCATION_POST = api.clone('MicrolocationPost', MICROLOCATION)
del MICROLOCATION_POST['id']
开发者ID:aviaryan,项目名称:open-event-orga-server,代码行数:31,代码来源:microlocations.py

示例4: Namespace

from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('events', description='Events')

EVENT = api.model('Event', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'email': fields.String,
    'color': fields.String,
    'logo': fields.String,
    'start_time': fields.DateTime,
    'end_time': fields.DateTime,
    'latitude': fields.Float,
    'longitude': fields.Float,
    'slogan': fields.String,
    'url': fields.String,
    'location_name': fields.String,
})

EVENT_PAGINATED = api.clone('EventPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(EVENT))
})


@api.route('/<int:event_id>')
@api.param('event_id')
@api.response(404, 'Event not found')
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:31,代码来源:events.py

示例5: Namespace

from flask.ext.restplus import Resource, Namespace

from app.api.events import EVENT
from app.models.role import Role
from app.models.user import User as UserModel, ATTENDEE
from app.models.user_detail import UserDetail as UserDetailModel
from app.helpers.data import DataManager, record_activity
from app.helpers.data_getter import DataGetter
from app.models.users_events_roles import UsersEventsRoles

from .helpers.helpers import requires_auth, can_access_account, staff_only
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, BaseDAO, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES
from .helpers import custom_fields as fields

api = Namespace('users', description='Users', path='/')


USER_DETAIL = api.model('UserDetail', {
    'firstname': fields.String(),
    'lastname': fields.String(),
    'details': fields.String(),
    'avatar': fields.Upload(),
    'contact': fields.String(),
    'facebook': fields.String(),
    'twitter': fields.String()
})

USER = api.model('User', {
    'id': fields.Integer(),
    'email': fields.Email(required=True),
开发者ID:ashishpahwa7,项目名称:open-event-orga-server,代码行数:31,代码来源:users.py

示例6: import

from flask.ext.restplus import Namespace

from app.helpers.data import DataManager
from app.helpers.data_getter import DataGetter
from app.models.notifications import Notification as NotificationModel
from app.api.helpers import custom_fields as fields
from app.api.helpers.helpers import (
    can_create,
    requires_auth,
    replace_event_id)
from app.api.helpers.utils import PAGINATED_MODEL, ServiceDAO, \
    POST_RESPONSES
from app.api.helpers.utils import Resource

api = Namespace('notifications', description='Notifications', path='/')

NOTIFICATION = api.model('Notification', {
    'id': fields.Integer(required=True),
    'email': fields.String(required=True),
    'title': fields.String(),
    'message': fields.String(),
    'action': fields.String(),
    'received_at': fields.DateTime(),
})

NOTIFICATION_PAGINATED = api.clone('NotificationPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(NOTIFICATION))
})

NOTIFICATION_POST = api.clone('NotificationPost', NOTIFICATION)
del NOTIFICATION_POST['id']
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:31,代码来源:notifications.py

示例7: Namespace

from flask.ext.restplus import  Namespace, fields
from flask.ext.restplus.fields import Raw

api = Namespace('errors', description='Error Responses')


class NotFoundStatus(Raw):
    __schema_type__ = 'string'
    __schema_example__ = 'NOT_FOUND'


class NotAuthorizedStatus(Raw):
    __schema_type__ = 'string'
    __schema_example__ = 'NOT_AUTHORIZED'


class PermissionDeniedStatus(Raw):
    __schema_type__ = 'string'
    __schema_example__ = 'PERMISSION_DENIED'


class ValidationStatus(Raw):
    __schema_type__ = 'string'
    __schema_example__ = 'INVALID_FIELD'


class InvalidServiceStatus(Raw):
    __schema_type__ = 'string'
    __schema_example__ = 'INVALID_SERVICE'

开发者ID:agwisniewska,项目名称:open-event-orga-server,代码行数:29,代码来源:error_docs.py

示例8: Namespace

from flask import g

from open_event.models.event import Event as EventModel
from open_event.models.users_events_roles import UsersEventsRoles
from open_event.models.role import Role
from open_event.models.user import ORGANIZER
from open_event.helpers.data import save_to_db, update_version

from .helpers.helpers import get_paginated_list, requires_auth, parse_args
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField


api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

EVENT = api.model('Event', {
    'id': fields.Integer(required=True),
    'name': fields.String(required=True),
    'email': fields.Email(),
    'color': fields.Color(),
    'logo': fields.ImageUri(),
    'start_time': fields.DateTime(required=True),
    'end_time': fields.DateTime(required=True),
    'latitude': fields.Float(),
开发者ID:faheemzunjani,项目名称:open-event-orga-server,代码行数:31,代码来源:events.py

示例9: Namespace

from flask.ext.restplus import Resource, Namespace

from app.models.user import User as UserModel
from app.models.user_detail import UserDetail as UserDetailModel
from app.helpers.data import DataManager, record_activity

from .helpers.helpers import requires_auth, can_access_account, staff_only
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, BaseDAO, PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES
from .helpers import custom_fields as fields

api = Namespace("users", description="Users", path="/")


USER_DETAIL = api.model(
    "UserDetail",
    {
        "fullname": fields.String(),
        "details": fields.String(),
        "avatar": fields.Upload(),
        "contact": fields.String(),
        "facebook": fields.String(),
        "twitter": fields.String(),
    },
)

USER = api.model(
    "User",
    {
        "id": fields.Integer(),
        "email": fields.Email(required=True),
        "signup_time": fields.DateTime(),
开发者ID:yasharmaster,项目名称:open-event-orga-server,代码行数:31,代码来源:users.py

示例10: Namespace

from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.session import Level as LevelModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('levels', description='levels', path='/')

LEVEL = api.model('Level', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'label_en': fields.String,
})

LEVEL_PAGINATED = api.clone('LevelPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(LEVEL))
})


@api.route('/events/<int:event_id>/levels/<int:level_id>')
@api.response(404, 'Level not found')
@api.response(400, 'Object does not belong to event')
class Level(Resource):
    @api.doc('get_level')
    @api.marshal_with(LEVEL)
    def get(self, event_id, level_id):
        """Fetch a level given its id"""
        return get_object_in_event(LevelModel, level_id, event_id)
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:30,代码来源:levels.py

示例11: Namespace

from app.models.users_events_roles import UsersEventsRoles
from app.models.event_copyright import EventCopyright
from app.models.role import Role
from app.models.user import ORGANIZER
from app.helpers.data import save_to_db, update_version, record_activity

from .helpers.helpers import requires_auth, parse_args, \
    can_access, fake_marshal_with, fake_marshal_list_with, erase_from_dict
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
from .helpers.utils import Resource
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField, \
    EventPrivacyField, EventSubTopicField

api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

EVENT_COPYRIGHT = api.model('EventCopyright', {
    'holder': fields.String(),
    'holder_url': fields.Uri(),
    'licence': fields.String(),
    'licence_url': fields.Uri(),
    'year': fields.Integer(),
    'logo': fields.String()
})
开发者ID:hacktrec,项目名称:open-event-orga-server,代码行数:30,代码来源:events.py

示例12: Namespace

from app.models.event_copyright import EventCopyright
from app.models.role import Role
from app.models.social_link import SocialLink as SocialLinkModel
from app.models.user import ORGANIZER
from app.models.users_events_roles import UsersEventsRoles
from helpers.special_fields import EventTypeField, EventTopicField, \
    EventPrivacyField, EventSubTopicField, EventStateField
from app.api.helpers import custom_fields as fields
from app.api.helpers.helpers import requires_auth, parse_args, \
    can_access, fake_marshal_with, fake_marshal_list_with, erase_from_dict, replace_event_id
from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN
from app.api.helpers.custom_fields import Licence

api = Namespace('events', description='Events')

EVENT_COPYRIGHT = api.model('EventCopyright', {
    'holder': fields.String(),
    'holder_url': fields.Uri(),
    'licence': fields.String(),
    'licence_url': fields.Uri(),
    'year': fields.Integer(),
    'logo': fields.String()
})

EVENT_CFS = api.model('EventCFS', {
    'announcement': fields.String(),
    'start_date': fields.DateTime(),
    'end_date': fields.DateTime(),
    'timezone': fields.String(),
开发者ID:rafalkowalski,项目名称:open-event-orga-server,代码行数:31,代码来源:events.py

示例13: Namespace

from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.session import Language as LanguageModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('languages', description='languages', path='/')

LANGUAGE = api.model('Language', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'label_en': fields.String,
    'label_de': fields.String,
})

LANGUAGE_PAGINATED = api.clone('LanguagePaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(LANGUAGE))
})


@api.route('/events/<int:event_id>/languages/<int:language_id>')
@api.response(404, 'Language not found')
@api.response(400, 'Object does not belong to event')
class Language(Resource):
    @api.doc('get_language')
    @api.marshal_with(LANGUAGE)
    def get(self, event_id, language_id):
        """Fetch a language given its id"""
        return get_object_in_event(LanguageModel, language_id, event_id)
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:31,代码来源:languages.py

示例14: Namespace

from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.session import Session as SessionModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('sessions', description='Sessions', path='/')

SESSION_TRACK = api.model('SessionTrack', {
    'id': fields.Integer(required=True),
    'name': fields.String,
})

SESSION_SPEAKER = api.model('SessionSpeaker', {
    'id': fields.Integer(required=True),
    'name': fields.String,
})

SESSION_LEVEL = api.model('SessionLevel', {
    'id': fields.Integer(required=True),
    'label_en': fields.String,
})

SESSION_LANGUAGE = api.model('SessionLanguage', {
    'id': fields.Integer(required=True),
    'label_en': fields.String,
    'label_de': fields.String,
})
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:30,代码来源:sessions.py

示例15: import

from flask.ext.restplus import Namespace

from app.api.tickets import ORDER, TICKET
from app.helpers.ticketing import TicketingManager

from app.api.helpers.helpers import (
    requires_auth,
    can_access)
from app.api.helpers.utils import POST_RESPONSES
from app.api.helpers.utils import Resource
from app.api.helpers import custom_fields as fields

api = Namespace('attendees', description='Attendees', path='/')

ATTENDEE = api.model('TicketHolder', {
    'id': fields.Integer(),
    'firstname': fields.String(),
    'lastname': fields.String(),
    'email': fields.Email(),
    'checked_in': fields.Boolean(),
    'order': fields.Nested(ORDER, allow_null=False),
    'ticket': fields.Nested(TICKET, allow_null=False)
})


@api.route('/events/<int:event_id>/attendees/')
class AttendeesList(Resource):
    @requires_auth
    @can_access
    @api.doc('check_in_toggle', responses=POST_RESPONSES)
    @api.marshal_list_with(ATTENDEE)
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:31,代码来源:attendees.py


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