a place to start for the user profiel & fixed some bugs
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
import comment_client
|
||||
import comment_client as cc
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -15,8 +15,5 @@ service'''
|
||||
|
||||
def handle(self, *args, **options):
|
||||
for user in User.objects.all().iterator():
|
||||
comment_client.update_user(user.id, {
|
||||
'id': user.id,
|
||||
'username': user.username,
|
||||
'email': user.email
|
||||
})
|
||||
cc_user = cc.User.from_django_user(user)
|
||||
cc_user.save()
|
||||
|
||||
@@ -50,7 +50,7 @@ from django.dispatch import receiver
|
||||
|
||||
from functools import partial
|
||||
|
||||
import comment_client
|
||||
import comment_client as cc
|
||||
|
||||
import logging
|
||||
|
||||
@@ -265,16 +265,9 @@ def add_user_to_default_group(user, group):
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def update_user_information(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
func = comment_client.create_user
|
||||
else:
|
||||
func = partial(comment_client.update_user, user_id=instance.id)
|
||||
try:
|
||||
func(attributes={
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'email': instance.email,
|
||||
})
|
||||
cc_user = cc.User.from_django_user(instance)
|
||||
cc_user.save()
|
||||
except Exception as e:
|
||||
log = logging.getLogger("mitx.discussion")
|
||||
log.error(unicode(e))
|
||||
|
||||
Reference in New Issue
Block a user