blob: f80bb826b1bcb0a6369bbf9e4370e9d23d560b84 (
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
|
# coding=utf-8
from flask import jsonify
from schema import Schema
from pysite.base_route import APIView
from pysite.constants import ValidationTypes
from pysite.decorators import api_key, api_params
from pysite.mixins import DBMixin
SCHEMA = Schema([
{
"user_id": int,
"role": int
}
])
REQUIRED_KEYS = [
"user_id",
"role"
]
class UserView(APIView, DBMixin):
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):
changes = self.db.insert(
self.table_name, *data,
conflict="update"
)
return jsonify(changes) # pragma: no cover
|