Merge branch 'master' into feature/tomg/fall-design
This commit is contained in:
@@ -51,6 +51,7 @@ from django.dispatch import receiver
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import comment_client as cc
|
import comment_client as cc
|
||||||
|
from django_comment_client.models import Role, Permission
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -174,7 +175,6 @@ class PendingEmailChange(models.Model):
|
|||||||
new_email = models.CharField(blank=True, max_length=255, db_index=True)
|
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)
|
activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True)
|
||||||
|
|
||||||
|
|
||||||
class CourseEnrollment(models.Model):
|
class CourseEnrollment(models.Model):
|
||||||
user = models.ForeignKey(User)
|
user = models.ForeignKey(User)
|
||||||
course_id = models.CharField(max_length=255, db_index=True)
|
course_id = models.CharField(max_length=255, db_index=True)
|
||||||
@@ -184,6 +184,16 @@ class CourseEnrollment(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
unique_together = (('user', 'course_id'), )
|
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)
|
#cache_relation(User.profile)
|
||||||
|
|
||||||
#### Helper methods for use from python manage.py shell.
|
#### Helper methods for use from python manage.py shell.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class @Video
|
|||||||
fetchMetadata: (url) ->
|
fetchMetadata: (url) ->
|
||||||
@metadata = {}
|
@metadata = {}
|
||||||
$.each @videos, (speed, url) =>
|
$.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: ->
|
getDuration: ->
|
||||||
@metadata[@youtubeId()].duration
|
@metadata[@youtubeId()].duration
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# call some function from permissions so that the post_save hook is imported
|
|
||||||
from permissions import assign_default_role
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def ajax_content_response(request, course_id, content, template_name):
|
|||||||
'content': content,
|
'content': content,
|
||||||
}
|
}
|
||||||
html = render_to_string(template_name, context)
|
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)
|
annotated_content_info = utils.get_annotated_content_info(course_id, content, request.user, user_info)
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'html': html,
|
'html': html,
|
||||||
|
|||||||
@@ -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])),
|
'user': (lambda: reverse('django_comment_client.forum.views.user_profile', args=[course_id, user_id])),
|
||||||
}[discussion_type]()
|
}[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):
|
def infogetter(thread):
|
||||||
return utils.get_annotated_content_infos(course_id, thread, request.user, user_info)
|
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()
|
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)
|
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():
|
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)
|
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)
|
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}
|
context = {'thread': thread.to_dict(), 'course_id': course_id}
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ Enrollments.
|
|||||||
"""
|
"""
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
from student.models import CourseEnrollment
|
from student.models import CourseEnrollment, assign_default_role
|
||||||
from django_comment_client.permissions import assign_default_role
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
args = 'course_id'
|
args = 'course_id'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from .models import Role, Permission
|
from .models import Role, Permission
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from student.models import CourseEnrollment
|
from student.models import CourseEnrollment
|
||||||
@@ -8,16 +7,6 @@ import logging
|
|||||||
from util.cache import cache
|
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):
|
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
|
Call has_permission if it's not cached. A change in a user's role or
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from xmodule.modulestore.django import modulestore
|
||||||
|
|
||||||
|
|
||||||
def heartbeat(request):
|
def heartbeat(request):
|
||||||
@@ -8,6 +9,7 @@ def heartbeat(request):
|
|||||||
Simple view that a loadbalancer can check to verify that the app is up
|
Simple view that a loadbalancer can check to verify that the app is up
|
||||||
"""
|
"""
|
||||||
output = {
|
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))
|
return HttpResponse(json.dumps(output, indent=4))
|
||||||
|
|||||||
@@ -33,6 +33,16 @@ class User(models.Model):
|
|||||||
params = {'source_type': source.type, 'source_id': source.id}
|
params = {'source_type': source.type, 'source_id': source.id}
|
||||||
response = perform_request('delete', _url_for_subscription(self.id), params)
|
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):
|
def vote(self, voteable, value):
|
||||||
if voteable.type == 'thread':
|
if voteable.type == 'thread':
|
||||||
url = _url_for_vote_thread(voteable.id)
|
url = _url_for_vote_thread(voteable.id)
|
||||||
|
|||||||
26
lms/static/maintenance/css/base.css
Normal file
26
lms/static/maintenance/css/base.css
Normal file
@@ -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;
|
||||||
|
}
|
||||||
49
lms/static/maintenance/css/reset.css
Normal file
49
lms/static/maintenance/css/reset.css
Normal file
@@ -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: "" "";
|
||||||
|
}
|
||||||
BIN
lms/static/maintenance/images/edx-legos.png
Normal file
BIN
lms/static/maintenance/images/edx-legos.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
21
lms/static/maintenance/index.html
Normal file
21
lms/static/maintenance/index.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
|
||||||
|
<link rel="stylesheet" href="css/reset.css">
|
||||||
|
<link rel="stylesheet" href="css/base.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="legos">
|
||||||
|
<img src="images/edx-legos.png" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
We’re busy building a brand new edX.<br />
|
||||||
|
We’ll be right back!
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user