Skip to content

Commit

Permalink
Merge pull request #5107 from edx/adam/resolve-merge-conflicts
Browse files Browse the repository at this point in the history
Adam/resolve merge conflicts
  • Loading branch information
adampalay committed Sep 5, 2014
2 parents 3f8ea64 + 0bd9bc6 commit 58e6dcf
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def course_index(request, course_key):
"""
# A depth of None implies the whole course. The course outline needs this in order to compute has_changes.
# A unit may not have a draft version, but one of its components could, and hence the unit itself has changes.
with modulestore().bulk_operations(course_key):
with modulestore().bulk_temp_noop_operations(course_key): # FIXME
course_module = _get_course_module(course_key, request.user, depth=None)
lms_link = get_lms_link_for_item(course_module.location)
sections = course_module.get_children()
Expand Down
8 changes: 8 additions & 0 deletions common/lib/xmodule/xmodule/modulestore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,14 @@ def bulk_operations(self, course_id):
finally:
self._end_bulk_operation(course_id)

@contextmanager
def bulk_temp_noop_operations(self, course_id):
"""
A hotfix noop b/c old mongo does not properly handle nested bulk operations and does unnecessary work
if the bulk operation only reads data. Replace with bulk_operations once fixed (or don't merge to master)
"""
yield

def _begin_bulk_operation(self, course_id):
"""
Begin a bulk write operation on course_id.
Expand Down
3 changes: 2 additions & 1 deletion common/lib/xmodule/xmodule/modulestore/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def find_path_to_course():
newpath = (next_usage, path)
queue.append((parent, newpath))

with modulestore.bulk_operations(usage_key.course_key):
# FIXME replace with bulk_operations once it's fixed for old mongo
with modulestore.bulk_temp_noop_operations(usage_key.course_key):
if not modulestore.has_item(usage_key):
raise ItemNotFoundError(usage_key)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def test_get_parent_locations_deleted_child(self, default_ms):
# TODO: LMS-11220: Document why draft send count is 5
# TODO: LMS-11220: Document why draft find count is [19, 6]
# TODO: LMS-11220: Document why split find count is [2, 2]
@ddt.data(('draft', [21, 6], 0), ('split', [2, 2], 0))
@ddt.data(('draft', [20, 5], 0), ('split', [17, 6], 0)) # FIXME, replace w/ above when bulk reenabled
@ddt.unpack
def test_path_to_location(self, default_ms, num_finds, num_sends):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ describe "DiscussionThreadView", ->
expect($(".post-body").text()).toEqual(expectedAbbreviation)
expect(DiscussionThreadShowView.prototype.convertMath).toHaveBeenCalled()

it "strips script tags appropriately", ->
DiscussionViewSpecHelper.setNextResponseContent({resp_total: 0, children: []})
longMaliciousBody = new Array(100).join("<script>alert('Until they think warm days will never cease');</script>\n")
@thread.set("body", longMaliciousBody)
maliciousAbbreviation = DiscussionUtil.abbreviateString(@thread.get('body'), 140)

# The nodes' html should be different than the strings, but
# their texts should be the same, indicating that they've been
# properly escaped. To be safe, make sure the string "<script"
# isn't present, either

@view.render()
expect($(".post-body").html()).not.toEqual(maliciousAbbreviation)
expect($(".post-body").text()).toEqual(maliciousAbbreviation)
expect($(".post-body").html()).not.toContain("<script")

@view.expand()
expect($(".post-body").html()).not.toEqual(longMaliciousBody)
expect($(".post-body").text()).toEqual(longMaliciousBody)
expect($(".post-body").html()).not.toContain("<script")

@view.collapse()
expect($(".post-body").html()).not.toEqual(maliciousAbbreviation)
expect($(".post-body").text()).toEqual(maliciousAbbreviation)
expect($(".post-body").html()).not.toContain("<script")

describe "for question threads", ->
beforeEach ->
@thread.set("thread_type", "question")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if Backbone?
if event
event.preventDefault()
@$el.addClass("expanded")
@$el.find(".post-body").html(@model.get("body"))
@$el.find(".post-body").text(@model.get("body"))
@showView.convertMath()
@$el.find(".forum-thread-expand").hide()
@$el.find(".forum-thread-collapse").show()
Expand All @@ -74,7 +74,7 @@ if Backbone?
if event
event.preventDefault()
@$el.removeClass("expanded")
@$el.find(".post-body").html(@getAbbreviatedBody())
@$el.find(".post-body").text(@getAbbreviatedBody())
@showView.convertMath()
@$el.find(".forum-thread-expand").show()
@$el.find(".forum-thread-collapse").hide()
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/model_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def get_child_descriptors(descriptor, depth, descriptor_filter):

return descriptors

with modulestore().bulk_operations(descriptor.location.course_key):
# FIXME
with modulestore().bulk_temp_noop_operations(descriptor.location.course_key):
descriptors = get_child_descriptors(descriptor, depth, descriptor_filter)

return FieldDataCache(descriptors, course_id, user, select_for_update)
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_module_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def setup_modulestore(self, default_ms, num_finds, num_sends):

# TODO: LMS-11220: Document why split find count is 9
# TODO: LMS-11220: Document why mongo find count is 4
@ddt.data((ModuleStoreEnum.Type.mongo, 4, 0), (ModuleStoreEnum.Type.split, 9, 0))
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0), (ModuleStoreEnum.Type.split, 21, 0))
@ddt.unpack
def test_toc_toy_from_chapter(self, default_ms, num_finds, num_sends):
with self.store.default_store(default_ms):
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_toc_toy_from_chapter(self, default_ms, num_finds, num_sends):

