From 326e529ffbc45451b0e148a7e036f8c0116841c8 Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Mon, 6 Dec 2021 23:37:16 +0000 Subject: [PATCH] Updated test expiry --- ref-test/admin/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ref-test/admin/views.py b/ref-test/admin/views.py index 3c54905..dfdd3c9 100644 --- a/ref-test/admin/views.py +++ b/ref-test/admin/views.py @@ -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'])