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
from django.conf import settings
from django.contrib.auth.models import User
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.dispatch import receiver, Signal
import django.dispatch
......@@ -52,7 +52,7 @@ class AnonymousUserId(models.Model):
http://docs.python.org/2/library/md5.html#md5.digest_size
"""
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)
unique_together = (user, course_id)
......@@ -73,12 +73,30 @@ def anonymous_id_for_user(user, course_id):
hasher.update(settings.SECRET_KEY)
hasher.update(str(user.id))
hasher.update(course_id)
digest = hasher.hexdigest()
return AnonymousUserId.objects.get_or_create(
defaults={'anonymous_user_id': hasher.hexdigest()},
user=user,
course_id=course_id
)[0].anonymous_user_id
try:
anonymous_user_id, created = AnonymousUserId.objects.get_or_create(
defaults={'anonymous_user_id': digest},
user=user,
course_id=course_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):
......
......@@ -22,9 +22,10 @@
<h1>${_("Staff grading")}</h1>
<div class="breadcrumbs"></div>
<div class="error-container"></div>
<div class="message-container"></div>
<! -- Problem List View -->
<!-- Problem List View -->
<section class="problem-list-container">
<h2>${_("Instructions")}</h2>
<div class="instructions">
......
......@@ -16,6 +16,7 @@
<section class="container">
<div class="combined-notifications" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div>
<h1>${_("Open Ended Console")}</h1>
<h2>${_("Instructions")}</h2>
<p>${_("Here are items that could potentially need your attention.")}</p>
......
......@@ -19,6 +19,7 @@
<section class="container">
<div class="open-ended-problems" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div>
<h1>${_("Flagged Open Ended Problems")}</h1>
<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>
......
......@@ -48,4 +48,4 @@
%endif
%endif
</div>
</section>
</section>
\ No newline at end of file
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