def get_queryset(self): qs = super(PropertyViewSet, self).get_queryset() user = CuserMiddleware.get_user() if user: if user.is_superuser: return qs.filter(approved=True) else: return qs.filter(agency=get_agency(), approved=True) else: return qs.filter(agency=get_agency(), approved=True)
def get_queryset(self): qs = super(NoteViewSet, self).get_queryset() user = CuserMiddleware.get_user() if user: if user.is_superuser: return qs else: return qs.filter(agency=get_agency()) else: return qs.filter(agency=get_agency())
def get_queryset(self): qs = super(LeadPropertyDetail, self).get_queryset() user = CuserMiddleware.get_user() if user: if user.is_superuser: return qs else: return qs.filter(agency=get_agency()) else: return qs.filter(agency=get_agency())
def get_queryset(self): lead_pk = self.kwargs.get('lead_pk', None) if lead_pk is not None: user = CuserMiddleware.get_user() if user: if user.is_superuser: return LeadProperty.objects.filter(lead__pk=lead_pk) else: return LeadProperty.objects.filter(lead__pk=lead_pk, agency=get_agency()) else: return LeadProperty.objects.filter(lead__pk=lead_pk, agency=get_agency()) return []
def get_queryset(self): qs = super(MessageViewSet, self).get_queryset() user = CuserMiddleware.get_user() if user: if user.is_superuser: return qs.order_by('-processed') else: agency = get_agency() return qs.filter(mailbox=agency.mailbox).order_by('-processed') else: agency = get_agency() return qs.filter(mailbox=agency.mailbox).order_by('-processed')
def get_queryset(self): global db_start db_start = time.time() qs = Lead.objects.select_related('customer').all() source = self.request.QUERY_PARAMS.get('source', None) if source is not None: qs = qs.filter(source__icontains=source) user = CuserMiddleware.get_user() if user: if not user.is_superuser: qs = qs.filter(agency=get_agency()) else: qs = qs.filter(agency=get_agency()) return qs.distinct()