예제 #1
0
 def get(self, request):
     """
     Fetch the specified Allocation
     """
     user = request.user
     allocation_results = []
     memberships = only_active_memberships(user)
     for membership in memberships:
         strat = AllocationStrategy.objects.get(
             provider=membership.identity.provider)
         allocation_result = strat.execute(
             membership.identity, membership.allocation)
         allocation_results.append(allocation_result)
     serialized_data = AllocationResultSerializer(
         allocation_results, many=True).data
     return Response(serialized_data)
예제 #2
0
 def current_identity_memberships(self):
     return self.identity_memberships.filter(only_active_memberships())
예제 #3
0
파일: group.py 프로젝트: j143-zz/atmosphere
 def current_identity_memberships(self):
     return self.identity_memberships.filter(only_active_memberships())
예제 #4
0
 def current_providers(self):
     provider_ids = self.identity_memberships.filter(
         only_active_memberships()).values_list('identity__provider',
                                                flat=True)
     return Provider.objects.filter(id__in=provider_ids)
예제 #5
0
 def current_identities(self):
     identity_ids = self.identity_memberships.filter(
         only_active_memberships()).values_list('identity', flat=True)
     return Identity.objects.filter(only_current_provider(),
                                    only_active_provider(),
                                    id__in=identity_ids)
예제 #6
0
 def is_active(self, user=None):
     if user:
         return self.identity_memberships.filter(
             only_active_memberships(), member__user=user).count() > 0
     return self.provider.is_active()
예제 #7
0
 def is_active(self, user=None):
     if user:
         return self.identity_memberships.filter(
             only_active_memberships(),
             member__user=user).count() > 0
     return self.provider.is_active()
예제 #8
0
 def current_providers(self):
     provider_ids = self.identity_memberships.filter(
             only_active_memberships()).values_list('identity__provider',flat=True)
     return Provider.objects.filter(id__in=provider_ids)
예제 #9
0
 def current_identities(self):
     identity_ids = self.identity_memberships.filter(
             only_active_memberships()).values_list('identity',flat=True)
     return Identity.objects.filter(only_current_provider(), only_active_provider(), id__in=identity_ids)