Esempio n. 1
0
from flask import request
from flask_restplus import Resource
from extensions import api
from app.serializers.user_serializer import user_serializer
from app.controller.user_controller import UserController

namespace_user = api.namespace("user",
                               description="Operations related with users")


@namespace_user.route("/")
class UserCollection(Resource):
    def __init__(self, api=None, *args, **kwargs):
        super(UserCollection, self).__init__(api, args, kwargs)
        self.user = UserController()

    @api.expect(user_serializer)
    def post(self):
        data = request.json
        return self.user.add_user(email=data.get("email"),
                                  password=data.get("password"),
                                  cpf=data.get("cpf"))
Esempio n. 2
0
from flask_restplus import Resource
from extensions import api
from app.serializers.chat_serializer import message_serializer
from app.controller.chat_controller import ChatController

namespace_chat = api.namespace("chat",
                               description="Operations related with chat")


@namespace_chat.route("/")
class ChatCollection(Resource):
    def __init__(self, api=None, *args, **kwargs):
        super(ChatCollection, self).__init__(api, args, kwargs)
        self.chat = ChatController()

    @api.expect(message_serializer)
    def post(self):
        return self.chat.add_message(api.payload)
Esempio n. 3
0
from api.core.route import BaseRoute
from api.login.controller import LoginController
from api.login.schema import LoginRequest, LoginResponse
from extensions import api

ns = api.namespace('auth', description='Authenticate operations')

__all__ = [
    "LoginCommonRoute",
]


@ns.route('/login')
class LoginCommonRoute(BaseRoute):
    def get_controller(self):
        return LoginController

    @ns.doc('login by email, password')
    @ns.marshal_with(LoginResponse)
    @ns.expect(LoginRequest)
    def post(self):
        data = api.payload
        return self.controller.login(data=data)
Esempio n. 4
0
from flask import request
from flask_restplus import Resource
from extensions import api
from app.serializers.user_serializer import auth_serializer
from app.controller.auth_controller import AuthController

namespace_auth = api.namespace(
    "auth", description="Operations related with authentication")


@namespace_auth.route("/login")
class UserLogin(Resource):
    def __init__(self, api=None, *args, **kwargs):
        super(UserLogin, self).__init__(api, args, kwargs)
        self.auth = AuthController()

    @api.expect(auth_serializer)
    def post(self):
        data = request.json
        return self.auth.login(data=data)
Esempio n. 5
0
from flask import request
from flask_restplus import Resource
from bson.objectid import ObjectId
from extensions import api
from app.schemas import RequirementSchema
from app.helpful.status import StatusRequirement
from app.serializers.requirements_serializer import requirements_serializer
from app.controller.requirements_controller import RequirementsController

namespace_requirements = api.namespace(
    "requirements", description="Operations related with requirements")


@namespace_requirements.route("/")
class RequirementsCollection(Resource):
    def __init__(self, api=None, *args, **kwargs):
        super(RequirementsCollection, self).__init__(api, args, kwargs)
        self.requirements = RequirementsController()

    @api.expect(requirements_serializer)
    def post(self):
        data = request.json
        #representa o primeiro status de uma solicitação que é o de "solicitada"
        status = StatusRequirement.REQUESTED.value
        id_user = ObjectId(data.get("id_user"))
        return self.requirements.save_basic_requirement(id_user=id_user,
                                                        status=status)

    def get(self):
        schema = RequirementSchema(many=True)
        data = self.requirements.get_requirements()
Esempio n. 6
0
from flask import request
from flask_restplus import Resource
from extensions import api
from app.util.decorator import token_required
from app.schemas import KindnessDetailSchema, KindnessSchema
from app.serializers.kindness_serializer import kindness_create_serializer
from app.controllers.kindness_controller import KindnessController

namespace_kindness = api.namespace(
    "kindness", description="Operations related with kindness")

parser = api.parser()
parser.add_argument("user_latitude", type=float)
parser.add_argument("user_longitude", type=float)
parser.add_argument("id_user", type=int)


@namespace_kindness.route("/")
class KindnessCollection(Resource):
    def __init__(self, api=None, *args, **kwargs):
        super(KindnessCollection, self).__init__(api, args, kwargs)
        self.kindness = KindnessController()

    #@api.doc(security="apiKey")
    @api.expect(parser)
    #@token_required
    def get(self):
        schema = KindnessSchema(many=True)

        args = parser.parse_args()
        latitude = args["user_latitude"]