aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-09-11 18:28:12 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-01-26 23:46:30 +0100
commit462f6d3b21558ed0a283c24e0e0332eac6ccbbb3 (patch)
tree451c583b5f47bbf6e38743881c66f2f27371bd82 /pyaggr3g470r/views
parentmoving the root of source code from / to /src/ (diff)
downloadnewspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.tar.gz
newspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.tar.bz2
newspipe-462f6d3b21558ed0a283c24e0e0332eac6ccbbb3.zip
base modification in model for category support
Diffstat (limited to 'pyaggr3g470r/views')
-rw-r--r--pyaggr3g470r/views/api/category.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/pyaggr3g470r/views/api/category.py b/pyaggr3g470r/views/api/category.py
new file mode 100644
index 00000000..31f46751
--- /dev/null
+++ b/pyaggr3g470r/views/api/category.py
@@ -0,0 +1,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')
bgstack15