Merge pull request #1424 from MITx/feature/ichuang/fix-forum-management-commands
fix forum management commands (assign_default_role was moved)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user