Ejemplo n.º 1
0
    def calc(self, start, end):
        user_data = []
        for grp in self.groups:
            try:
                group_user = User.objects.get(username="******" + grp)
            except User.DoesNotExist:
                continue

            for user in group_user.users_in_group():
                existing_user = \
                    [x for x in user_data
                     if x['user'].username == user.username]
                if existing_user:
                    # This user is already in our user_data list. This means
                    # they belong to more than one group that we're reporting
                    # on. In this case, it's safe to just skip this duplicate
                    # entry.
                    continue

                user_time = user.interval_time(start, end)
                group_name = InGroup.verbose_name(group_user.fullname)
                group_username = group_user.username
                user_data.append(dict(user=user, user_time=user_time,
                                      group_name=group_name,
                                      group_username=group_username))

        return dict(users=user_data)
Ejemplo n.º 2
0
 def test_verbose_name(self):
     self.assertEqual(
         InGroup.verbose_name('Test group abc (group)'),
         'Test Group Abc')
Ejemplo n.º 3
0
 def test_verbose_name(self):
     self.assertEqual(InGroup.verbose_name('Test group abc (group)'),
                      'Test Group Abc')
Ejemplo n.º 4
0
def verbose_group_name(group_user):
    """Given a group's UserProfile, return its name."""
    return InGroup.verbose_name(group_user.fullname)
Ejemplo n.º 5
0
 def __init__(self, groups):
     groupnames = ['grp_' + x for x in groups]
     self.groups = User.objects.filter(username__in=groupnames)
     self.groupnames = [InGroup.verbose_name(x.fullname)
                        for x in self.groups]