Example #1
0
    def get_events(self):
        """
        Method that returns a list of all the events of bands for which the artist owns the band.
        """
        bands = self.owns.all()

        events_qs = False
        evs_lst = [band.event_set.all() for band in bands]
        events = [
            event for event in QuerySet.union(*evs_lst).order_by('-date')
        ]
        return events
def get_error_queryset(queryset, query, searchBy=None):
    if not searchBy:
        return queryset
    
    qs = QuerySet(model=Error).none()

    queries = query.split(' ')
    search = searchBy + '__icontains'

    for q in queries:
        errors = queryset.filter(**{search: q})
        qs = qs.union(errors)

    return qs
Example #3
0
    def get_mail_list(self, user, match_decision=True):
        case1 = Profile.objects.filter(
            Q(user__matchstatus_hi__user_lo=user)
            & Q(user__matchstatus_hi__user_lo_response=True)
            & Q(user__matchstatus_hi__user_hi_response=match_decision))
        # Case 2: User is user_hi
        case2 = Profile.objects.filter(
            Q(user__matchstatus_lo__user_hi=user)
            & Q(user__matchstatus_lo__user_lo_response=match_decision)
            & Q(user__matchstatus_lo__user_hi_response=True))

        # make distinct
        usion = QuerySet.union(case1, case2)
        return self.get_serializer(usion,
                                   context={
                                       "receiver": user
                                   },
                                   many=True).data
Example #4
0
 def get_queryset(self):
     return QuerySet.union(self.request.user.to_first.all(), self.request.user.to_second.all())