diff --git a/cms/djangoapps/contentstore/management/commands/check_course.py b/cms/djangoapps/contentstore/management/commands/check_course.py deleted file mode 100644 index 874a2b9a4c..0000000000 --- a/cms/djangoapps/contentstore/management/commands/check_course.py +++ /dev/null @@ -1,65 +0,0 @@ -from django.core.management.base import BaseCommand, CommandError -from xmodule.modulestore.django import modulestore -from xmodule.modulestore.xml_importer import check_module_metadata_editability -from opaque_keys.edx.keys import CourseKey -from opaque_keys import InvalidKeyError -from opaque_keys.edx.locations import SlashSeparatedCourseKey - - -class Command(BaseCommand): - help = '''Enumerates through the course and find common errors''' - - def handle(self, *args, **options): - if len(args) != 1: - raise CommandError("check_course requires one argument: ") - - try: - course_key = CourseKey.from_string(args[0]) - except InvalidKeyError: - course_key = SlashSeparatedCourseKey.from_deprecated_string(args[0]) - - store = modulestore() - - course = store.get_course(course_key, depth=3) - - err_cnt = 0 - - def _xlint_metadata(module): - err_cnt = check_module_metadata_editability(module) - for child in module.get_children(): - err_cnt = err_cnt + _xlint_metadata(child) - return err_cnt - - err_cnt = err_cnt + _xlint_metadata(course) - - # we've had a bug where the xml_attributes field can we rewritten as a string rather than a dict - def _check_xml_attributes_field(module): - err_cnt = 0 - if hasattr(module, 'xml_attributes') and isinstance(module.xml_attributes, basestring): - print 'module = {0} has xml_attributes as a string. It should be a dict'.format(module.location) - err_cnt = err_cnt + 1 - for child in module.get_children(): - err_cnt = err_cnt + _check_xml_attributes_field(child) - return err_cnt - - err_cnt = err_cnt + _check_xml_attributes_field(course) - - # check for dangling discussion items, this can cause errors in the forums - def _get_discussion_items(module): - discussion_items = [] - if module.location.category == 'discussion': - discussion_items = discussion_items + [module.location] - - for child in module.get_children(): - discussion_items = discussion_items + _get_discussion_items(child) - - return discussion_items - - discussion_items = _get_discussion_items(course) - - # now query all discussion items via get_items() and compare with the tree-traversal - queried_discussion_items = store.get_items(course_key=course_key, qualifiers={'category': 'discussion'}) - - for item in queried_discussion_items: - if item.location not in discussion_items: - print 'Found dangling discussion module = {0}'.format(item.location) diff --git a/common/djangoapps/student/management/commands/6002exportusers.py b/common/djangoapps/student/management/commands/6002exportusers.py deleted file mode 100644 index 0cb2b2ffee..0000000000 --- a/common/djangoapps/student/management/commands/6002exportusers.py +++ /dev/null @@ -1,53 +0,0 @@ -## -## One-off script to export 6.002x users into the edX framework -## -## Could be modified to be general by: -## * Changing user_keys and up_keys to handle dates more cleanly -## * Providing a generic set of tables, rather than just users and user profiles -## * Handling certificates and grades -## * Handling merge/forks of UserProfile.meta - - -import datetime -import json - -from django.core.management.base import BaseCommand -from django.contrib.auth.models import User - -from student.models import UserProfile - - -class Command(BaseCommand): - help = """Exports all users and user profiles. -Caveat: Should be looked over before any run -for schema changes. - -Current version grabs user_keys from -django.contrib.auth.models.User and up_keys -from student.userprofile.""" - - def handle(self, *args, **options): - users = list(User.objects.all()) - user_profiles = list(UserProfile.objects.all()) - user_profile_dict = dict([(up.user_id, up) for up in user_profiles]) - - user_tuples = [(user_profile_dict[u.id], u) for u in users if u.id in user_profile_dict] - - user_keys = ['id', 'username', 'email', 'password', 'is_staff', - 'is_active', 'is_superuser', 'last_login', 'date_joined', - 'password'] - up_keys = ['language', 'location', 'meta', 'name', 'id', 'user_id'] - - def extract_dict(keys, object): - d = {} - for key in keys: - item = object.__getattribute__(key) - if type(item) == datetime.datetime: - item = item.isoformat() - d[key] = item - return d - - extracted = [{'up': extract_dict(up_keys, t[0]), 'u':extract_dict(user_keys, t[1])} for t in user_tuples] - fp = open('transfer_users.txt', 'w') - json.dump(extracted, fp) - fp.close() diff --git a/common/djangoapps/student/management/commands/6002importusers.py b/common/djangoapps/student/management/commands/6002importusers.py deleted file mode 100644 index 17b4c2069b..0000000000 --- a/common/djangoapps/student/management/commands/6002importusers.py +++ /dev/null @@ -1,57 +0,0 @@ -## -## One-off script to import 6.002x users into the edX framework -## See export for more info - - -import json - -import dateutil.parser - -from django.core.management.base import BaseCommand -from django.contrib.auth.models import User - -from student.models import UserProfile - - -def import_user(u): - user_info = u['u'] - up_info = u['up'] - - # HACK to handle dates - user_info['last_login'] = dateutil.parser.parse(user_info['last_login']) - user_info['date_joined'] = dateutil.parser.parse(user_info['date_joined']) - - user_keys = ['id', 'username', 'email', 'password', 'is_staff', - 'is_active', 'is_superuser', 'last_login', 'date_joined', - 'password'] - up_keys = ['language', 'location', 'meta', 'name', 'id', 'user_id'] - - u = User() - for key in user_keys: - u.__setattr__(key, user_info[key]) - u.save() - - up = UserProfile() - up.user = u - for key in up_keys: - up.__setattr__(key, up_info[key]) - up.save() - - -class Command(BaseCommand): - help = """Exports all users and user profiles. -Caveat: Should be looked over before any run -for schema changes. - -Current version grabs user_keys from -django.contrib.auth.models.User and up_keys -from student.userprofile.""" - - def handle(self, *args, **options): - extracted = json.load(open('transfer_users.txt')) - n = 0 - for u in extracted: - import_user(u) - if n % 100 == 0: - print n - n = n + 1 diff --git a/common/djangoapps/student/management/commands/emaillist.py b/common/djangoapps/student/management/commands/emaillist.py deleted file mode 100644 index 8a74aafbcf..0000000000 --- a/common/djangoapps/student/management/commands/emaillist.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.core.management.base import BaseCommand -from django.contrib.auth.models import User - - -class Command(BaseCommand): - help = 'Extract an e-mail list of all active students.' - - def handle(self, *args, **options): - #text = open(args[0]).read() - #subject = open(args[1]).read() - users = User.objects.all() - - for user in users: - if user.is_active: - print user.email diff --git a/common/djangoapps/student/management/commands/userinfo.py b/common/djangoapps/student/management/commands/userinfo.py deleted file mode 100644 index bb6ef108a3..0000000000 --- a/common/djangoapps/student/management/commands/userinfo.py +++ /dev/null @@ -1,31 +0,0 @@ -from django.core.management.base import BaseCommand -from django.contrib.auth.models import User - -import json - -from student.models import UserProfile - - -class Command(BaseCommand): - help = """Extract full user information into a JSON file. -Pass a single filename.""" - - def handle(self, *args, **options): - file_output = open(args[0], 'w') - users = User.objects.all() - - data_list = [] - for user in users: - profile = UserProfile.objects.get(user=user) - data = { - 'username': user.username, - 'email': user.email, - 'is_active': user.is_active, - 'joined': user.date_joined.isoformat(), - 'name': profile.name, - 'language': profile.language, - 'location': profile.location, - } - data_list.append(data) - json.dump(data_list, file_output) - file_output.close()