dump_course_ids.py 830 Bytes
Newer Older
1 2 3 4 5
# pylint: disable=missing-docstring

from optparse import make_option
from textwrap import dedent

Ned Batchelder committed
6
from django.core.management.base import BaseCommand
7

8
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
9 10 11 12 13


class Command(BaseCommand):
    """
    Simple command to dump the course_ids available to the lms.
14 15 16

    Output is UTF-8 encoded by default.

17 18 19 20 21 22 23 24 25 26
    """
    help = dedent(__doc__).strip()
    option_list = BaseCommand.option_list + (
        make_option('--modulestore',
                    action='store',
                    default='default',
                    help='Name of the modulestore to use'),
    )

    def handle(self, *args, **options):
27
        output = u'\n'.join(unicode(course_overview.id) for course_overview in CourseOverview.get_all_courses()) + '\n'
28

29
        return output