From da2fda1045f1a212e3b9be0328fc99c381fbb81e Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Fri, 14 Jun 2013 21:13:11 -0700 Subject: [PATCH 1/4] Fix for broken forums due to forum entry with no start_date modification of @jrbl's version to handle a dict with value None --- lms/djangoapps/django_comment_client/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 6e9f6c1f71..477ead0214 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -1,9 +1,9 @@ +import pytz from collections import defaultdict import logging import urllib from datetime import datetime -from courseware.module_render import get_module from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.db import connection @@ -169,7 +169,9 @@ def initialize_discussion_info(course): category = " / ".join([x.strip() for x in category.split("/")]) last_category = category.split("/")[-1] discussion_id_map[id] = {"location": module.location, "title": last_category + " / " + title} - unexpanded_category_map[category].append({"title": title, "id": id, "sort_key": sort_key, "start_date": module.lms.start}) + #Handle case where module.lms.start is None + entry_start_date = module.lms.start if module.lms.start else pytz.UTC.localize(datetime.max) + unexpanded_category_map[category].append({"title": title, "id": id, "sort_key": sort_key, "start_date": entry_start_date}) category_map = {"entries": defaultdict(dict), "subcategories": defaultdict(dict)} for category_path, entries in unexpanded_category_map.items(): From a3f45bd94a0b23c8b572108ba3be1b615ec660d7 Mon Sep 17 00:00:00 2001 From: John Jarvis Date: Mon, 17 Jun 2013 17:45:22 -0400 Subject: [PATCH 2/4] moving segment io setting below auth.json --- cms/envs/aws.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cms/envs/aws.py b/cms/envs/aws.py index a6d6e2f847..c6a383211f 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -112,12 +112,6 @@ TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE) for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items(): MITX_FEATURES[feature] = value -# If Segment.io key specified, load it and turn on Segment.io if the feature flag is set -# Note that this is the Studio key. There is a separate key for the LMS. -SEGMENT_IO_KEY = AUTH_TOKENS.get('SEGMENT_IO_KEY') -if SEGMENT_IO_KEY: - MITX_FEATURES['SEGMENT_IO'] = ENV_TOKENS.get('SEGMENT_IO', False) - LOGGING = get_logger_config(LOG_DIR, logging_env=ENV_TOKENS['LOGGING_ENV'], syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514), @@ -129,6 +123,13 @@ LOGGING = get_logger_config(LOG_DIR, with open(ENV_ROOT / CONFIG_PREFIX + "auth.json") as auth_file: AUTH_TOKENS = json.load(auth_file) +# If Segment.io key specified, load it and turn on Segment.io if the feature flag is set +# Note that this is the Studio key. There is a separate key for the LMS. +SEGMENT_IO_KEY = AUTH_TOKENS.get('SEGMENT_IO_KEY') +if SEGMENT_IO_KEY: + MITX_FEATURES['SEGMENT_IO'] = ENV_TOKENS.get('SEGMENT_IO', False) + + AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"] AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"] DATABASES = AUTH_TOKENS['DATABASES'] From 28ae2b634660292e18c9c673957fff5f1d78b362 Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Mon, 17 Jun 2013 16:11:35 -0700 Subject: [PATCH 3/4] change form of making datetime.max aware (in UTC) --- lms/djangoapps/django_comment_client/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 477ead0214..496c834950 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -170,7 +170,7 @@ def initialize_discussion_info(course): last_category = category.split("/")[-1] discussion_id_map[id] = {"location": module.location, "title": last_category + " / " + title} #Handle case where module.lms.start is None - entry_start_date = module.lms.start if module.lms.start else pytz.UTC.localize(datetime.max) + entry_start_date = module.lms.start if module.lms.start else datetime.max.replace(tzinfo=pytz.UTC) unexpanded_category_map[category].append({"title": title, "id": id, "sort_key": sort_key, "start_date": entry_start_date}) category_map = {"entries": defaultdict(dict), "subcategories": defaultdict(dict)} From 048be222a66ed780ffc80e8ad66280a4a89e5d5d Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Mon, 17 Jun 2013 18:02:03 -0600 Subject: [PATCH 4/4] Update CHANGELOG.rst --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a6feac71a2..5eb50a06f2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, in roughly chronological order, most recent first. Add your entries at or near the top. Include a label indicating the component affected. +LMS: Forums. Added handling for case where discussion module can get `None` as +value of lms.start in `lms/djangoapps/django_comment_client/utils.py` Studio, LMS: Make ModelTypes more strict about their expected content (for instance, Boolean, Integer, String), but also allow them to hold either the