コード例 #1
0
ファイル: views.py プロジェクト: carlosandrade/gastos_abertos
from flask.ext.restplus import Resource
from sqlalchemy import desc

# from flask.ext.restplus import Resource, marshal_with, fields
# from sqlalchemy import Integer

from .models import Execucao, History, ExecucaoYearInfo
from gastosabertos.extensions import db, api

# Blueprint for Execucao
execucao = Blueprint(
    "execucao", __name__, template_folder="templates", static_folder="static", static_url_path="/execucao/static"
)


ns = api.namespace("api/v1/execucao", "Dados sobre execução")

arguments = {
    "code": {"type": str, "help": "Code."},
    "codes": {"type": list, "location": "json", "default": None, "help": "List of codes."},
    "year": {"type": int, "help": "Year."},
    "page": {"type": int, "default": 0, "help": "Page."},
    "per_page_num": {"type": int, "default": 100, "help": "Number of elements per page."},
    "has_key": {"type": str, "help": "Field that must have been modified."},
}


def create_parser(*args):
    """Create a parser for the passed arguments."""
    parser = api.parser()
    for arg in args:
コード例 #2
0
from flask.ext.restplus import Resource, fields

from .models import Revenue, RevenueCode
from ..utils import with_csv
from gastosabertos.extensions import db, api

# Blueprint for Receita
receita = Blueprint('receita',
                    __name__,
                    template_folder='templates',
                    static_folder='static',
                    static_url_path='/receita/static')

# Create the restful API
receita_api = restful.Api(receita)
ns = api.namespace('api/v1/receita',
                   'API para as Receitas da cidade de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
revenue_list_parser = RequestParser()
revenue_list_parser.add_argument('page', type=int, default=0)
revenue_list_parser.add_argument('per_page_num', type=int, default=100)
revenue_list_parser.add_argument('years', type=int, action='append')
revenue_list_parser.add_argument('code')

# Fields for RevenueAPI data marshal
コード例 #3
0
ファイル: views.py プロジェクト: chrmorais/gastos_abertos
from flask.ext.restplus import Resource
from sqlalchemy import func
# from flask.ext.restplus import Resource, marshal_with, fields
# from sqlalchemy import Integer

from .models import Execucao
from gastosabertos.extensions import db, api

# Blueprint for Execucao
execucao = Blueprint('execucao', __name__,
                     template_folder='templates',
                     static_folder='static',
                     static_url_path='/execucao/static')


ns = api.namespace('execucao', 'Dados sobre execução')


@ns.route('/info')
class ExecucaoInfoApi(Resource):

    def get(self):
        '''Information about all the database (currently only years).'''
        dbyears = db.session.query(Execucao.get_year()).distinct().all()
        years = sorted([str(i[0]) for i in dbyears])

        return {
            'data': {
                'years': years,
            }
        }
コード例 #4
0
ファイル: views.py プロジェクト: VitorPizzuto/gastos_abertos
from .models import Contrato
from ..utils import with_csv
from gastosabertos.extensions import db, api

# Blueprint for Contrato
contratos = Blueprint('contratos', __name__,
                      template_folder='templates',
                      static_folder='static',
                      static_url_path='/contrato/static')


# Create the restful API
contratos_api = restful.Api(contratos)

ns = api.namespace('api/v1/contrato', 'API para os contrato de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
_filter_parser = api.parser()
_filter_parser.add_argument('cnpj')
_filter_parser.add_argument('orgao')
_filter_parser.add_argument('modalidade')
_filter_parser.add_argument('evento')
_filter_parser.add_argument('objeto')
_filter_parser.add_argument('processo_administrativo')
コード例 #5
0
from flask.ext.restplus import Resource
from sqlalchemy import desc
# from flask.ext.restplus import Resource, marshal_with, fields
# from sqlalchemy import Integer

from .models import Execucao, History, ExecucaoYearInfo
from gastosabertos.extensions import db, api

# Blueprint for Execucao
execucao = Blueprint('execucao',
                     __name__,
                     template_folder='templates',
                     static_folder='static',
                     static_url_path='/execucao/static')

ns = api.namespace('api/v1/execucao', 'Dados sobre execução')

arguments = {
    'code': {
        'type': str,
        'help': 'Code.',
    },
    'codes': {
        'type': list,
        'location': 'json',
        'default': None,
        'help': 'List of codes.',
    },
    'year': {
        'type': int,
        'help': 'Year.',
コード例 #6
0
ファイル: views.py プロジェクト: VitorPizzuto/gastos_abertos

from .models import Revenue, RevenueCode
from ..utils import with_csv
from gastosabertos.extensions import db, api

# Blueprint for Receita
receita = Blueprint('receita', __name__,
                    template_folder='templates',
                    static_folder='static',
                    static_url_path='/receita/static')


# Create the restful API
receita_api = restful.Api(receita)
ns = api.namespace('api/v1/receita', 'API para as Receitas da cidade de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
revenue_list_parser = RequestParser()
revenue_list_parser.add_argument('page', type=int, default=0)
revenue_list_parser.add_argument('per_page_num', type=int, default=100)
revenue_list_parser.add_argument('years', type=int, action='append')
revenue_list_parser.add_argument('code')

# Fields for RevenueAPI data marshal
コード例 #7
0
from .models import Contrato
from ..utils import with_csv
from gastosabertos.extensions import db, api

# Blueprint for Contrato
contratos = Blueprint('contratos',
                      __name__,
                      template_folder='templates',
                      static_folder='static',
                      static_url_path='/contrato/static')

# Create the restful API
contratos_api = restful.Api(contratos)

ns = api.namespace('api/v1/contrato', 'API para os contrato de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
_filter_parser = api.parser()
_filter_parser.add_argument('cnpj')
_filter_parser.add_argument('orgao')
_filter_parser.add_argument('modalidade')
_filter_parser.add_argument('evento')
_filter_parser.add_argument('objeto')
_filter_parser.add_argument('processo_administrativo')