Commit 5aa104bf by David Ormsbee

Don't explode if a forum content piece is by a user that doesn't exist

parent cde2f4bd
...@@ -301,8 +301,12 @@ def permalink(content): ...@@ -301,8 +301,12 @@ def permalink(content):
def extend_content(content): def extend_content(content):
roles = {} roles = {}
if content.get('user_id'): if content.get('user_id'):
user = User.objects.get(pk=content['user_id']) try:
roles = dict(('name', role.name.lower()) for role in user.roles.filter(course_id=content['course_id'])) user = User.objects.get(pk=content['user_id'])
roles = dict(('name', role.name.lower()) for role in user.roles.filter(course_id=content['course_id']))
except user.DoesNotExist:
logging.error('User ID {0} in comment content {1} but not in our DB.'.format(content.get('user_id'), content.get('id')))
content_info = { content_info = {
'displayed_title': content.get('highlighted_title') or content.get('title', ''), 'displayed_title': content.get('highlighted_title') or content.get('title', ''),
'displayed_body': content.get('highlighted_body') or content.get('body', ''), 'displayed_body': content.get('highlighted_body') or content.get('body', ''),
......
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