From 55d2800b61df661e7155f8b3cbd30ed047259f43 Mon Sep 17 00:00:00 2001 From: Jayram Date: Sun, 9 Aug 2020 22:16:56 +0530 Subject: [FIX] #546 - create_moderator command if User has no Profile --- yaksh/management/commands/create_moderator.py | 5 +++++ yaksh/models.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'yaksh') diff --git a/yaksh/management/commands/create_moderator.py b/yaksh/management/commands/create_moderator.py index 3ec012e..c0f160a 100644 --- a/yaksh/management/commands/create_moderator.py +++ b/yaksh/management/commands/create_moderator.py @@ -10,6 +10,7 @@ from django.contrib.auth.models import User, Group, Permission # local imports from yaksh.models import create_group +from yaksh.views import _create_or_update_profile class Command(BaseCommand): @@ -43,6 +44,10 @@ class Command(BaseCommand): ) ) else: + if not hasattr(user, 'profile'): + _create_or_update_profile(user, + {'is_email_verified': True} + ) user.profile.is_moderator = True user.profile.save() self.stdout.write( diff --git a/yaksh/models.py b/yaksh/models.py index 6542daa..0765ee8 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1279,7 +1279,7 @@ class Profile(models.Model): super(Profile, self).save(*args, **kwargs) def __str__(self): - return '%s' % (self.user.get_full_name()) + return '%s' % (self.user.get_full_name() or self.user.username) ############################################################################### -- cgit