fix forum management commands (assign_default_role moved); add reload_forum_users

This commit is contained in:
ichuang
2013-02-05 00:21:04 +00:00
parent 82afc477fa
commit 630607d345
3 changed files with 33 additions and 2 deletions

View File

@@ -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'

View File

@@ -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'

View File

@@ -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)