# Path: standup/status/models.py
# class StandupUser(models.Model):
#     """A standup participant--tied to Django's User model."""
#     # Note: User provides "username", "is_superuser", "is_staff" and "email"
#     user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
#     name = models.CharField(max_length=100, blank=True, null=True)
#     slug = models.SlugField(max_length=100, blank=True, null=True, unique=True)
#     irc_nick = models.CharField(
#         max_length=100, blank=True, null=True, unique=True,
#         help_text='IRC nick for this particular user'
#     )
# 
#     class Meta:
#         # ordering = ('user__username',)
#         db_table = 'user'
# 
#     def __str__(self):
#         akas = [aka for aka in [self.slug, self.irc_nick] if aka]
#         return '%s (%s)' % (
#             self.name,
#             ', '.join([':%s' % aka for aka in akas])
#         )
# 
#     def __repr__(self):
#         return '<StandupUser: [{}]>'.format(self.slug)
# 
#     def get_absolute_url(self):
#         try:
#             return reverse('status.user', kwargs={'slug': self.slug})
#         except NoReverseMatch:
#             return ''
# 
#     @property
#     def email(self):
#         return self.user.email
# 
#     def dictify(self):
#         """Returns an OrderedDict of model attributes"""
#         data = OrderedDict()
#         data['id'] = self.id
#         data['name'] = self.name
#         data['slug'] = self.slug
#         data['irc_nick'] = self.irc_nick
#         # FIXME: Should we be providing email addresses publicly via the api?
#         # data['email'] = self.user.email
#         data['is_staff'] = self.user.is_staff
#         return data


from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from standup.status.models import StandupUser
        self.stdout.write('    id:          %s' % user_keep.id)
        self.stdout.write('    username:    %s' % user_keep.username)
        self.stdout.write('    email:       %s' % user_keep.email)
        self.stdout.write('    date_joined: %s' % user_keep.date_joined)
        self.stdout.write('    statuses:    %s' % get_status_count(user_keep))
        self.stdout.write('    teams:       %s' % get_teams(user_keep))
        self.stdout.write('')

        if not options['assume_yes']:
            self.stdout.write('Continue?: y/N')
            cont = input()
            if cont.strip().lower() != 'y':
                self.stdout.write('Exiting.')
                return 1

        # Transfer statuses and profile information
        if not hasattr(user_keep, 'profile'):
            if hasattr(user_delete, 'profile'):
                # Keep has no profile, but delete does, so we transfer it over
                self.stdout.write('Keep has no profile--transferring profile')
                profile = user_delete.profile
                profile.user = user_keep
                profile.save()

        else:
            if hasattr(user_delete, 'profile'):
                # They both have profiles, so transfer all the statuses from delete -> keep
                self.stdout.write('Transfering statuses from delete -> keep')
                for status in user_delete.profile.statuses.all():
                    # NOTE(willkg): 'status.user' is a StandupUser instance

# Path: standup/status/models.py
# class StandupUser(models.Model):
#     """A standup participant--tied to Django's User model."""
#     # Note: User provides "username", "is_superuser", "is_staff" and "email"
#     user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
#     name = models.CharField(max_length=100, blank=True, null=True)
#     slug = models.SlugField(max_length=100, blank=True, null=True, unique=True)
#     irc_nick = models.CharField(
#         max_length=100, blank=True, null=True, unique=True,
#         help_text='IRC nick for this particular user'
#     )
# 
#     class Meta:
#         # ordering = ('user__username',)
#         db_table = 'user'
# 
#     def __str__(self):
#         akas = [aka for aka in [self.slug, self.irc_nick] if aka]
#         return '%s (%s)' % (
#             self.name,
#             ', '.join([':%s' % aka for aka in akas])
#         )
# 
#     def __repr__(self):
#         return '<StandupUser: [{}]>'.format(self.slug)
# 
#     def get_absolute_url(self):
#         try:
#             return reverse('status.user', kwargs={'slug': self.slug})
#         except NoReverseMatch:
#             return ''
# 
#     @property
#     def email(self):
#         return self.user.email
# 
#     def dictify(self):
#         """Returns an OrderedDict of model attributes"""
#         data = OrderedDict()
#         data['id'] = self.id
#         data['name'] = self.name
#         data['slug'] = self.slug
#         data['irc_nick'] = self.irc_nick
#         # FIXME: Should we be providing email addresses publicly via the api?
#         # data['email'] = self.user.email
#         data['is_staff'] = self.user.is_staff
#         return data


# Path: standup/status/management/commands/mergeuser.py
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from standup.status.models import StandupUser

        self.stdout.write('    id:          %s' % user_keep.id)
        self.stdout.write('    username:    %s' % user_keep.username)
        self.stdout.write('    email:       %s' % user_keep.email)
        self.stdout.write('    date_joined: %s' % user_keep.date_joined)
        self.stdout.write('    statuses:    %s' % get_status_count(user_keep))
        self.stdout.write('    teams:       %s' % get_teams(user_keep))
        self.stdout.write('')

        if not options['assume_yes']:
            self.stdout.write('Continue?: y/N')
            cont = input()
            if cont.strip().lower() != 'y':
                self.stdout.write('Exiting.')
                return 1

        # Transfer statuses and profile information
        if not hasattr(user_keep, 'profile'):
            if hasattr(user_delete, 'profile'):
                # Keep has no profile, but delete does, so we transfer it over
                self.stdout.write('Keep has no profile--transferring profile')
                profile = user_delete.profile
                profile.user = user_keep
                profile.save()

        else:
            if hasattr(user_delete, 'profile'):
                # They both have profiles, so transfer all the statuses from delete -> keep
                self.stdout.write('Transfering statuses from delete -> keep')
                for status in user_delete.profile.statuses.all():
                    # NOTE(willkg): 'status.user' is a StandupUser instance

                    status.user = user_keep.profile