Commit 1bf5d712 by David Baumgold

Merge pull request #2662 from edx/db/textbook-id-unicode

Call unicode() instead of str() for textbook IDs
parents 92d4726b 33f56e1b
...@@ -738,7 +738,7 @@ def validate_textbook_json(textbook): ...@@ -738,7 +738,7 @@ def validate_textbook_json(textbook):
raise TextbookValidationError("must be JSON object") raise TextbookValidationError("must be JSON object")
if not textbook.get("tab_title"): if not textbook.get("tab_title"):
raise TextbookValidationError("must have tab_title") raise TextbookValidationError("must have tab_title")
tid = str(textbook.get("id", "")) tid = unicode(textbook.get("id", ""))
if tid and not tid[0].isdigit(): if tid and not tid[0].isdigit():
raise TextbookValidationError("textbook ID must start with a digit") raise TextbookValidationError("textbook ID must start with a digit")
return textbook return textbook
...@@ -853,7 +853,7 @@ def textbooks_detail_handler(request, tid, tag=None, package_id=None, branch=Non ...@@ -853,7 +853,7 @@ def textbooks_detail_handler(request, tid, tag=None, package_id=None, branch=Non
) )
store = get_modulestore(course.location) store = get_modulestore(course.location)
matching_id = [tb for tb in course.pdf_textbooks matching_id = [tb for tb in course.pdf_textbooks
if str(tb.get("id")) == str(tid)] if unicode(tb.get("id")) == unicode(tid)]
if matching_id: if matching_id:
textbook = matching_id[0] textbook = matching_id[0]
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment