Updated test expiry

This commit is contained in:
Vivek Santayana 2021-12-06 23:37:16 +00:00
parent b5d5f7f0e1
commit 326e529ffb

View File

@ -421,8 +421,8 @@ def delete_test():
def close_test(): def close_test():
from main import db from main import db
_id = request.get_json()['_id'] _id = request.get_json()['_id']
if db.tests.find_one_and_update({'_id': _id}, {'$set': {'expiry_date': datetime.today() - timedelta(days=1) }}): if db.tests.find_one({'_id': _id}):
return Test(_id = _id).delete() return Test(_id = _id, expiry_date= datetime.today() - timedelta(days=1)).update()
return jsonify({'error': 'Could not find the corresponding test to delete.'}), 404 return jsonify({'error': 'Could not find the corresponding test to delete.'}), 404
@views.route('/test/<_id>/', methods=['GET','POST']) @views.route('/test/<_id>/', methods=['GET','POST'])