blob: 31f46751225b02bf6537c0b1e04c923f24e5724b (
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 pyaggr3g470r.controllers.category import CategoryController
from pyaggr3g470r.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')
|