Commit 2bc156cd by Ned Batchelder

Merge pull request #1865 from edx/ned/merge-hotfix-2013-12-04-to-master

The changes from hotfix/2013-12-04 that we want permanently
parents 09befd2a 1cbc1716
...@@ -19,7 +19,7 @@ import uuid ...@@ -19,7 +19,7 @@ import uuid
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in, user_logged_out from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.db import models from django.db import models, IntegrityError
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver, Signal from django.dispatch import receiver, Signal
import django.dispatch import django.dispatch
...@@ -52,7 +52,7 @@ class AnonymousUserId(models.Model): ...@@ -52,7 +52,7 @@ class AnonymousUserId(models.Model):
http://docs.python.org/2/library/md5.html#md5.digest_size http://docs.python.org/2/library/md5.html#md5.digest_size
""" """
user = models.ForeignKey(User, db_index=True) user = models.ForeignKey(User, db_index=True)
anonymous_user_id = models.CharField(unique=True, max_length=16) anonymous_user_id = models.CharField(unique=True, max_length=32)
course_id = models.CharField(db_index=True, max_length=255) course_id = models.CharField(db_index=True, max_length=255)
unique_together = (user, course_id) unique_together = (user, course_id)
...@@ -73,12 +73,30 @@ def anonymous_id_for_user(user, course_id): ...@@ -73,12 +73,30 @@ def anonymous_id_for_user(user, course_id):
hasher.update(settings.SECRET_KEY) hasher.update(settings.SECRET_KEY)
hasher.update(str(user.id)) hasher.update(str(user.id))
hasher.update(course_id) hasher.update(course_id)
digest = hasher.hexdigest()
return AnonymousUserId.objects.get_or_create( try:
defaults={'anonymous_user_id': hasher.hexdigest()}, anonymous_user_id, created = AnonymousUserId.objects.get_or_create(
defaults={'anonymous_user_id': digest},
user=user, user=user,
course_id=course_id course_id=course_id
)[0].anonymous_user_id )
if anonymous_user_id.anonymous_user_id != digest:
log.error(
"Stored anonymous user id {stored!r} for user {user!r} "
"in course {course!r} doesn't match computed id {digest!r}".format(
user=user,
course=course_id,
stored=anonymous_user_id.anonymous_user_id,
digest=digest
)
)
except IntegrityError:
# Another thread has already created this entry, so
# continue
pass
return digest
def user_by_anonymous_id(id): def user_by_anonymous_id(id):
......
...@@ -22,9 +22,10 @@ ...@@ -22,9 +22,10 @@
<h1>${_("Staff grading")}</h1> <h1>${_("Staff grading")}</h1>
<div class="breadcrumbs"></div> <div class="breadcrumbs"></div>
<div class="error-container"></div> <div class="error-container"></div>
<div class="message-container"></div> <div class="message-container"></div>
<! -- Problem List View --> <!-- Problem List View -->
<section class="problem-list-container"> <section class="problem-list-container">
<h2>${_("Instructions")}</h2> <h2>${_("Instructions")}</h2>
<div class="instructions"> <div class="instructions">
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<section class="container"> <section class="container">
<div class="combined-notifications" data-ajax_url="${ajax_url}"> <div class="combined-notifications" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div> <div class="error-container">${error_text}</div>
<h1>${_("Open Ended Console")}</h1> <h1>${_("Open Ended Console")}</h1>
<h2>${_("Instructions")}</h2> <h2>${_("Instructions")}</h2>
<p>${_("Here are items that could potentially need your attention.")}</p> <p>${_("Here are items that could potentially need your attention.")}</p>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<section class="container"> <section class="container">
<div class="open-ended-problems" data-ajax_url="${ajax_url}"> <div class="open-ended-problems" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div> <div class="error-container">${error_text}</div>
<h1>${_("Flagged Open Ended Problems")}</h1> <h1>${_("Flagged Open Ended Problems")}</h1>
<h2>${_("Instructions")}</h2> <h2>${_("Instructions")}</h2>
<p>${_("Here are a list of open ended problems for this course that have been flagged by students as potentially inappropriate.")}</p> <p>${_("Here are a list of open ended problems for this course that have been flagged by students as potentially inappropriate.")}</p>
......
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