aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/api/category.py
blob: 7923279a97af98068be5602e5e566d4ebed03248 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flask import g

from web.controllers.category import CategoryController
from web.views.api.common import (PyAggResourceNew,
                                  PyAggResourceExisting,
                                  PyAggResourceMulti)


CAT_ATTRS = {'name': {'type': str},
             'user_id': {'type': int}}


class CategoryNewAPI(PyAggResourceNew):
    controller_cls = CategoryController
    attrs = CAT_ATTRS


class CategoryAPI(PyAggResourceExisting):
    controller_cls = CategoryController
    attrs = CAT_ATTRS


class CategoriesAPI(PyAggResourceMulti):
    controller_cls = CategoryController
    attrs = CAT_ATTRS


g.api.add_resource(CategoryNewAPI, '/category', endpoint='category_new.json')
g.api.add_resource(CategoryAPI, '/category/<int:obj_id>',
                   endpoint='category.json')
g.api.add_resource(CategoriesAPI, '/categories', endpoint='categories.json')
bgstack15