Exemplo n.º 1
0
    def to_representation(self, instance):
        ret = super().to_representation(instance)

        # UI Expectation
        expectation = {
            'totalDashboards':
            Dashboard.objects.filter(user_id=ret['id']).count(),
            'totalGroups': instance.groups.filter(stack_default=False).count(),
            'totalStacks': len(Person.get_directly_assigned_stacks(instance)),
            'totalWidgets': instance.personwidgetdefinition_set.count(),
        }

        ret.update(expectation)
        return ret
Exemplo n.º 2
0
 def test_get_stacks_for_user(self):
     stacks = len(Person.get_directly_assigned_stacks(self.admin_user))
     self.assertGreaterEqual(stacks, 2)