nightly commit
This commit is contained in:
@@ -173,12 +173,12 @@ class CalendarDatabase(object):
|
|||||||
def common_logout(self, token):
|
def common_logout(self, token):
|
||||||
self.tokenOper_check_valid(token)
|
self.tokenOper_check_valid(token)
|
||||||
self.cursor.execute('DELETE FROM token WHERE [ccn_token] = ?;', (token, ))
|
self.cursor.execute('DELETE FROM token WHERE [ccn_token] = ?;', (token, ))
|
||||||
return None
|
return True
|
||||||
|
|
||||||
@SafeDatabaseOperation
|
@SafeDatabaseOperation
|
||||||
def common_tokenValid(self, token):
|
def common_tokenValid(self, token):
|
||||||
self.tokenOper_check_valid(token)
|
self.tokenOper_check_valid(token)
|
||||||
return None
|
return True
|
||||||
|
|
||||||
@SafeDatabaseOperation
|
@SafeDatabaseOperation
|
||||||
def common_isAdmin(self, token):
|
def common_isAdmin(self, token):
|
||||||
@@ -243,7 +243,7 @@ class CalendarDatabase(object):
|
|||||||
lastChange
|
lastChange
|
||||||
))
|
))
|
||||||
if len(self.cursor.fetchall()) == 0:
|
if len(self.cursor.fetchall()) == 0:
|
||||||
raise Exception()
|
raise Exception('No matched uuid or not matched sync symbol')
|
||||||
|
|
||||||
# update
|
# update
|
||||||
newLastChange = utils.GenerateUUID()
|
newLastChange = utils.GenerateUUID()
|
||||||
@@ -264,11 +264,11 @@ class CalendarDatabase(object):
|
|||||||
lastChange
|
lastChange
|
||||||
))
|
))
|
||||||
if len(self.cursor.fetchall()) == 0:
|
if len(self.cursor.fetchall()) == 0:
|
||||||
raise Exception()
|
raise Exception('No matched uuid or not matched sync symbol')
|
||||||
|
|
||||||
# delete
|
# delete
|
||||||
self.cursor.execute('DELETE FROM todo WHERE [ccn_uuid] = ?;', (uuid, ))
|
self.cursor.execute('DELETE FROM todo WHERE [ccn_uuid] = ?;', (uuid, ))
|
||||||
return None
|
return True
|
||||||
|
|
||||||
|
|
||||||
# =============================== admin
|
# =============================== admin
|
||||||
|
|||||||
142
src/server.py
142
src/server.py
@@ -71,54 +71,30 @@ def web_loginHandle():
|
|||||||
|
|
||||||
@app.route('/api/common/salt', methods=['POST'])
|
@app.route('/api/common/salt', methods=['POST'])
|
||||||
def api_common_saltHandle():
|
def api_common_saltHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.common_salt,
|
||||||
if (CheckParameter(('username', ))):
|
(('username', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.common_salt(request.form['username'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/common/login', methods=['POST'])
|
@app.route('/api/common/login', methods=['POST'])
|
||||||
def api_common_loginHandle():
|
def api_common_loginHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.common_login,
|
||||||
if (CheckParameter(('username', 'password'))):
|
(('username', str),
|
||||||
db = calendar_db
|
('password', str)))
|
||||||
result = db.common_login(
|
|
||||||
request.form['username'],
|
|
||||||
request.form['password']
|
|
||||||
)
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/common/webLogin', methods=['POST'])
|
@app.route('/api/common/webLogin', methods=['POST'])
|
||||||
def api_common_webLoginHandle():
|
def api_common_webLoginHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.common_webLogin,
|
||||||
if (CheckParameter(('username', 'password'))):
|
(('username', str),
|
||||||
db = calendar_db
|
('password', str)))
|
||||||
result = db.common_webLogin(
|
|
||||||
request.form['username'],
|
|
||||||
request.form['password']
|
|
||||||
)
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/common/logout', methods=['POST'])
|
@app.route('/api/common/logout', methods=['POST'])
|
||||||
def api_common_logoutHandle():
|
def api_common_logoutHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.common_logout,
|
||||||
if (CheckParameter(('token', ))):
|
(('token', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.common_logout(request.form['token'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/common/tokenValid', methods=['POST'])
|
@app.route('/api/common/tokenValid', methods=['POST'])
|
||||||
def api_common_tokenValidHandle():
|
def api_common_tokenValidHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.common_tokenValid,
|
||||||
if (CheckParameter(('token', ))):
|
(('token', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.common_tokenValid(request.form['token'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/common/isAdmin', methods=['POST'])
|
@app.route('/api/common/isAdmin', methods=['POST'])
|
||||||
def api_common_isAdminHandle():
|
def api_common_isAdminHandle():
|
||||||
@@ -156,8 +132,16 @@ def api_calendar_deleteHandle():
|
|||||||
|
|
||||||
# ================================ collection
|
# ================================ collection
|
||||||
|
|
||||||
@app.route('/api/collection/getOwn', methods=['POST'])
|
@app.route('/api/collection/getFullOwn', methods=['POST'])
|
||||||
def api_collection_getOwnHandle():
|
def api_collection_getFullOwnHandle():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@app.route('/api/collection/getListOwn', methods=['POST'])
|
||||||
|
def api_collection_getListOwnHandle():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@app.route('/api/collection/getDetailOwn', methods=['POST'])
|
||||||
|
def api_collection_getDetailOwnHandle():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@app.route('/api/collection/addOwn', methods=['POST'])
|
@app.route('/api/collection/addOwn', methods=['POST'])
|
||||||
@@ -195,69 +179,39 @@ def api_collection_getSharedHandle():
|
|||||||
|
|
||||||
@app.route('/api/todo/getFull', methods=['POST'])
|
@app.route('/api/todo/getFull', methods=['POST'])
|
||||||
def api_todo_getFullHandle():
|
def api_todo_getFullHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_getFull,
|
||||||
if (CheckParameter(('token', ))):
|
(('token', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.todo_getFull(request.form['token'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/todo/getList', methods=['POST'])
|
@app.route('/api/todo/getList', methods=['POST'])
|
||||||
def api_todo_getListHandle():
|
def api_todo_getListHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_getList,
|
||||||
if (CheckParameter(('token', ))):
|
(('token', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.todo_getList(request.form['token'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/todo/getDetail', methods=['POST'])
|
@app.route('/api/todo/getDetail', methods=['POST'])
|
||||||
def api_todo_getDetailHandle():
|
def api_todo_getDetailHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_getDetail,
|
||||||
if (CheckParameter(('token', 'uuid'))):
|
(('token', str),
|
||||||
db = calendar_db
|
('uuid', str)))
|
||||||
result = db.todo_getDetail(
|
|
||||||
request.form['token'],
|
|
||||||
request.form['uuid']
|
|
||||||
)
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/todo/add', methods=['POST'])
|
@app.route('/api/todo/add', methods=['POST'])
|
||||||
def api_todo_addHandle():
|
def api_todo_addHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_add,
|
||||||
if (CheckParameter(('token', ))):
|
(('token', str), ))
|
||||||
db = calendar_db
|
|
||||||
result = db.todo_add(request.form['token'])
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/todo/update', methods=['POST'])
|
@app.route('/api/todo/update', methods=['POST'])
|
||||||
def api_todo_updateHandle():
|
def api_todo_updateHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_update,
|
||||||
if (CheckParameter(('token', 'uuid', 'data', 'lastChange'))):
|
(('token', str),
|
||||||
db = calendar_db
|
('uuid', str),
|
||||||
result = db.todo_update(
|
('data', str),
|
||||||
request.form['token'],
|
('lastChange', str)))
|
||||||
request.form['uuid'],
|
|
||||||
request.form['data'],
|
|
||||||
request.form['lastChange']
|
|
||||||
)
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
@app.route('/api/todo/delete', methods=['POST'])
|
@app.route('/api/todo/delete', methods=['POST'])
|
||||||
def api_todo_deleteHandle():
|
def api_todo_deleteHandle():
|
||||||
result = (False, None)
|
return SmartDbCaller(calendar_db.todo_delete,
|
||||||
if (CheckParameter(('token', 'uuid', 'lastChange'))):
|
(('token', str),
|
||||||
db = calendar_db
|
('uuid', str),
|
||||||
result = db.todo_delete(
|
('lastChange', str)))
|
||||||
request.form['token'],
|
|
||||||
request.form['uuid'],
|
|
||||||
request.form['lastChange']
|
|
||||||
)
|
|
||||||
|
|
||||||
return ConstructResponseBody(result)
|
|
||||||
|
|
||||||
# ================================ admin
|
# ================================ admin
|
||||||
|
|
||||||
@@ -297,10 +251,18 @@ def UpdateStaticResources():
|
|||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def CheckParameter(paramList):
|
def SmartDbCaller(dbMethod, paramTuple):
|
||||||
gotten = set(request.form.keys())
|
result = (False, 'Invalid parameter', None)
|
||||||
paramSet = set(paramList)
|
paramList = []
|
||||||
return gotten.issubset(paramSet) and paramSet.issubset(gotten)
|
for item in paramTuple:
|
||||||
|
cache = request.form.get(item[0], default=None, type=item[1])
|
||||||
|
if cache is None:
|
||||||
|
break
|
||||||
|
paramList.append(cache)
|
||||||
|
else:
|
||||||
|
result = dbMethod(*paramList)
|
||||||
|
|
||||||
|
return ConstructResponseBody(result)
|
||||||
|
|
||||||
def ConstructResponseBody(returnedTuple):
|
def ConstructResponseBody(returnedTuple):
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user