# TODO: LMS-11220: Document why split find count is 9
# TODO: LMS-11220: Document why mongo find count is 4
@ddt.data((ModuleStoreEnum.Type.mongo, 4, 0), (ModuleStoreEnum.Type.split, 9, 0))
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0), (ModuleStoreEnum.Type.split, 21, 0))
@ddt.unpack
def test_toc_toy_from_section(self, default_ms, num_finds, num_sends):
with self.store.default_store(default_ms):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ <h2>${_("Coupons List")}</h2>
<tr class="coupons-headings">
<th class="c_code">${_("Code")}</th>
<th class="c_dsc">${_("Description")}</th>
<th class="c_course_id">${_("Course_id")}</th>
<th class="c_discount">${_("Discount (%)")}</th>
<th class="c_count">${_("Count")}</th>
<th class="c_action">${_("Actions")}</th>
Expand All @@ -114,7 +113,6 @@ <h2>${_("Coupons List")}</h2>
%endif
<td>${coupon.code}</td>
<td>${coupon.description}</td>
<td>${coupon.course_id.to_deprecated_string()}</td>
<td>${coupon.percentage_discount}</td>
<td>
${ coupon.couponredemption_set.all().count() }
Expand Down
3 changes: 2 additions & 1 deletion lms/templates/shoppingcart/receipt.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%! from django.utils.translation import ugettext as _ %>
<%! from django.core.urlresolvers import reverse %>
<%! from django.conf import settings %>
<%! from microsite_configuration import microsite %>

<%inherit file="../main.html" />

Expand All @@ -22,7 +23,7 @@ <h2>${_("Thank you for your Purchase!")}</h2>
<section class="wrapper cart-list">
<div class="wrapper-content-main">
<article class="content-main">
<h1>${_(settings.PLATFORM_NAME + " (" + settings.SITE_NAME + ")" + " Electronic Receipt")}</h1>
<h1>${_("{platform_name} ({site_name}) Electronic Receipt").format(platform_name=microsite.get_value('platform_name', settings.PLATFORM_NAME), site_name=microsite.get_value('SITE_NAME', settings.SITE_NAME))}</h1>
<hr />

<table class="order-receipt">
Expand Down

0 comments on commit 58e6dcf

Please sign in to comment.