blob: 5e9dc444bd7945b6cb5b27b26f25827bee0f91ea (
plain) (
blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
|
# coding=utf-8
from flask import jsonify
from schema import Schema
from pysite.base_route import APIView, DBViewMixin
from pysite.constants import ValidationTypes
from pysite.decorators import api_key, api_params
SCHEMA = Schema([
{
"user_id": int,
"role": int
}
])
REQUIRED_KEYS = [
"user_id",
"role"
]
class UserView(APIView, DBViewMixin):
path = "/user"
name = "user"
table_name = "users"
table_primary_key = "user_id"
@api_key
@api_params(schema=SCHEMA, validation_type=ValidationTypes.json)
def post(self, data):
for user in data:
self.db.insert(
self.table_name, user,
conflict="update",
durability="soft"
)
self.db.sync(self.table_name)
return jsonify({"success": True})
|