# 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
                'whether to keep the email address of the --keep record; otherwise the '
                'email address is stomped on by the email address in the --delete record'
            )
        )
        parser.add_argument(
            '-y', '--yes', dest='assume_yes', action='store_true',
            help='whether to skip prompts'
        )

    def handle(self, *args, **options):
        try:
            user_keep = User.objects.get(id=options['keep'])
        except User.DoesNotExist:
            self.stdout.write('User keep=%s does not exist. Exiting.' % options['keep'])
            return 1

        try:
            user_delete = User.objects.get(id=options['delete'])
        except User.DoesNotExist:
            self.stdout.write('User delete=%s does not exist. Exiting.' % options['delete'])
            return 1

        def get_teams(user):
            try:
                return [team.name for team in user.profile.teams.all()]
            except StandupUser.DoesNotExist:
                return 0

        def get_status_count(user):
            try:

# 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

                'whether to keep the email address of the --keep record; otherwise the '
                'email address is stomped on by the email address in the --delete record'
            )
        )
        parser.add_argument(
            '-y', '--yes', dest='assume_yes', action='store_true',
            help='whether to skip prompts'
        )

    def handle(self, *args, **options):
        try:
            user_keep = User.objects.get(id=options['keep'])
        except User.DoesNotExist:
            self.stdout.write('User keep=%s does not exist. Exiting.' % options['keep'])
            return 1

        try:
            user_delete = User.objects.get(id=options['delete'])
        except User.DoesNotExist:
            self.stdout.write('User delete=%s does not exist. Exiting.' % options['delete'])
            return 1

        def get_teams(user):
            try:
                return [team.name for team in user.profile.teams.all()]
            except StandupUser.DoesNotExist:
                return 0

        def get_status_count(user):
            try:

                return StandupUser.objects.get(user=user).statuses.count()