Commit 5bd0442f by cahrens

Merge branch 'master' into feature/christina/metadata-ui

parents 69832c57 2c1b0c83
# pylint: disable=W0401, W0511
# TODO: component.py should explicitly enumerate exports with __all__
from .component import *
# TODO: course.py should explicitly enumerate exports with __all__
from .course import *
# Disable warnings about import from wildcard
# All files below declare exports with __all__
from .assets import *
from .checklist import *
from .component import *
from .course import *
from .error import *
from .item import *
from .preview import *
......
......@@ -59,12 +59,12 @@ def asset_index(request, org, course, name):
asset_display = []
for asset in assets:
id = asset['_id']
asset_id = asset['_id']
display_info = {}
display_info['displayname'] = asset['displayname']
display_info['uploadDate'] = get_default_time_display(asset['uploadDate'].timetuple())
asset_location = StaticContent.compute_location(id['org'], id['course'], id['name'])
asset_location = StaticContent.compute_location(asset_id['org'], asset_id['course'], asset_id['name'])
display_info['url'] = StaticContent.get_url_path_from_location(asset_location)
# note, due to the schema change we may not have a 'thumbnail_location' in the result set
......@@ -171,13 +171,13 @@ def import_course(request, org, course, name):
temp_file.write(chunk)
temp_file.close()
tf = tarfile.open(temp_filepath)
tf.extractall(course_dir + '/')
tar_file = tarfile.open(temp_filepath)
tar_file.extractall(course_dir + '/')
# find the 'course.xml' file
for r, d, f in os.walk(course_dir):
for files in f:
for dirpath, _dirnames, filenames in os.walk(course_dir):
for files in filenames:
if files == 'course.xml':
break
if files == 'course.xml':
......@@ -186,17 +186,17 @@ def import_course(request, org, course, name):
if files != 'course.xml':
return HttpResponse(json.dumps({'ErrMsg': 'Could not find the course.xml file in the package.'}))
logging.debug('found course.xml at {0}'.format(r))
logging.debug('found course.xml at {0}'.format(dirpath))
if r != course_dir:
for fname in os.listdir(r):
shutil.move(r / fname, course_dir)
if dirpath != course_dir:
for fname in os.listdir(dirpath):
shutil.move(dirpath / fname, course_dir)
module_store, course_items = import_from_xml(modulestore('direct'), settings.GITHUB_REPO_ROOT,
[course_subdir], load_error_modules=False,
static_content_store=contentstore(),
target_location_namespace=Location(location),
draft_store=modulestore())
_module_store, course_items = import_from_xml(modulestore('direct'), settings.GITHUB_REPO_ROOT,
[course_subdir], load_error_modules=False,
static_content_store=contentstore(),
target_location_namespace=Location(location),
draft_store=modulestore())
# we can blow this away when we're done importing.
shutil.rmtree(course_dir)
......@@ -234,9 +234,9 @@ def generate_export_course(request, org, course, name):
#filename = root_dir / name + '.tar.gz'
logging.debug('tar file being generated at {0}'.format(export_file.name))
tf = tarfile.open(name=export_file.name, mode='w:gz')
tf.add(root_dir / name, arcname=name)
tf.close()
tar_file = tarfile.open(name=export_file.name, mode='w:gz')
tar_file.add(root_dir / name, arcname=name)
tar_file.close()
# remove temp dir
shutil.rmtree(root_dir / name)
......
......@@ -26,16 +26,22 @@ from models.settings.course_grading import CourseGradingModel
from .requests import get_request_method, _xmodule_recurse
from .access import has_access
# TODO: should explicitly enumerate exports with __all__
# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz'
__all__ = ['OPEN_ENDED_COMPONENT_TYPES',
'ADVANCED_COMPONENT_POLICY_KEY',
'edit_subsection',
'edit_unit',
'assignment_type_update',
'create_draft',
'publish_draft',
'unpublish_unit',
'module_info']
log = logging.getLogger(__name__)
COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video']
OPEN_ENDED_COMPONENT_TYPES = ["combinedopenended", "peergrading"]
ADVANCED_COMPONENT_TYPES = ['annotatable' + 'word_cloud'] + OPEN_ENDED_COMPONENT_TYPES
ADVANCED_COMPONENT_TYPES = ['annotatable', 'word_cloud'] + OPEN_ENDED_COMPONENT_TYPES
ADVANCED_COMPONENT_CATEGORY = 'advanced'
ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules'
......
"""
Views related to operations on course objects
"""
import json
import time
......@@ -10,16 +13,17 @@ from django.core.urlresolvers import reverse
from mitxmako.shortcuts import render_to_response
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError, \
InvalidLocationError
from xmodule.modulestore.exceptions \
import ItemNotFoundError, InvalidLocationError
from xmodule.modulestore import Location
from contentstore.course_info_model import get_course_updates, \
update_course_updates, delete_course_update
from contentstore.utils import get_lms_link_for_item, \
add_open_ended_panel_tab, remove_open_ended_panel_tab
from models.settings.course_details import CourseDetails, \
CourseSettingsEncoder
from contentstore.course_info_model \
import get_course_updates, update_course_updates, delete_course_update
from contentstore.utils \
import get_lms_link_for_item, add_open_ended_panel_tab, \
remove_open_ended_panel_tab
from models.settings.course_details \
import CourseDetails, CourseSettingsEncoder
from models.settings.course_grading import CourseGradingModel
from models.settings.course_metadata import CourseMetadata
from auth.authz import create_all_course_groups
......@@ -30,7 +34,13 @@ from .requests import get_request_method
from .tabs import initialize_course_tabs
from .component import OPEN_ENDED_COMPONENT_TYPES, ADVANCED_COMPONENT_POLICY_KEY
# TODO: should explicitly enumerate exports with __all__
__all__ = ['course_index', 'create_new_course', 'course_info',
'course_info_updates', 'get_course_settings',
'course_config_graders_page',
'course_config_advanced_page',
'course_settings_updates',
'course_grader_updates',
'course_advanced_updates']
@login_required
......@@ -87,8 +97,9 @@ def create_new_course(request):
try:
dest_location = Location('i4x', org, number, 'course', Location.clean(display_name))
except InvalidLocationError as e:
return HttpResponse(json.dumps({'ErrMsg': "Unable to create course '" + display_name + "'.\n\n" + e.message}))
except InvalidLocationError as error:
return HttpResponse(json.dumps({'ErrMsg': "Unable to create course '" +
display_name + "'.\n\n" + error.message}))
# see if the course already exists
existing_course = None
......
......@@ -96,7 +96,7 @@ def preview_module_system(request, preview_id, descriptor):
return ModuleSystem(
ajax_url=reverse('preview_dispatch', args=[preview_id, descriptor.location.url(), '']).rstrip('/'),
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
track_function=lambda type, event: None,
track_function=lambda event_type, event: None,
filestore=descriptor.system.resources_fs,
get_module=partial(get_preview_module, request, preview_id),
render_template=render_from_lms,
......@@ -171,7 +171,7 @@ def get_module_previews(request, descriptor):
descriptor: An XModuleDescriptor
"""
preview_html = []
for idx, (instance_state, shared_state) in enumerate(descriptor.get_sample_state()):
for idx, (_instance_state, _shared_state) in enumerate(descriptor.get_sample_state()):
module = load_preview_module(request, str(idx), descriptor)
preview_html.append(module.get_html())
return preview_html
......@@ -161,7 +161,7 @@ def submit_feedback_via_zendesk(request):
try:
ticket_id = zendesk_api.create_ticket(new_ticket)
except zendesk.ZendeskError as err:
log.error("%s", str(err))
log.error("Error creating Zendesk ticket: %s", str(err))
return HttpResponse(status=500)
# Additional information is provided as a private update so the information
......@@ -170,7 +170,7 @@ def submit_feedback_via_zendesk(request):
try:
zendesk_api.update_ticket(ticket_id, ticket_update)
except zendesk.ZendeskError as err:
log.error("%s", str(err))
log.error("Error updating Zendesk ticket: %s", str(err))
# The update is not strictly necessary, so do not indicate failure to the user
pass
......
......@@ -165,7 +165,7 @@ define('WordCloudMain', ['logme'], function (logme) {
d3.layout.cloud().size([this.width, this.height])
.words(words)
.rotate(function () {
return Math.floor((Math.random() * 2) * 90);
return Math.floor((Math.random() * 2)) * 90;
})
.font('Impact')
.fontSize(function (d) {
......
##
## requires >= 1.3.0 of the Jenkins git plugin
##
function github_status {
gcli status create edx mitx $GIT_COMMIT \
if [[ ! ${GIT_URL} =~ git@github.com:([^/]+)/([^\.]+).git ]]; then
echo "Cannot parse Github org or repo from URL, using defaults."
ORG="edx"
REPO="mitx"
else
ORG=${BASH_REMATCH[1]}
REPO=${BASH_REMATCH[2]}
fi
gcli status create $ORG $REPO $GIT_COMMIT \
--params=$1 \
target_url:$BUILD_URL \
description:"Build #$BUILD_NUMBER is running" \
......
......@@ -4,7 +4,7 @@ set -e
set -x
function github_status {
gcli status create edx mitx $GIT_COMMIT \
gcli status create edx edx-platform $GIT_COMMIT \
--params=$1 \
target_url:$BUILD_URL \
description:"Build #$BUILD_NUMBER $2" \
......
......@@ -33,6 +33,6 @@ PIPELINE_JS['spec'] = {
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
STATICFILES_DIRS.append(COMMON_ROOT / 'test' / 'phantom-jasmine' / 'lib')
STATICFILES_DIRS.append(REPO_ROOT/'node_modules/phantom-jasmine/lib')
INSTALLED_APPS += ('django_jasmine', )
......@@ -61,10 +61,12 @@ urlpatterns = ('', # nopep8
url(r'^heartbeat$', include('heartbeat.urls')),
##
## Only universities without courses should be included here. If
## courses exist, the dynamic profile rule below should win.
##
url(r'^(?i)university_profile/WellesleyX$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'WellesleyX'}),
url(r'^(?i)university_profile/GeorgetownX$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'GeorgetownX'}),
url(r'^(?i)university_profile/McGillX$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'McGillX'}),
url(r'^(?i)university_profile/TorontoX$', 'courseware.views.static_university_profile',
......@@ -73,8 +75,6 @@ urlpatterns = ('', # nopep8
name="static_university_profile", kwargs={'org_id': 'RiceX'}),
url(r'^(?i)university_profile/ANUx$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'ANUx'}),
url(r'^(?i)university_profile/DelftX$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'DelftX'}),
url(r'^(?i)university_profile/EPFLx$', 'courseware.views.static_university_profile',
name="static_university_profile", kwargs={'org_id': 'EPFLx'}),
......
......@@ -3,6 +3,6 @@
"version": "0.1.0",
"dependencies": {
"coffee-script": "1.6.X",
"phantom-jasmine": "0.3.X"
"phantom-jasmine": "0.1.0"
}
}
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