-
Notifications
You must be signed in to change notification settings - Fork 2
/
users.py
59 lines (41 loc) · 1.71 KB
/
users.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from flask import request, abort
from flask_restful import Resource
from werkzeug.exceptions import BadRequest
from werkzeug.utils import secure_filename
from data_pm import connect, uploadImage, s3
import json
import os
import ast
class UserInfo(Resource):
def __call__(self):
print("In User Info")
def get(self, user_id):
print("In UserInfo GET")
print(user_id)
with connect() as db:
# print("in get lease applications")
userQuery = db.execute("""
SELECT *
FROM space.users
-- WHERE user_uid = '[email protected]' OR email = '[email protected]' ;
WHERE user_uid = \'""" + user_id + """\' OR email = \'""" + user_id + """\' ;
""")
print(userQuery)
if userQuery['code'] == 200 and int(len(userQuery['result']) > 0):
print(userQuery['result'][0]['user_uid'])
return userQuery
else:
abort(404, description="User not found")
def put(self):
print("In update User")
with connect() as db:
payload = request.get_json()
print(payload)
if payload["user_uid"] is None:
raise BadRequest("Request failed, no UID in payload.")
key = {'user_uid': payload.pop('user_uid')}
print(key)
# print(payload)
with connect() as db:
response = db.update('users', key, payload)
return response