From 630607d34554aef03f4e74adbdf26f0dd3b01496 Mon Sep 17 00:00:00 2001 From: ichuang Date: Tue, 5 Feb 2013 00:21:04 +0000 Subject: [PATCH 01/19] fix forum management commands (assign_default_role moved); add reload_forum_users --- .../commands/assign_roles_for_course.py | 3 +- .../commands/create_roles_for_existing.py | 3 +- .../management/commands/reload_forum_users.py | 29 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py diff --git a/lms/djangoapps/django_comment_client/management/commands/assign_roles_for_course.py b/lms/djangoapps/django_comment_client/management/commands/assign_roles_for_course.py index 82f2290bc7..64378108b6 100644 --- a/lms/djangoapps/django_comment_client/management/commands/assign_roles_for_course.py +++ b/lms/djangoapps/django_comment_client/management/commands/assign_roles_for_course.py @@ -6,7 +6,8 @@ Enrollments. """ from django.core.management.base import BaseCommand, CommandError -from student.models import CourseEnrollment, assign_default_role +from student.models import CourseEnrollment +from django_comment_client.models import assign_default_role class Command(BaseCommand): args = 'course_id' diff --git a/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py b/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py index d1244a6690..3ec2d0646e 100644 --- a/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py +++ b/lms/djangoapps/django_comment_client/management/commands/create_roles_for_existing.py @@ -6,7 +6,8 @@ Enrollments. """ from django.core.management.base import BaseCommand, CommandError -from student.models import CourseEnrollment, assign_default_role +from student.models import CourseEnrollment +from django_comment_client.models import assign_default_role class Command(BaseCommand): args = 'course_id' diff --git a/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py b/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py new file mode 100644 index 0000000000..5e7e268270 --- /dev/null +++ b/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py @@ -0,0 +1,29 @@ +""" +Reload forum (comment client) users from existing users. +""" +from django.core.management.base import BaseCommand, CommandError + +from django.contrib.auth.models import User +import comment_client as cc + +class Command(BaseCommand): + help = 'Reload forum (comment client) users from existing users' + + def adduser(self,user): + print user + try: + cc_user = cc.User.from_django_user(user) + cc_user.save() + except Exception as err: + print "update user info to discussion failed for user with id: %s" % user + + def handle(self, *args, **options): + if len(args) != 0: + uset = [User.objects.get(username=x) for x in args] + else: + uset = User.objects.all() + + for user in uset: + self.adduser(user) + + \ No newline at end of file From 14899b90667902aca65732acd942b04f22764b04 Mon Sep 17 00:00:00 2001 From: ichuang Date: Sat, 30 Mar 2013 03:40:40 +0000 Subject: [PATCH 02/19] fix lms migration to be compatible with xblock --- lms/djangoapps/lms_migration/migrate.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/lms_migration/migrate.py b/lms/djangoapps/lms_migration/migrate.py index 569129f469..a677383035 100644 --- a/lms/djangoapps/lms_migration/migrate.py +++ b/lms/djangoapps/lms_migration/migrate.py @@ -39,12 +39,14 @@ def getip(request): def get_commit_id(course): - return course.metadata.get('GIT_COMMIT_ID', 'No commit id') + #return course.metadata.get('GIT_COMMIT_ID', 'No commit id') + return getattr(course, 'GIT_COMMIT_ID', 'No commit id') # getattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID','No commit id') def set_commit_id(course, commit_id): - course.metadata['GIT_COMMIT_ID'] = commit_id + #course.metadata['GIT_COMMIT_ID'] = commit_id + setattr(course, 'GIT_COMMIT_ID', commit_id) # setattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID', new_commit_id) @@ -124,7 +126,8 @@ def manage_modulestores(request, reload_dir=None, commit_id=None): #---------------------------------------- - dumpfields = ['definition', 'location', 'metadata'] + #dumpfields = ['definition', 'location', 'metadata'] + dumpfields = ['location', 'metadata'] for cdir, course in def_ms.courses.items(): html += '
' @@ -133,7 +136,7 @@ def manage_modulestores(request, reload_dir=None, commit_id=None): html += '

commit_id=%s

' % get_commit_id(course) for field in dumpfields: - data = getattr(course, field) + data = getattr(course, field, None) html += '

%s

' % field if type(data) == dict: html += '