Beispiel #1
0
from app import db
from flask import current_app, request
from app.common.schema import *
from app.common.param import *
from app.common.wrap import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from sqlalchemy import or_
from .model import *
from .schema import *
from .param import *
from .dao import *
from app.modules.admin.schema import *
from app.modules.notice_content_admin.schema import *

ns = Namespace("notice_content",
               description="RESTful API Notice Content resource")


@ns.route("/")
class Notice_contentAPI(Resource):
    """
    Notice Content module resource main service: add/delete/edit/view
    """
    @ns.parameters(Notice_contentParameters(dump_only=['id']))
    @ns.response(Notice_contentSchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
        record = None
Beispiel #2
0
from app.common.result import Result
from app.common.wrap import auth
from .model import *
from .schema import *
from .param import *
from .dao import *
import random
import string
from sqlalchemy import or_
from datetime import datetime
import uuid
import os
from app.modules.admin.model import *
from app.modules.admin.dao import *

ns = Namespace("attachments", description="attachments API Resource")


@ns.route("/")
class AttachmentsAPI(Resource):
    """
    attachments module resource main service: add/delete/edit/view
    """
    @auth()
    @ns.response(AttachmentsSchema())
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def get(self, args):
        """
        view
        """
        record = None
Beispiel #3
0
from app import db
from flask import current_app, request
from app.common.status import Status
from app.common.schema import *
from app.common.param import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from app.common.result import Result
from .model import *
from .schema import *
from .param import *
import random
import string
from sqlalchemy import or_

ns = Namespace("adminroles", description="adminroles API Resource")
Beispiel #4
0
LICENSE: Apache-2.0
"""

from app import db
from flask import current_app,request
from app.common.schema import *
from app.common.param import *
from app.common.wrap import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from sqlalchemy import or_
from .model import *
from .schema import *
from .param import *
from .dao import *

ns = Namespace("configs", description="configs API Resource")

@ns.route("/")
class ConfigsAPI(Resource):
    """
    configs module resource main service: add/delete/edit/view
    """
    @ns.parameters(ConfigsParameters(dump_only=['id']))
    @ns.response(ConfigsSchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
        configs = None
        configsDao = ConfigsDao()
Beispiel #5
0
# ======================================
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(), nullable=False)


# Serialization/Deserialization schema definition
# ===============================================
class UserSchema(ModelSchema):
    class Meta:
        model = User


# "Users" resource RESTful API definitions
# ========================================
users_api = Namespace('users')
api.add_namespace(users_api)


@users_api.route('/')
class UsersList(Resource):
    @users_api.response(UserSchema(many=True))
    def get(self):
        return User.query.all()


@users_api.route('/<int:user_id>')
@users_api.resolve_object(
    'user', lambda kwargs: User.query.get_or_404(kwargs.pop('user_id')))
class UserByID(Resource):
    @users_api.response(UserSchema())
Beispiel #6
0
"""resource

API Resource

PROJECT: BaoAI Backend
AUTHOR: henry <*****@*****.**>
WEBSITE: http://www.baoai.co
COPYRIGHT: Copyright © 2016-2020 广州源宝网络有限公司 Guangzhou Yuanbao Network Co., Ltd. ( http://www.ybao.org )
LICENSE: Apache-2.0
"""

from app import db
from flask import current_app, request
from app.common.status import Status
from app.common.schema import *
from app.common.param import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from app.common.result import Result
from .model import *
from .schema import *
from .param import *
from sqlalchemy import or_

ns = Namespace("rolesresources", description="Rolesresources Namespace")
Beispiel #7
0
from flask_restplus import Resource
from flask_restplus_patched import Namespace
from sqlalchemy.exc import IntegrityError
from werkzeug.exceptions import Conflict, NotFound

from egl.api.v1 import Auditable
from egl.api.v1.authorization import authorize
from egl.api.v1.schemas import PagingParametersSchema, UserPageSchema, UserSchema
from egl.api.v1.services import UserService
from egl.db.models import Permissions, User
from egl.db.sessions import db

ns = Namespace('Users')


@ns.route('/')
class UsersResource(Resource):
    @ns.parameters(PagingParametersSchema(), locations=['query'])
    @ns.response(UserPageSchema())
    def get(self, paging):
        service = UserService()
        return service.get_users(paging.page, paging.per_page)

    # @ns.parameters(NewUserSchema(), locations=['json'])
    # @ns.response(UserSchema(), code=201)
    # def post(self, validated):
    #     service = UserService()
    #     return service.create(validated)


@ns.route('/<id>')
Beispiel #8
0
from flask import jsonify

from flask_login import login_required, current_user, logout_user, login_user
from flask_restplus import Resource
from flask_restplus_patched import Namespace, abort
from werkzeug.exceptions import Unauthorized

from egl.api.v1 import Auditable
from egl.api.v1.schemas import LoginSchema, UserSchema, CurrentUserSchema
from egl.db.models.user import User
from egl.db.sessions import db

ns = Namespace('Authentication')


@ns.route('/current')
class CurrentUserResource(Resource):
    @login_required
    @ns.response(UserSchema())
    def get(self):
        return current_user


@ns.route('/login')
class LoginResource(Resource, Auditable):
    @ns.parameters(LoginSchema(), locations=['json'])
    @ns.response(UserSchema())
    def post(self, login):
        """
        Wire up a non-standard REST login end point, and revisit to support a traditional Authorization header.
        This provides quick entry for all of the moving parts, and ensuring bcrypt and our seed data is working as desired.
Beispiel #9
0
CREATEDATE: 2019-08-23 16:18:40
"""

from app import db
from flask import current_app, request
from app.common.schema import *
from app.common.param import *
from app.common.wrap import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from sqlalchemy import or_
from .model import *
from .schema import *
from .param import *
from .dao import *

ns = Namespace("iris", description="RESTful API IRIS resource")


@ns.route("/")
class IrisAPI(Resource):
    """
    IRIS module resource main service: add/delete/edit/view
    """
    @ns.parameters(IrisParameters(dump_only=['id']))
    @ns.response(IrisSchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
        record = None
Beispiel #10
0
from app import db
from flask import current_app, request
from app.common.status import Status
from app.common.schema import *
from app.common.param import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from app.common.result import Result
from app.common.wrap import auth
from .model import *
from .schema import *
from .param import *
from .dao import *
from sqlalchemy import or_

ns = Namespace("roles", description="roles API Resource")


@ns.route("/")
class RolesAPI(Resource):
    @auth()
    @ns.response(RolesSchema())
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def get(self):
        """
        view
        """
        record = None
        rolesDao = RolesDao()
        id = request.uid
        record = rolesDao.getById(id)
Beispiel #11
0
from app import db
from flask import current_app, request
from flask_restplus._http import HTTPStatus
from app.common.schema import *
from app.common.param import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from .model import *
from .schema import *
from .param import *
import random
import string
from sqlalchemy import or_
from .dao import *
from app.common.wrap import auth

ns = Namespace("profiles", description="profiles API Resource")


@ns.route("/")
class ProfilesAPI(Resource):
    @ns.parameters(ProfilesParameters(dump_only=['id']))
    @ns.response(ProfilesSchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
        profiles = None
        profilesDao = ProfilesDao()
        try:
            profiles = profilesDao.add(args)
Beispiel #12
0
LICENSE: Apache-2.0
"""

from app import db
from flask import current_app, request
from app.common.schema import *
from app.common.param import *
from app.common.wrap import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from .model import *
from .schema import *
from .param import *
from sqlalchemy import or_
from .dao import *

ns = Namespace("logs", description="logs API Resource")


@ns.route("/")
class LogsAPI(Resource):
    @ns.parameters(LogsParameters(dump_only=['id']))
    @ns.response(LogsSchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
        logs = None
        logsDao = LogsDao()
        try:
            logs = logsDao.add(args)
#! coding: utf-8

import logging
from flask_restplus_patched import Namespace, abort
from flask_restplus import Resource

from simple.repository import test_result

simple_ns = Namespace('simple')
logger = logging.getLogger("simple")


class CurrentUserResource(Resource):
    def get(self):
        result = test_result()
        logger.info(result)
        if result:
            return {"data": result[0].id}
        else:
            return {"data": 0}
Beispiel #14
0
 def namespace(self, *args, **kwargs):
     # The only purpose of this method is to pass custom Namespace class
     _namespace = Namespace(*args, **kwargs)
     self.namespaces.append(_namespace)
     return _namespace
Beispiel #15
0
CREATEDATE: 2019-08-04 10:04:19
"""

from app import db
from flask import current_app, request
from app.common.schema import *
from app.common.param import *
from app.common.wrap import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from sqlalchemy import or_
from .model import *
from .schema import *
from .param import *
from .dao import *

ns = Namespace("category", description="RESTful API Category resource")


@ns.route("/")
class CategoryAPI(Resource):
    """
    Category module resource main service: add/delete/edit/view
    """
    @auth()
    @ns.parameters(CategoryParameters(dump_only=['id']))
    @ns.response(CategorySchema(many=False))
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def post(self, args):
        """
        add
        """
Beispiel #16
0
from app import db
from flask import current_app, request, session
from app.common.status import Status
from app.common.schema import *
from app.common.param import *
from flask_restplus_patched import Resource, Namespace, abort, HTTPStatus
from app.common.result import Result
from app.common.wrap import auth
from app.common.captcha import CaptchaTool
from .model import *
from .schema import *
from .param import *
from .dao import *

ns = Namespace("admin", description="admin API Resource")


@ns.route("/")
class AdminAPI(Resource):
    @auth()
    @ns.response(AdminSchema())
    @ns.response(code=HTTPStatus.NO_CONTENT)
    @ns.response(code=HTTPStatus.INTERNAL_SERVER_ERROR)
    def get(self):
        """
        view # 查看
        """
        record = None
        adminDao = AdminDao()
        id = request.uid