Delete graders when deleting problems

This commit is contained in:
James Wang 2016-04-07 22:54:47 -04:00
parent 19d9fe32eb
commit a94df0dd49
No known key found for this signature in database
GPG key ID: 5B80C0B3F263CD5B

View file

@ -1,6 +1,7 @@
import hashlib import hashlib
import logger import logger
import os import os
import shutil
import utils import utils
from flask import Blueprint, jsonify, session, request from flask import Blueprint, jsonify, session, request
@ -68,6 +69,8 @@ def problem_delete():
if problem: if problem:
Solves.query.filter_by(pid=pid).delete() Solves.query.filter_by(pid=pid).delete()
Problems.query.filter_by(pid=pid).delete() Problems.query.filter_by(pid=pid).delete()
grader_folder = "/".join(problem.grader.split("/")[:-1])
shutil.rmtree(grader_folder)
db.session.commit() db.session.commit()
return { "success": 1, "message": "Success!" } return { "success": 1, "message": "Success!" }
raise WebException("Problem does not exist!") raise WebException("Problem does not exist!")