summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorprathamesh2016-09-29 15:31:50 +0530
committerprathamesh2016-09-29 15:31:50 +0530
commit155bff9c2a32192405e21ffdb8f533893eb927f4 (patch)
tree9b1a625a824ec89da516ced964b869dfb95481ac /yaksh/models.py
parent64bb8507cbfbaf8b4558926a0c3206eb85547ed1 (diff)
downloadonline_test-155bff9c2a32192405e21ffdb8f533893eb927f4.tar.gz
online_test-155bff9c2a32192405e21ffdb8f533893eb927f4.tar.bz2
online_test-155bff9c2a32192405e21ffdb8f533893eb927f4.zip
Set OUTPUT_DIR path to a temporary directory.
Moved OUTPUT_DIR to settings. Temporary directory path is fetched, and accordingly output path is set. Now, the outpath directory will always have a write permission.
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 7c4d5c4..69dff6d 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -21,10 +21,7 @@ import zipfile
import tempfile
from file_utils import extract_files
from yaksh.xmlrpc_clients import code_server
-
-
-# The directory where user data can be saved.
-OUTPUT_DIR = abspath(join(dirname(__file__), 'output'))
+from django.conf import settings
languages = (
@@ -205,9 +202,9 @@ class Profile(models.Model):
def get_user_dir(self):
"""Return the output directory for the user."""
- user_dir = join(OUTPUT_DIR, str(self.user.username))
+ user_dir = join(settings.OUTPUT_DIR, str(self.user.username))
if not exists(user_dir):
- os.mkdir(user_dir)
+ os.makedirs(user_dir)
# Make it rwx by others.
os.chmod(user_dir, stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH
| stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR