Files
edx-platform/lms/djangoapps/dashboard/management/commands/git_add_course.py
Calen Pennington cd746bf8e5 Make course ids and usage ids opaque to LMS and Studio [partial commit]
This commit adds the non-courseware lms/djangoapps and lms/lib.

These keys are now objects with a limited interface, and the particular
internal representation is managed by the data storage layer (the
modulestore).

For the LMS, there should be no outward-facing changes to the system.
The keys are, for now, a change to internal representation only. For
Studio, the new serialized form of the keys is used in urls, to allow
for further migration in the future.

Co-Author: Andy Armstrong <andya@edx.org>
Co-Author: Christina Roberts <christina@edx.org>
Co-Author: David Baumgold <db@edx.org>
Co-Author: Diana Huang <dkh@edx.org>
Co-Author: Don Mitchell <dmitchell@edx.org>
Co-Author: Julia Hansbrough <julia@edx.org>
Co-Author: Nimisha Asthagiri <nasthagiri@edx.org>
Co-Author: Sarina Canelake <sarina@edx.org>

[LMS-2370]
2014-05-08 12:09:23 -04:00

57 lines
1.9 KiB
Python

"""
Script for importing courseware from git/xml into a mongo modulestore
"""
import logging
from django.core.management.base import BaseCommand, CommandError
from django.utils.translation import ugettext as _
import dashboard.git_import
from dashboard.git_import import GitImportError
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml import XMLModuleStore
log = logging.getLogger(__name__)
class Command(BaseCommand):
"""
Pull a git repo and import into the mongo based content database.
"""
# Translators: A git repository is a place to store a grouping of
# versioned files. A branch is a sub grouping of a repository that
# has a specific version of the repository. A modulestore is the database used
# to store the courses for use on the Web site.
help = ('Usage: '
'git_add_course repository_url [directory to check out into] [repository_branch] '
'\n{0}'.format(_('Import the specified git repository and optional branch into the '
'modulestore and optionally specified directory.')))
def handle(self, *args, **options):
"""Check inputs and run the command"""
if isinstance(modulestore, XMLModuleStore):
raise CommandError('This script requires a mongo module store')
if len(args) < 1:
raise CommandError('This script requires at least one argument, '
'the git URL')
if len(args) > 3:
raise CommandError('Expected no more than three '
'arguments; recieved {0}'.format(len(args)))
rdir_arg = None
branch = None
if len(args) > 1:
rdir_arg = args[1]
if len(args) > 2:
branch = args[2]
try:
dashboard.git_import.add_repo(args[0], rdir_arg, branch)
except GitImportError as ex:
raise CommandError(str(ex))