def delete(self, exp_id): """ Delete an experiment +--------------------------------------------------------------------+ | Example | +====================================================================+ | http://example.com/exp/EXP_ID | +--------------------------------------------------------------------+ :requires: A secure cookie obtained by logging in. :param int exp_id: The ID of the experiment to be deleted. :returns: A JSON showing the deleted experiment. :raises 401: If the experiment does not belong to this user or the exp_id is wrong. :raises 401: If user is not logged in or if there is no secure cookie available. """ if self.get_current_user(): if self.validate_user_experiment(exp_id): db = Database() mongo_db = MongoLog() response = db.delete_experiment(exp_id) mongo_db.log_deleted_experiment(response) self.write(json.dumps(response['exp_id'])) else: raise ExceptionHandler( reason="Experiment could not be validated.", status_code=401) else: raise ExceptionHandler(reason="Could not validate user.", status_code=401)