Commit 630607d3 by ichuang

fix forum management commands (assign_default_role moved); add reload_forum_users

parent 82afc477
......@@ -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'
......
......@@ -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'
......
"""
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment