diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index b5243f9ab7..55204f19f6 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -51,6 +51,7 @@ from django.dispatch import receiver from functools import partial import comment_client as cc +from django_comment_client.models import Role, Permission import logging @@ -174,7 +175,6 @@ class PendingEmailChange(models.Model): new_email = models.CharField(blank=True, max_length=255, db_index=True) activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) - class CourseEnrollment(models.Model): user = models.ForeignKey(User) course_id = models.CharField(max_length=255, db_index=True) @@ -184,6 +184,16 @@ class CourseEnrollment(models.Model): class Meta: unique_together = (('user', 'course_id'), ) +@receiver(post_save, sender=CourseEnrollment) +def assign_default_role(sender, instance, **kwargs): + if instance.user.is_staff: + role = Role.objects.get_or_create(course_id=instance.course_id, name="Moderator")[0] + else: + role = Role.objects.get_or_create(course_id=instance.course_id, name="Student")[0] + + logging.info("assign_default_role: adding %s as %s" % (instance.user, role)) + instance.user.roles.add(role) + #cache_relation(User.profile) #### Helper methods for use from python manage.py shell. diff --git a/common/lib/xmodule/xmodule/js/src/video/display.coffee b/common/lib/xmodule/xmodule/js/src/video/display.coffee index 8057e003da..ecf9ee1a72 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display.coffee @@ -44,7 +44,7 @@ class @Video fetchMetadata: (url) -> @metadata = {} $.each @videos, (speed, url) => - $.get "http://gdata.youtube.com/feeds/api/videos/#{url}?v=2&alt=jsonc", ((data) => @metadata[data.data.id] = data.data) , 'jsonp' + $.get "https://gdata.youtube.com/feeds/api/videos/#{url}?v=2&alt=jsonc", ((data) => @metadata[data.data.id] = data.data) , 'jsonp' getDuration: -> @metadata[@youtubeId()].duration diff --git a/lms/djangoapps/django_comment_client/__init__.py b/lms/djangoapps/django_comment_client/__init__.py index 61f59d6f9b..e69de29bb2 100644 --- a/lms/djangoapps/django_comment_client/__init__.py +++ b/lms/djangoapps/django_comment_client/__init__.py @@ -1,2 +0,0 @@ -# call some function from permissions so that the post_save hook is imported -from permissions import assign_default_role diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index dd9da857c6..280e6d2780 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -51,7 +51,7 @@ def ajax_content_response(request, course_id, content, template_name): 'content': content, } html = render_to_string(template_name, context) - user_info = cc.User.from_django_user(request.user).to_dict() + user_info = cc.User.from_django_user(request.user).safe_attributes() annotated_content_info = utils.get_annotated_content_info(course_id, content, request.user, user_info) return JsonResponse({ 'html': html, diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index eda574cb6e..38f8fa985d 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -64,7 +64,7 @@ def render_discussion(request, course_id, threads, *args, **kwargs): 'user': (lambda: reverse('django_comment_client.forum.views.user_profile', args=[course_id, user_id])), }[discussion_type]() - user_info = cc.User.from_django_user(request.user).to_dict() + user_info = cc.User.from_django_user(request.user).safe_attributes() def infogetter(thread): return utils.get_annotated_content_infos(course_id, thread, request.user, user_info) @@ -176,7 +176,7 @@ def render_single_thread(request, discussion_id, course_id, thread_id): thread = cc.Thread.find(thread_id).retrieve(recursive=True).to_dict() - user_info = cc.User.from_django_user(request.user).to_dict() + user_info = cc.User.from_django_user(request.user).safe_attributes() annotated_content_info = utils.get_annotated_content_infos(course_id, thread=thread, user=request.user, user_info=user_info) @@ -194,7 +194,7 @@ def single_thread(request, course_id, discussion_id, thread_id): if request.is_ajax(): - user_info = cc.User.from_django_user(request.user).to_dict() + user_info = cc.User.from_django_user(request.user).safe_attributes() thread = cc.Thread.find(thread_id).retrieve(recursive=True) annotated_content_info = utils.get_annotated_content_infos(course_id, thread, request.user, user_info=user_info) context = {'thread': thread.to_dict(), 'course_id': course_id} diff --git a/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py b/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py index 148c204acf..d1244a6690 100644 --- a/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py +++ b/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py @@ -6,9 +6,7 @@ Enrollments. """ from django.core.management.base import BaseCommand, CommandError -from student.models import CourseEnrollment -from django_comment_client.permissions import assign_default_role - +from student.models import CourseEnrollment, assign_default_role class Command(BaseCommand): args = 'course_id' @@ -23,4 +21,4 @@ class Command(BaseCommand): assign_default_role(None, enrollment) if i % 1000 == 0: print "{0}...".format(i), - print \ No newline at end of file + print diff --git a/lms/djangoapps/django_comment_client/permissions.py b/lms/djangoapps/django_comment_client/permissions.py index ffb676d2c2..9b064a7fef 100644 --- a/lms/djangoapps/django_comment_client/permissions.py +++ b/lms/djangoapps/django_comment_client/permissions.py @@ -1,5 +1,4 @@ from .models import Role, Permission -from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from student.models import CourseEnrollment @@ -8,16 +7,6 @@ import logging from util.cache import cache -@receiver(post_save, sender=CourseEnrollment) -def assign_default_role(sender, instance, **kwargs): - if instance.user.is_staff: - role = Role.objects.get_or_create(course_id=instance.course_id, name="Moderator")[0] - else: - role = Role.objects.get_or_create(course_id=instance.course_id, name="Student")[0] - - logging.info("assign_default_role: adding %s as %s" % (instance.user, role)) - instance.user.roles.add(role) - def cached_has_permission(user, permission, course_id=None): """ Call has_permission if it's not cached. A change in a user's role or diff --git a/lms/djangoapps/heartbeat/views.py b/lms/djangoapps/heartbeat/views.py index 1d053d3da0..956504407b 100644 --- a/lms/djangoapps/heartbeat/views.py +++ b/lms/djangoapps/heartbeat/views.py @@ -1,6 +1,7 @@ import json from datetime import datetime from django.http import HttpResponse +from xmodule.modulestore.django import modulestore def heartbeat(request): @@ -8,6 +9,7 @@ def heartbeat(request): Simple view that a loadbalancer can check to verify that the app is up """ output = { - 'date': datetime.now().isoformat() + 'date': datetime.now().isoformat(), + 'courses': [course.location.url() for course in modulestore().get_courses()], } return HttpResponse(json.dumps(output, indent=4)) diff --git a/lms/lib/comment_client/user.py b/lms/lib/comment_client/user.py index ae4abf91b7..1f61e9d625 100644 --- a/lms/lib/comment_client/user.py +++ b/lms/lib/comment_client/user.py @@ -33,6 +33,16 @@ class User(models.Model): params = {'source_type': source.type, 'source_id': source.id} response = perform_request('delete', _url_for_subscription(self.id), params) + # TODO this is a hack to compensate for the fact that synchronization isn't + # happening properly. + def safe_attributes(self): + try: + return self.to_dict() + except: + self.save() + self._retrieve() + return self.to_dict() + def vote(self, voteable, value): if voteable.type == 'thread': url = _url_for_vote_thread(voteable.id) diff --git a/lms/static/maintenance/css/base.css b/lms/static/maintenance/css/base.css new file mode 100644 index 0000000000..e514c7fdf7 --- /dev/null +++ b/lms/static/maintenance/css/base.css @@ -0,0 +1,26 @@ +html, body { + height: 100%; + background: -webkit-radial-gradient(center, #fff, #e6e6e6); + background: -moz-radial-gradient(center, #fff, #e6e6e6); + background: -ms-radial-gradient(center, #fff, #e6e6e6); + background: -o-radial-gradient(center, #fff, #e6e6e6); +} + +body { + font-family: 'Open Sans', sans-serif; + font-weight: 300; +} + +.legos { + width: 693px; + height: 327px; + margin: 0 auto 50px auto; + padding-top: 150px; +} + +h1 { + font-size: 22px; + line-height: 36px; + color: #666; + text-align: center; +} \ No newline at end of file diff --git a/lms/static/maintenance/css/reset.css b/lms/static/maintenance/css/reset.css new file mode 100644 index 0000000000..57a3be8506 --- /dev/null +++ b/lms/static/maintenance/css/reset.css @@ -0,0 +1,49 @@ +@charset "UTF-8"; +/* CSS Document */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-weight: inherit; + font-style: inherit; + font-size: 100%; + font-family: inherit; + vertical-align: baseline; +} +/* remember to define focus styles! */ +:focus { + outline: 0; +} +body { + line-height: 1; + color: black; + background: white; +} +ol, ul { + list-style: none; +} +/* tables still need 'cellspacing="0"' in the markup */ +table { + border-collapse: separate; + border-spacing: 0; +} +caption, th, td { + text-align: left; + font-weight: normal; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ""; +} +blockquote, q { + quotes: "" ""; +} \ No newline at end of file diff --git a/lms/static/maintenance/images/edx-legos.png b/lms/static/maintenance/images/edx-legos.png new file mode 100644 index 0000000000..fefb13ec63 Binary files /dev/null and b/lms/static/maintenance/images/edx-legos.png differ diff --git a/lms/static/maintenance/index.html b/lms/static/maintenance/index.html new file mode 100644 index 0000000000..eeaa7b7b0b --- /dev/null +++ b/lms/static/maintenance/index.html @@ -0,0 +1,21 @@ + + + + + + + + + + +
+ +
+ +

+ We’re busy building a brand new edX.
+ We’ll be right back! +

+ + + \ No newline at end of file