Skip to content

Commit

Permalink
Merge pull request #4227 from learningequality/0.14.x
Browse files Browse the repository at this point in the history
Merge 0.14.x into develop
  • Loading branch information
aronasorman committed Aug 12, 2015
2 parents 9915005 + 3f5e60c commit 67e5c9c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
20 changes: 10 additions & 10 deletions kalite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

if not _data_path:
_data_path = '.'

# This is getting deprecated as we will not explicitly operate with a static
# source structure, but have shared system-wide data and user data.
# It's not actually even a project root, because it's also the application's
Expand All @@ -124,10 +124,10 @@
default_project_root
)
)

else:
_data_path = os.path.join(ROOT_DATA_PATH,)

# BEING DEPRECATED, PLEASE DO NOT USE PROJECT_PATH!
PROJECT_PATH = os.environ.get(
"KALITE_HOME",
Expand Down Expand Up @@ -186,7 +186,7 @@
USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
LOCALE_PATHS = getattr(local_settings, "LOCALE_PATHS", (USER_WRITABLE_LOCALE_DIR,))
LOCALE_PATHS = tuple([os.path.realpath(lp) + "/" for lp in LOCALE_PATHS])

# This is the legacy location kalite/database/data.sqlite
DEFAULT_DATABASE_PATH = os.path.join(_data_path, "kalite", "database", "data.sqlite")

Expand All @@ -196,22 +196,22 @@

# Storing data in a user directory
else:

# Ensure that path exists
if not os.path.exists(USER_DATA_ROOT):
os.mkdir(USER_DATA_ROOT)

USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
KALITE_APP_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')

LOCALE_PATHS = getattr(local_settings, "LOCALE_PATHS", (USER_WRITABLE_LOCALE_DIR, KALITE_APP_LOCALE_DIR))
if not os.path.exists(USER_WRITABLE_LOCALE_DIR):
os.mkdir(USER_WRITABLE_LOCALE_DIR)

DEFAULT_DATABASE_PATH = os.path.join(USER_DATA_ROOT, "database",)
if not os.path.exists(DEFAULT_DATABASE_PATH):
os.mkdir(DEFAULT_DATABASE_PATH)

DEFAULT_DATABASE_PATH = os.path.join(DEFAULT_DATABASE_PATH, 'data.sqlite')

# Stuff that can be served by the HTTP server is located the same place
Expand Down Expand Up @@ -464,7 +464,7 @@

# Separate session caching from file caching.
SESSION_ENGINE = getattr(
local_settings, "SESSION_ENGINE", 'django.contrib.sessions.backends.cache' + (''))
local_settings, "SESSION_ENGINE", 'django.contrib.sessions.backends.signed_cookies' + (''))

# Use our custom message storage to avoid adding duplicate messages
MESSAGE_STORAGE = 'fle_utils.django_utils.classes.NoDuplicateMessagesSessionStorage'
Expand Down
5 changes: 4 additions & 1 deletion kalite/testing/management/commands/readmodel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import importlib
import json
import sys
Expand All @@ -9,6 +10,8 @@
from django.core.management.base import BaseCommand, CommandError
from django.core import serializers

dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) else None

class Command(BaseCommand):
args = "<model_path>"

Expand Down Expand Up @@ -40,7 +43,7 @@ def handle(self, *args, **options):
serialized_data = serializers.serialize("python", [data])[0]["fields"]
serialized_data["id"] = model_id
logging.debug("Serialized data: '%s'" % serialized_data)
print json.dumps(serialized_data)
print json.dumps(serialized_data, default=dthandler)

except Model.DoesNotExist:
logging.error("Could not find '%s' entry with primary key: '%s'" % (model_path, model_id))
Expand Down
9 changes: 4 additions & 5 deletions kalite/topic_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def cache_file_path(basename):
CACHE_VARS.append("TOPICS")
CNT=0
def get_topic_tree(force=False, annotate=False, channel=None, language=None, parent=None):

# Hardcode the Brazilian Portuguese mapping that only the central server knows about
# TODO(jamalex): BURN IT ALL DOWN!
if language == "pt-BR":
Expand Down Expand Up @@ -193,16 +193,15 @@ def get_exercise_cache(force=False, language=None):
EXERCISES[language] = exercises
return EXERCISES[language]
EXERCISES[language] = softload_json(settings.EXERCISES_FILEPATH, logger=logging.debug, raises=False)

# English-language exercises live in application space, translations in user space
if language == "en":
exercise_root = os.path.join(settings.KHAN_EXERCISES_DIRPATH, "exercises")
else:
exercise_root = os.path.join(django_settings.USER_DATA_ROOT, "exercises")
exercise_root = i18n.get_localized_exercise_dirpath(language)
if os.path.exists(exercise_root):
exercise_path = os.path.join(exercise_root, language) if language != "en" else exercise_root
try:
exercise_templates = os.listdir(exercise_path)
exercise_templates = os.listdir(exercise_root)
except OSError:
exercise_templates = []
else:
Expand Down
12 changes: 1 addition & 11 deletions python-packages/securesync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@
ID_MAX_LENGTH=32
IP_MAX_LENGTH=50


# TODO(benjaoming): So the version of securesync dynamic !? Not understanding
# this.. plus it adds problems in dependency testing... but that should be
# deleted anyways... for now just hard coding it at 1.0 and below will be
# left commented out.
# try:
# from kalite.version import VERSION
# except:
# VERSION = "1.0"

VERSION = "1.0"
from kalite.version import VERSION

# JsonResponseMessageError codes
class ERROR_CODES:
Expand Down

0 comments on commit 67e5c9c

Please sign in to comment.