Updated test expiry

This commit is contained in:
Vivek Santayana 2021-12-06 23:37:16 +00:00
parent 72cd18b76f
commit d5559c499d

View File

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