Commit bdab9019 by Brittany Cheng

trying to fix merge conflicts

parents 01623ddb f204e988
...@@ -184,7 +184,7 @@ def get_module(user, request, location, student_module_cache, position=None): ...@@ -184,7 +184,7 @@ def get_module(user, request, location, student_module_cache, position=None):
) )
if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff: if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff:
module.get_html = add_histogram(module.get_html) module.get_html = add_histogram(module.get_html, module)
# If StudentModule for this instance wasn't already in the database, # If StudentModule for this instance wasn't already in the database,
# and this isn't a guest user, create it. # and this isn't a guest user, create it.
......
...@@ -23,8 +23,11 @@ from django.views.decorators.cache import cache_control ...@@ -23,8 +23,11 @@ from django.views.decorators.cache import cache_control
from module_render import toc_for_course, get_module, get_section from module_render import toc_for_course, get_module, get_section
from models import StudentModuleCache from models import StudentModuleCache
from student.models import UserProfile from student.models import UserProfile
<<<<<<< HEAD
from multicourse import multicourse_settings from multicourse import multicourse_settings
=======
>>>>>>> 38dd8f18984df3ab14f5715891af7f984c7f14a7
from django_comment_client.utils import get_discussion_title from django_comment_client.utils import get_discussion_title
from xmodule.modulestore import Location from xmodule.modulestore import Location
......
...@@ -38,7 +38,12 @@ def comment_author_only(fn): ...@@ -38,7 +38,12 @@ def comment_author_only(fn):
return verified_fn return verified_fn
def instructor_only(fn): #TODO add instructor verification def instructor_only(fn): #TODO add instructor verification
return fn def verified_fn(request, *args, **kwargs):
if not request.user.is_staff:
return JsonError("unauthorized")
else:
return fn(request, *args, **kwargs)
return verified_fn
def extract(dic, keys): def extract(dic, keys):
return {k: dic[k] for k in keys} return {k: dic[k] for k in keys}
...@@ -70,7 +75,6 @@ def create_comment(request, course_id, thread_id): ...@@ -70,7 +75,6 @@ def create_comment(request, course_id, thread_id):
attributes = extract(request.POST, ['body']) attributes = extract(request.POST, ['body'])
attributes['user_id'] = request.user.id attributes['user_id'] = request.user.id
attributes['course_id'] = course_id attributes['course_id'] = course_id
print request.POST
if request.POST.get('anonymous', 'false').lower() == 'true': if request.POST.get('anonymous', 'false').lower() == 'true':
attributes['anonymous'] = True attributes['anonymous'] = True
if request.POST.get('autowatch', 'false').lower() == 'true': if request.POST.get('autowatch', 'false').lower() == 'true':
......
...@@ -27,9 +27,9 @@ def render_accordion(request, course, discussion_id): ...@@ -27,9 +27,9 @@ def render_accordion(request, course, discussion_id):
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
} }
return render_to_string('discussion/accordion.html', context) return render_to_string('discussion/_accordion.html', context)
def render_discussion(request, course_id, threads, discussion_id=None, with_search_bar=True, search_text=''): def render_discussion(request, course_id, threads, discussion_id=None, with_search_bar=True, search_text='', template='discussion/_inline.html'):
context = { context = {
'threads': threads, 'threads': threads,
'discussion_id': discussion_id, 'discussion_id': discussion_id,
...@@ -38,12 +38,19 @@ def render_discussion(request, course_id, threads, discussion_id=None, with_sear ...@@ -38,12 +38,19 @@ def render_discussion(request, course_id, threads, discussion_id=None, with_sear
'user_info': comment_client.get_user_info(request.user.id, raw=True), 'user_info': comment_client.get_user_info(request.user.id, raw=True),
'tags': comment_client.get_threads_tags(raw=True), 'tags': comment_client.get_threads_tags(raw=True),
'course_id': course_id, 'course_id': course_id,
'request': request,
} }
return render_to_string('discussion/inline.html', context) return render_to_string(template, context)
def render_inline_discussion(*args, **kwargs):
return render_discussion(template='discussion/_inline.html', *args, **kwargs)
def render_forum_discussion(*args, **kwargs):
return render_discussion(template='discussion/_forum.html', *args, **kwargs)
def inline_discussion(request, course_id, discussion_id): def inline_discussion(request, course_id, discussion_id):
threads = comment_client.get_threads(discussion_id, recursive=False) threads = comment_client.get_threads(discussion_id, recursive=False)
html = render_discussion(request, course_id, threads, discussion_id=discussion_id) html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id)
return HttpResponse(html, content_type="text/plain") return HttpResponse(html, content_type="text/plain")
def render_search_bar(request, course_id, discussion_id=None, text=''): def render_search_bar(request, course_id, discussion_id=None, text=''):
...@@ -54,7 +61,7 @@ def render_search_bar(request, course_id, discussion_id=None, text=''): ...@@ -54,7 +61,7 @@ def render_search_bar(request, course_id, discussion_id=None, text=''):
'text': text, 'text': text,
'course_id': course_id, 'course_id': course_id,
} }
return render_to_string('discussion/search_bar.html', context) return render_to_string('discussion/_search_bar.html', context)
def forum_form_discussion(request, course_id, discussion_id): def forum_form_discussion(request, course_id, discussion_id):
...@@ -70,7 +77,7 @@ def forum_form_discussion(request, course_id, discussion_id): ...@@ -70,7 +77,7 @@ def forum_form_discussion(request, course_id, discussion_id):
context = { context = {
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'course': course, 'course': course,
'content': render_discussion(request, course_id, threads, discussion_id=discussion_id, search_text=search_text), 'content': render_forum_discussion(request, course_id, threads, discussion_id=discussion_id, search_text=search_text),
'accordion': render_accordion(request, course, discussion_id), 'accordion': render_accordion(request, course, discussion_id),
} }
...@@ -97,8 +104,9 @@ def render_single_thread(request, course_id, thread_id): ...@@ -97,8 +104,9 @@ def render_single_thread(request, course_id, thread_id):
'annotated_content_info': json.dumps(get_annotated_content_info(thread=thread, user_id=request.user.id)), 'annotated_content_info': json.dumps(get_annotated_content_info(thread=thread, user_id=request.user.id)),
'tags': comment_client.get_threads_tags(raw=True), 'tags': comment_client.get_threads_tags(raw=True),
'course_id': course_id, 'course_id': course_id,
'request': request,
} }
return render_to_string('discussion/single_thread.html', context) return render_to_string('discussion/_single_thread.html', context)
def single_thread(request, course_id, discussion_id, thread_id): def single_thread(request, course_id, discussion_id, thread_id):
...@@ -131,7 +139,7 @@ def search(request, course_id): ...@@ -131,7 +139,7 @@ def search(request, course_id):
context = { context = {
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'init': '', 'init': '',
'content': render_discussion(request, course_id, threads, search_text=text), 'content': render_forum_discussion(request, course_id, threads, search_text=text),
'accordion': '', 'accordion': '',
'course': course, 'course': course,
} }
......
...@@ -373,6 +373,15 @@ Discussion = ...@@ -373,6 +373,15 @@ Discussion =
Discussion.handleAnchorAndReload(response) Discussion.handleAnchorAndReload(response)
, 'json' , 'json'
handleEndorse = (elem) ->
url = Discussion.urlFor('endorse_comment', id)
endorsed = $local(".discussion-endorse").is(":checked")
$.post url, {endorsed: endorsed}, (response, textStatus) ->
# TODO error handling
Discussion.handleAnchorAndReload(response)
, 'json'
$local(".discussion-reply").click -> $local(".discussion-reply").click ->
handleReply(this) handleReply(this)
...@@ -385,6 +394,9 @@ Discussion = ...@@ -385,6 +394,9 @@ Discussion =
$local(".discussion-vote-down").click -> $local(".discussion-vote-down").click ->
handleVote(this, "down") handleVote(this, "down")
$local(".discussion-endorse").click ->
handleEndorse(this)
$local(".discussion-edit").click -> $local(".discussion-edit").click ->
if $content.hasClass("thread") if $content.hasClass("thread")
handleEditThread(this) handleEditThread(this)
......
...@@ -267,6 +267,12 @@ $discussion_input_width: 90%; ...@@ -267,6 +267,12 @@ $discussion_input_width: 90%;
display: block; display: block;
color: black; color: black;
} }
&.endorsed {
> .discussion-content {
background-color: lightyellow;
}
}
} }
} }
} }
......
<%namespace name="renderer" file="thread.html"/> <%namespace name="renderer" file="_thread.html"/>
<section class="discussion" _id="${discussion_id}"> <section class="discussion" _id="${discussion_id}">
<div class="discussion-non-content"> <div class="discussion-non-content">
......
<%namespace name="renderer" file="_thread.html"/>
<section class="discussion" _id="${discussion_id}">
<div class="discussion-non-content">
<div class="discussion-title-wrapper">
<a class="discussion-title" href="javascript:void(0)">Discussion</a>
</div>
${search_bar}
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
</div>
% for thread in threads:
${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)}
% endfor
</section>
<%!
def escape_quotes(text):
return text.replace('\"', '\\\"').replace("\'", "\\\'")
%>
<script type="text/javascript">
var $$user_info = JSON.parse('${user_info | escape_quotes}');
var $$course_id = "${course_id}";
var $$tags = JSON.parse("${tags | escape_quotes}");
</script>
<%namespace name="renderer" file="thread.html"/> <%namespace name="renderer" file="_thread.html"/>
<section class="discussion"> <section class="discussion">
<a class="discussion-title" href="javascript:void(0)">Discussion</a> <a class="discussion-title" href="javascript:void(0)">Discussion</a>
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
<%def name="render_comments(comments)"> <%def name="render_comments(comments)">
<div class="comments"> <div class="comments">
% for comment in comments: % for comment in comments:
% if comment['endorsed']:
<div class="comment endorsed" _id="${comment['id']}">
% else:
<div class="comment" _id="${comment['id']}"> <div class="comment" _id="${comment['id']}">
% endif
${render_content(comment, "comment")} ${render_content(comment, "comment")}
<div class="comments"> <div class="comments">
${render_comments(comment['children'])} ${render_comments(comment['children'])}
...@@ -76,6 +80,14 @@ ...@@ -76,6 +80,14 @@
% if type == "thread" and kwargs['edit_thread'] or type == "comment": % if type == "thread" and kwargs['edit_thread'] or type == "comment":
${render_link("discussion-link discussion-reply", "Reply")} ${render_link("discussion-link discussion-reply", "Reply")}
${render_link("discussion-link discussion-edit", "Edit")} ${render_link("discussion-link discussion-edit", "Edit")}
% if type == "comment" and request.user.is_staff:
% if content['endorsed']:
<input type="checkbox" checked="checked" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}">
% else:
<input type="checkbox" class="discussion-link discussion-endorse" id="discussion-endorse-${content['id']}">
% endif
<label class="discussion-link" for="discussion-endorse-${content['id']}">Endorsed</label>
% endif
% endif % endif
</div> </div>
</%def> </%def>
......
...@@ -137,8 +137,9 @@ $(function() { ...@@ -137,8 +137,9 @@ $(function() {
total = section['section_total'].possible total = section['section_total'].possible
percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 and total > 0 else "" percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 and total > 0 else ""
%> %>
<h3><a href="${reverse('courseware_section', kwargs={'course_id' : course.id, 'chapter' : chapter['chapter'], 'section' : section['section']})}"> <h3><a href="${reverse('courseware_section', kwargs={'course_id' : course.id, 'chapter' : chapter['chapter'], 'section' : section['section']})}">
>>>>>>> 7f2f47597fd50acbab49be5173b76b026ff4378d
${ section['section'] }</a> ${"({0:.3n}/{1:.3n}) {2}".format( float(earned), float(total), percentageString )}</h3> ${ section['section'] }</a> ${"({0:.3n}/{1:.3n}) {2}".format( float(earned), float(total), percentageString )}</h3>
${section['format']} ${section['format']}
%if 'due' in section and section['due']!="": %if 'due' in section and section['due']!="":
......
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