From c72b0bb293d109b9cfca0d595f865ba96080949e Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 9 May 2014 15:31:20 -0400 Subject: [PATCH] Resolve merge conflicts relative to master --- cms/djangoapps/contentstore/views/item.py | 16 +-------- .../views/tests/test_container.py | 5 --- .../contentstore/views/tests/test_tabs.py | 7 +--- .../xmodule/modulestore/mongo/draft.py | 6 +--- .../management/commands/gen_cert_report.py | 13 ++----- lms/djangoapps/certificates/queue.py | 6 ---- lms/djangoapps/certificates/views.py | 7 +--- lms/djangoapps/courseware/module_render.py | 8 ----- .../courseware/tests/test_module_render.py | 6 +--- lms/djangoapps/instructor/views/api.py | 3 -- .../instructor/views/instructor_dashboard.py | 14 ++------ lms/djangoapps/instructor/views/legacy.py | 36 ++++--------------- .../shoppingcart/tests/test_models.py | 10 ------ lms/djangoapps/verify_student/views.py | 16 +++------ 14 files changed, 20 insertions(+), 133 deletions(-) diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 77dd8bb3a1..a8a36f6aec 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -177,14 +177,9 @@ def xblock_view_handler(request, usage_key_string, view_name): accept_header = request.META.get('HTTP_ACCEPT', 'application/json') if 'application/json' in accept_header: -<<<<<<< HEAD store = get_modulestore(usage_key) component = store.get_item(usage_key) -======= - store = get_modulestore(old_location) - component = store.get_item(old_location) is_read_only = _xblock_is_read_only(component) ->>>>>>> edx/master # wrap the generated fragment in the xmodule_editor div so that the javascript # can bind to it correctly @@ -215,12 +210,7 @@ def xblock_view_handler(request, usage_key_string, view_name): html = render_to_string('container_xblock_component.html', { 'xblock_context': context, 'xblock': component, -<<<<<<< HEAD 'locator': usage_key, - 'reordering_enabled': True, -======= - 'locator': locator, ->>>>>>> edx/master }) return JsonResponse({ 'html': html, @@ -265,9 +255,6 @@ def xblock_view_handler(request, usage_key_string, view_name): return HttpResponse(status=406) -<<<<<<< HEAD -def _save_item(request, usage_key, data=None, children=None, metadata=None, nullout=None, -======= def _xblock_is_read_only(xblock): """ Returns true if the specified xblock is read-only, meaning that it cannot be edited. @@ -279,8 +266,7 @@ def _xblock_is_read_only(xblock): return component_publish_state == PublishState.public -def _save_item(request, usage_loc, item_location, data=None, children=None, metadata=None, nullout=None, ->>>>>>> edx/master +def _save_item(request, usage_key, data=None, children=None, metadata=None, nullout=None, grader_type=None, publish=None): """ Saves xblock w/ its fields. Has special processing for grader_type, publish, and nullout and Nones in metadata. diff --git a/cms/djangoapps/contentstore/views/tests/test_container.py b/cms/djangoapps/contentstore/views/tests/test_container.py index f45e4a725a..dbc0aae23a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container.py +++ b/cms/djangoapps/contentstore/views/tests/test_container.py @@ -53,8 +53,6 @@ class ContainerViewTestCase(CourseTestCase): parent_location=published_xblock_with_child.location, category="html", display_name="Child HTML" ) -<<<<<<< HEAD - draft_xblock_with_child = modulestore('draft').convert_to_draft(published_xblock_with_child.location) expected_breadcrumbs = ( r'Unit\s*' @@ -65,9 +63,6 @@ class ContainerViewTestCase(CourseTestCase): unit_location=unicode(self.vertical.location).replace("+", "\\+"), child_vertical_location=unicode(self.child_vertical.location).replace("+", "\\+"), ) -======= - branch_name = "MITx.999.Robot_Super_Course/branch/draft/block" ->>>>>>> edx/master self._test_html_content( published_xblock_with_child, expected_location_in_section_tag=published_xblock_with_child.location, diff --git a/cms/djangoapps/contentstore/views/tests/test_tabs.py b/cms/djangoapps/contentstore/views/tests/test_tabs.py index 79049dd218..63396884f1 100644 --- a/cms/djangoapps/contentstore/views/tests/test_tabs.py +++ b/cms/djangoapps/contentstore/views/tests/test_tabs.py @@ -24,13 +24,8 @@ class TabsPageTests(CourseTestCase): self.url = reverse_course_url('tabs_handler', self.course.id) # add a static tab to the course, for code coverage -<<<<<<< HEAD - ItemFactory.create( - parent_location=self.course.location, -======= self.test_tab = ItemFactory.create( - parent_location=self.course_location, ->>>>>>> edx/master + parent_location=self.course.location, category="static_tab", display_name="Static_1" ) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py index ed4aef1500..d7226e3dc0 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py @@ -147,11 +147,7 @@ class DraftModuleStore(MongoModuleStore): self.refresh_cached_metadata_inheritance_tree(draft_location.course_key) -<<<<<<< HEAD - return self._load_items(source_location.course_key, [original])[0] -======= - return wrap_draft(self._load_items([original])[0]) ->>>>>>> edx/master + return wrap_draft(self._load_items(source_location.course_key, [original])[0]) def update_item(self, xblock, user_id=None, allow_not_found=False, force=False): """ diff --git a/lms/djangoapps/certificates/management/commands/gen_cert_report.py b/lms/djangoapps/certificates/management/commands/gen_cert_report.py index ff83248acd..8d148f0996 100644 --- a/lms/djangoapps/certificates/management/commands/gen_cert_report.py +++ b/lms/djangoapps/certificates/management/commands/gen_cert_report.py @@ -38,20 +38,11 @@ class Command(BaseCommand): def _ended_courses(self): for course_id in [course # all courses in COURSE_LISTINGS -<<<<<<< HEAD - for sub in settings.COURSE_LISTINGS - for course in settings.COURSE_LISTINGS[sub]]: + for sub in settings.COURSE_LISTINGS + for course in settings.COURSE_LISTINGS[sub]]: course = modulestore().get_course(course_id) if course.has_ended(): yield course_id -======= - for sub in settings.COURSE_LISTINGS - for course in settings.COURSE_LISTINGS[sub]]: - course_loc = CourseDescriptor.id_to_location(course_id) - course = modulestore().get_instance(course_id, course_loc) - if course.has_ended(): - yield course_id ->>>>>>> edx/master def handle(self, *args, **options): diff --git a/lms/djangoapps/certificates/queue.py b/lms/djangoapps/certificates/queue.py index ad99f83c0c..dc3c173b33 100644 --- a/lms/djangoapps/certificates/queue.py +++ b/lms/djangoapps/certificates/queue.py @@ -229,16 +229,10 @@ class XQueueCertInterface(object): contents = { 'action': 'create', 'username': student.username, -<<<<<<< HEAD 'course_id': course_id.to_deprecated_string(), - 'name': profile.name, - 'grade': grade['grade'], -======= - 'course_id': course_id, 'course_name': course_name, 'name': profile_name, 'grade': grade_contents, ->>>>>>> edx/master 'template_pdf': template_pdf, } if template_file: diff --git a/lms/djangoapps/certificates/views.py b/lms/djangoapps/certificates/views.py index 762855f2c5..7514f67e71 100644 --- a/lms/djangoapps/certificates/views.py +++ b/lms/djangoapps/certificates/views.py @@ -5,19 +5,14 @@ import logging from django.contrib.auth.models import User from django.http import HttpResponse -<<<<<<< HEAD -import json -from dogapi import dog_stats_api -from xmodule.modulestore.locations import SlashSeparatedCourseKey -======= from django.views.decorators.csrf import csrf_exempt ->>>>>>> edx/master from capa.xqueue_interface import XQUEUE_METRIC_NAME from certificates.models import certificate_status_for_student, CertificateStatuses, GeneratedCertificate from certificates.queue import XQueueCertInterface from xmodule.course_module import CourseDescriptor from xmodule.modulestore.django import modulestore +from xmodule.modulestore.locations import SlashSeparatedCourseKey logger = logging.getLogger(__name__) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 36e1874554..3aae5ea841 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -233,18 +233,10 @@ def get_module_system_for_user(user, field_data_cache, to allow an existing module to be re-bound to a user. Most of the user bindings happen when creating the closures that feed the instantiation of ModuleSystem. -<<<<<<< HEAD - # Do not check access when it's a noauth request. - if getattr(user, 'known', True): - # Short circuit--if the user shouldn't have access, bail without doing any work - if not has_access(user, 'load', descriptor, course_id): - return None -======= The arguments fall into two categories: those that have explicit or implicit user binding, which are user and field_data_cache, and those don't and are just present so that ModuleSystem can be instantiated, which are all the other arguments. Ultimately, this isn't too different than how get_module_for_descriptor_internal was before refactoring. ->>>>>>> edx/master Arguments: see arguments for get_module() diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 093a3e0800..e408677500 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -577,11 +577,7 @@ class ViewInStudioTest(ModuleStoreTestCase): location = course_key.make_usage_key('chapter', 'Overview') descriptor = modulestore().get_item(location) -<<<<<<< HEAD - self._get_module(course_key, descriptor, location) -======= - self.module = self._get_module(course_id, descriptor, location) ->>>>>>> edx/master + self.module = self._get_module(course_key, descriptor, location) @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index a13743ccbb..05f62f04a1 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -1066,14 +1066,11 @@ def send_email(request, course_id): - 'subject' specifies email's subject - 'message' specifies email's content """ -<<<<<<< HEAD course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) -======= if not bulk_email_is_enabled_for_course(course_id): return HttpResponseForbidden("Email is not enabled for this course.") ->>>>>>> edx/master send_to = request.POST.get("send_to") subject = request.POST.get("subject") message = request.POST.get("message") diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index b8f1969f7e..e379739cca 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -26,12 +26,8 @@ from student.models import CourseEnrollment from bulk_email.models import CourseAuthorization from class_dashboard.dashboard_data import get_section_display_name, get_array_section_has_problem -<<<<<<< HEAD -from .tools import get_units_with_due_date, title_or_url -from xmodule.modulestore.locations import SlashSeparatedCourseKey -======= from .tools import get_units_with_due_date, title_or_url, bulk_email_is_enabled_for_course ->>>>>>> edx/master +from xmodule.modulestore.locations import SlashSeparatedCourseKey @ensure_csrf_cookie @@ -66,14 +62,8 @@ def instructor_dashboard_2(request, course_id): sections.insert(3, _section_extensions(course)) # Gate access to course email by feature flag & by course-specific authorization -<<<<<<< HEAD - if settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and \ - is_studio_course and CourseAuthorization.instructor_email_enabled(course_key): + if bulk_email_is_enabled_for_course(course_key): sections.append(_section_send_email(course_key, access, course)) -======= - if bulk_email_is_enabled_for_course(course_id): - sections.append(_section_send_email(course_id, access, course)) ->>>>>>> edx/master # Gate access to Metrics tab by featue flag and staff authorization if settings.FEATURES['CLASS_DASHBOARD'] and access['staff']: diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index e4c9b5b8c2..a81ff1c7f4 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -844,40 +844,23 @@ def instructor_dashboard(request, course_id): email_subject = request.POST.get("subject") html_message = request.POST.get("message") -<<<<<<< HEAD - try: - # Create the CourseEmail object. This is saved immediately, so that - # any transaction that has been pending up to this point will also be - # committed. - email = CourseEmail.create( - course_key.to_deprecated_string(), request.user, email_to_option, email_subject, html_message - ) - - # Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes) - submit_bulk_course_email(request, course_key, email.id) # pylint: disable=E1101 - - except Exception as err: # pylint: disable=broad-except - # Catch any errors and deliver a message to the user - error_msg = "Failed to send email! ({0})".format(err) - msg += "" + error_msg + "" - log.exception(error_msg) -======= - if bulk_email_is_enabled_for_course(course_id): + if bulk_email_is_enabled_for_course(course_key): try: # Create the CourseEmail object. This is saved immediately, so that # any transaction that has been pending up to this point will also be # committed. - email = CourseEmail.create(course_id, request.user, email_to_option, email_subject, html_message) + email = CourseEmail.create( + course_key.to_deprecated_string(), request.user, email_to_option, email_subject, html_message + ) # Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes) - submit_bulk_course_email(request, course_id, email.id) # pylint: disable=E1101 + submit_bulk_course_email(request, course_key, email.id) # pylint: disable=E1101 - except Exception as err: + except Exception as err: # pylint: disable=broad-except # Catch any errors and deliver a message to the user error_msg = "Failed to send email! ({0})".format(err) msg += "" + error_msg + "" log.exception(error_msg) ->>>>>>> edx/master else: # If sending the task succeeds, deliver a success message to the user. @@ -1005,12 +988,7 @@ def instructor_dashboard(request, course_id): # 1. Feature flag is on # 2. We have explicitly enabled email for the given course via django-admin # 3. It is NOT an XML course -<<<<<<< HEAD - if settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and \ - CourseAuthorization.instructor_email_enabled(course_key) and is_studio_course: -======= - if bulk_email_is_enabled_for_course(course_id): ->>>>>>> edx/master + if bulk_email_is_enabled_for_course(course_key): show_email_tab = True # display course stats only if there is no other table to display: diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index ff6ccb6694..a29d963d3e 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -353,13 +353,8 @@ class CertificateItemTest(ModuleStoreTestCase): cart = Order.get_cart_for_user(user=self.user) CertificateItem.add_to_order(cart, self.course_key, self.cost, 'verified') # verify that we are still enrolled -<<<<<<< HEAD self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key)) - self.mock_server_track.reset_mock() -======= - self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_id)) self.mock_tracker.reset_mock() ->>>>>>> edx/master cart.purchase() enrollment = CourseEnrollment.objects.get(user=self.user, course_id=self.course_key) self.assertEquals(enrollment.mode, u'verified') @@ -460,13 +455,8 @@ class CertificateItemTest(ModuleStoreTestCase): cart.purchase() with patch('shoppingcart.models.send_mail', side_effect=smtplib.SMTPException): -<<<<<<< HEAD CourseEnrollment.unenroll(self.user, course_key) - self.assertTrue(error_logger.called) -======= - CourseEnrollment.unenroll(self.user, course_id) self.assertTrue(error_logger.call_args[0][0].startswith('Failed sending email')) ->>>>>>> edx/master def test_refund_cert_callback_after_expiration(self): # If the expiration date has passed, the user cannot get a refund diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 59c12598f9..f0a2673ae3 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -121,7 +121,10 @@ class VerifiedView(View): if CourseEnrollment.enrollment_mode_for_user(request.user, course_id) == 'verified': return redirect(reverse('dashboard')) verify_mode = CourseMode.mode_for_course(course_id, "verified") -<<<<<<< HEAD + + if verify_mode is None: + return redirect(reverse('dashboard')) + chosen_price = request.session.get( "donation_for_course", {} @@ -129,14 +132,6 @@ class VerifiedView(View): course_id.to_deprecated_string(), verify_mode.min_price ) -======= - if verify_mode is None: - return redirect(reverse('dashboard')) - if course_id in request.session.get("donation_for_course", {}): - chosen_price = request.session["donation_for_course"][course_id] - else: - chosen_price = verify_mode.min_price.format("{:g}") ->>>>>>> edx/master course = course_from_id(course_id) context = { @@ -276,10 +271,7 @@ def results_callback(request): # If this is a reverification, log an event if attempt.window: course_id = attempt.window.course_id -<<<<<<< HEAD course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) -======= ->>>>>>> edx/master course = course_from_id(course_id) course_enrollment = CourseEnrollment.get_or_create_enrollment(attempt.user, course_id) course_enrollment.emit_event(EVENT_NAME_USER_REVERIFICATION_REVIEWED_BY_SOFTWARESECURE)