コード例 #1
0
 def get_queryset(self):
     queryset = models.Team.objects.all().prefetch_related(
         Prefetch('members',
                  queryset=self.get_members_queryset(),
                  to_attr='all_members'))
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('owner_account',
                                            'owner_account__owner')
     return queryset
コード例 #2
0
ファイル: views.py プロジェクト: SixSonatas/SchoolIdolAPI
 def get_queryset(self):
     queryset = models.OwnedCard.objects.all()
     queryset = queryset.filter(Q(owner_account__owner__preferences__private=False) | Q(owner_account__owner__preferences__private=True, owner_account__pk__in=(self.request.user.accounts_set.all() if self.request.user.is_authenticated() else [])))
     if ('expand_card' in self.request.query_params
         or self.request.method == 'PATCH' or self.request.method == 'PUT'):
         queryset = queryset.select_related('card')
     if 'expand_owner' in self.request.query_params:
         queryset = queryset.select_related('owner_account')
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('owner_account', 'owner_account__owner')
     return queryset
コード例 #3
0
ファイル: views.py プロジェクト: SixSonatas/SchoolIdolAPI
 def get_queryset(self):
     queryset = models.EventParticipation.objects.all()
     # do not allow fake account participations
     if self.request.method == 'GET' and 'account' not in self.request.query_params and self.request.resolver_match.url_name.endswith('-list'):
         queryset = queryset.filter(account__fake=False)
     if 'expand_account' in self.request.query_params:
         queryset = queryset.select_related('account')
     if 'expand_event' in self.request.query_params:
         queryset = queryset.select_related('event')
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('account', 'account__owner')
     return queryset
コード例 #4
0
 def get_queryset(self):
     queryset = models.EventParticipation.objects.all()
     # do not allow fake account participations
     if self.request.method == 'GET' and 'account' not in self.request.query_params and self.request.resolver_match.url_name.endswith(
             '-list'):
         queryset = queryset.filter(account__fake=False)
     if 'expand_account' in self.request.query_params:
         queryset = queryset.select_related('account')
     if 'expand_event' in self.request.query_params:
         queryset = queryset.select_related('event')
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('account', 'account__owner')
     return queryset
コード例 #5
0
 def get_queryset(self):
     queryset = models.OwnedCard.objects.all()
     queryset = queryset.filter(
         Q(owner_account__owner__preferences__private=False)
         | Q(owner_account__owner__preferences__private=True,
             owner_account__pk__in=(self.request.user.accounts_set.all(
             ) if self.request.user.is_authenticated() else [])))
     if ('expand_card' in self.request.query_params
             or self.request.method == 'PATCH'
             or self.request.method == 'PUT'):
         queryset = queryset.select_related('card')
     if 'expand_owner' in self.request.query_params:
         queryset = queryset.select_related('owner_account')
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('owner_account',
                                            'owner_account__owner')
     return queryset
コード例 #6
0
ファイル: views.py プロジェクト: SixSonatas/SchoolIdolAPI
 def get_queryset(self):
     queryset = models.Team.objects.all().prefetch_related(Prefetch('members', queryset=self.get_members_queryset(), to_attr='all_members'))
     if api_permissions.shouldSelectOwner(self.request):
         queryset = queryset.select_related('owner_account', 'owner_account__owner')
     return queryset