def get_queryset(self): if app_settings.EXPLORER_PERMISSION_VIEW(self.request.user): qs = Query.objects.prefetch_related('created_by_user').all() else: qs = Query.objects.prefetch_related('created_by_user').filter( pk__in=allowed_query_pks(self.request.user.id)) return qs.annotate(run_count=Count('querylog'))
def get_queryset(self): if app_settings.EXPLORER_PERMISSION_VIEW(self.request.user): qs = (Query.objects.prefetch_related('created_by_user', 'querylog_set').all()) else: qs = (Query.objects.prefetch_related( 'created_by_user', 'querylog_set').filter( pk__in=allowed_query_pks(self.request.user.id))) return qs
def wrap(request, *args, **kwargs): if not app_settings.EXPLORER_PERMISSION_VIEW(request.user)\ and not allowed_query_pks(request.user.id): return safe_admin_login_prompt(request) return f(request, *args, **kwargs)
def get_queryset(self): if app_settings.EXPLORER_PERMISSION_VIEW(self.request.user): qs = Query.objects.prefetch_related('created_by_user').all() else: qs = Query.objects.prefetch_related('created_by_user').filter(pk__in=allowed_query_pks(self.request.user.id)) return qs.annotate(run_count=Count('querylog'))
def get_queryset(self): if app_settings.EXPLORER_PERMISSION_VIEW(self.request.user): return Query.objects.prefetch_related('created_by_user').all() else: return Query.objects.prefetch_related('created_by_user').filter(pk__in=allowed_query_pks(self.request.user.id))
def view_permission_list(request): return app_settings.EXPLORER_PERMISSION_VIEW(request.user)\ or allowed_query_pks(request.user.id)