From da2fda1045f1a212e3b9be0328fc99c381fbb81e Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Fri, 14 Jun 2013 21:13:11 -0700 Subject: [PATCH] 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():