From 3f9773c4eb2a21902ccdefab89c7f503a08f1743 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 4 Jan 2017 17:39:52 +0530 Subject: Change demo settings for yaksh commands --- online_test/settings.py | 4 +++- yaksh/demo_templates/demo_settings.py | 4 ++++ yaksh/demo_templates/demo_urls.py | 4 +++- yaksh/models.py | 4 ++-- yaksh/scripts/cli.py | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/online_test/settings.py b/online_test/settings.py index 5df0410..0b604ca 100644 --- a/online_test/settings.py +++ b/online_test/settings.py @@ -32,6 +32,8 @@ URL_ROOT = '' # Application definition +FIXTURE_DIRS = os.path.join(BASE_DIR, "yaksh", "fixtures") + INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', @@ -97,7 +99,7 @@ SOCIAL_AUTH_LOGIN_ERROR_URL = '/exam/login/' MEDIA_URL = "/data/" -MEDIA_ROOT = os.path.join(BASE_DIR+"/yaksh/", "data") +MEDIA_ROOT = os.path.join(BASE_DIR, "yaksh", "data") EMAIL_USE_TLS = False diff --git a/yaksh/demo_templates/demo_settings.py b/yaksh/demo_templates/demo_settings.py index 5fe18bc..3c38794 100644 --- a/yaksh/demo_templates/demo_settings.py +++ b/yaksh/demo_templates/demo_settings.py @@ -97,6 +97,10 @@ LOGIN_URL = '/exam/login/' LOGIN_REDIRECT_URL = '/exam/' +MEDIA_URL = "/data/" + +MEDIA_ROOT = os.path.join(BASE_DIR, "yaksh", "data") + SOCIAL_AUTH_LOGIN_ERROR_URL = '/exam/login/' EMAIL_USE_TLS = False diff --git a/yaksh/demo_templates/demo_urls.py b/yaksh/demo_templates/demo_urls.py index b96b476..5abc121 100644 --- a/yaksh/demo_templates/demo_urls.py +++ b/yaksh/demo_templates/demo_urls.py @@ -1,5 +1,6 @@ from django.conf.urls import patterns, include, url - +from django.conf import settings +from django.conf.urls.static import static from django.contrib import admin admin.autodiscover() @@ -12,3 +13,4 @@ urlpatterns = patterns('', url(r'^exam/', include('yaksh.urls', namespace='yaksh', app_name='yaksh')), url(r'^', include('social.apps.django_app.urls', namespace='social')), ) +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/yaksh/models.py b/yaksh/models.py index d2a85f6..a91f4d2 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals from datetime import datetime, timedelta import json from random import sample, shuffle @@ -382,8 +383,7 @@ class Question(models.Model): self.load_questions(questions_list, user, file_path, files) def create_demo_questions(self, user): - zip_file_path = os.path.join(os.getcwd(), 'yaksh', - 'fixtures', 'demo_questions.zip') + zip_file_path = os.path.join(settings.FIXTURE_DIRS, 'demo_questions.zip') files, extract_path = extract_files(zip_file_path) self.read_json(extract_path, user, files) diff --git a/yaksh/scripts/cli.py b/yaksh/scripts/cli.py index fa18ff7..283cb12 100644 --- a/yaksh/scripts/cli.py +++ b/yaksh/scripts/cli.py @@ -76,7 +76,7 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR): management.call_command('startproject', project_name, project_dir) print("Demo Django project '{0}' created at '{1}'".format(project_name, project_dir)) - except Exception, e: + except Exception as e: print("Error: {0}\nExiting yaksh Installer".format(e)) if project_dir is None: -- cgit