def query_export_custom(request): """ Create and serve the CSV file. """ try: content_type = Query.get_content_type(request.GET.get("entity")) except ContentType.DoesNotExist: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to query docs.") if content_type.model_class() not in QueryCondition.RELATION_MAP: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to query docs.") conditions = Query.parse_conditions(content_type, request.GET.get("conditions")) filename = "query_%s_export" % (content_type) try: results = Query.get_queryset(content_type, conditions).visible_by_user(request.user) except FieldError: raise InvalidConditionsError("Conditions URL incorrect: Field does " "not exist. Please refer to query docs.") return _export_query(results, content_type, filename)
def notification_criteria(job_id, criteria, state, health, old_health): if "dependency_query" in criteria: # Makes sure that all the jobs from dependency list also satisfy the # criteria for sending notification. dependency_jobs = Query.get_queryset( ContentType.objects.get_for_model(TestJob), Query.parse_conditions(TestJob._meta.model_name, criteria["dependency_query"]), ).exclude(pk=job_id) if criteria["status"] == "finished": if dependency_jobs.filter(~Q( state=TestJob.STATE_FINISHED)).count(): return False if criteria["status"] == "running": if dependency_jobs.filter(~Q(state=TestJob.STATE_RUNNING)).count(): return False if criteria["status"] == "complete": if dependency_jobs.filter(~Q( health=TestJob.HEALTH_COMPLETE)).count(): return False elif criteria["status"] == "incomplete": if dependency_jobs.filter(~Q( health=TestJob.HEALTH_INCOMPLETE)).count(): return False elif criteria["status"] == "canceled": if dependency_jobs.filter(~Q( health=TestJob.HEALTH_CANCELED)).count(): return False # support special status of finished, otherwise skip to normal if criteria["status"] == "finished": return state == TestJob.STATE_FINISHED if criteria["status"] == "running": return state == TestJob.STATE_RUNNING if criteria["status"] == "complete": const = TestJob.HEALTH_COMPLETE elif criteria["status"] == "incomplete": const = TestJob.HEALTH_INCOMPLETE else: const = TestJob.HEALTH_CANCELED # use normal notification support if health == const: if "type" in criteria: if criteria["type"] == "regression": if (old_health == TestJob.HEALTH_COMPLETE and health == TestJob.HEALTH_INCOMPLETE): return True if criteria["type"] == "progression": if (old_health == TestJob.HEALTH_INCOMPLETE and health == TestJob.HEALTH_COMPLETE): return True else: return True return False
def query_export_custom(request): """ Create and serve the CSV file. """ try: content_type = Query.get_content_type(request.GET.get("entity")) except ContentType.DoesNotExist: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to query docs.") if content_type.model_class() not in QueryCondition.RELATION_MAP: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to query docs.") conditions = Query.parse_conditions( content_type, request.GET.get("conditions")) filename = "query_%s_export" % (content_type) try: results = Query.get_queryset(content_type, conditions).visible_by_user( request.user) except FieldError: raise InvalidConditionsError("Conditions URL incorrect: Field does " "not exist. Please refer to query docs.") return _export_query(results, content_type, filename)
def query_export_custom(request): """ Create and serve the CSV file. """ try: content_type = Query.get_content_type(request.GET.get("entity")) except InvalidContentTypeError as e: messages.error(request, e) raise Http404() if content_type.model_class() not in QueryCondition.RELATION_MAP: messages.error( request, "Wrong table name in entity param. Please refer to query docs.") raise Http404() try: conditions = Query.parse_conditions(content_type, request.GET.get("conditions")) except InvalidConditionsError as e: messages.error(request, e) raise Http404() filename = "query_%s_export" % (content_type) try: results = Query.get_queryset(content_type, conditions).visible_by_user(request.user) except (FieldDoesNotExist, FieldError) as e: messages.error(request, e) raise Http404() return _export_query(results, content_type, filename)
def query_export_custom(request): """ Create and serve the CSV file. """ try: content_type = Query.get_content_type(request.GET.get("entity")) except InvalidContentTypeError as e: messages.error(request, e) raise Http404() if content_type.model_class() not in QueryCondition.RELATION_MAP: messages.error( request, "Wrong table name in entity param. Please refer to query docs.") raise Http404() try: conditions = Query.parse_conditions( content_type, request.GET.get("conditions")) except InvalidConditionsError as e: messages.error(request, e) raise Http404() filename = "query_%s_export" % (content_type) try: results = Query.get_queryset(content_type, conditions).visible_by_user( request.user) except (FieldDoesNotExist, FieldError) as e: messages.error(request, e) raise Http404() return _export_query(results, content_type, filename)
def validate_yaml(yaml_data): if "notify" in yaml_data: if "recipients" in yaml_data["notify"]: for recipient in yaml_data["notify"]["recipients"]: if recipient["to"][ "method"] == NotificationRecipient.EMAIL_STR: if "email" not in recipient[ "to"] and "user" not in recipient["to"]: raise SubmissionException( "No valid user or email address specified.") else: if ("handle" not in recipient["to"] and "user" not in recipient["to"]): raise SubmissionException( "No valid user or IRC handle specified.") if "user" in recipient["to"]: try: User.objects.get(username=recipient["to"]["user"]) except User.DoesNotExist: raise SubmissionException( "%r is not an existing user in LAVA." % recipient["to"]["user"]) elif "email" in recipient["to"]: try: validate_email(recipient["to"]["email"]) except ValidationError: raise SubmissionException( "%r is not a valid email address." % recipient["to"]["email"]) if ("compare" in yaml_data["notify"] and "query" in yaml_data["notify"]["compare"]): query_yaml_data = yaml_data["notify"]["compare"]["query"] if "username" in query_yaml_data: try: query = Query.objects.get( owner__username=query_yaml_data["username"], name=query_yaml_data["name"], ) if query.content_type.model_class() != TestJob: raise SubmissionException( "Only TestJob queries allowed.") except Query.DoesNotExist: raise SubmissionException( "Query ~%s/%s does not exist" % (query_yaml_data["username"], query_yaml_data["name"])) else: # Custom query. if query_yaml_data["entity"] != "testjob": raise SubmissionException("Only TestJob queries allowed.") try: conditions = None if "conditions" in query_yaml_data: conditions = query_yaml_data["conditions"] Query.validate_custom_query(query_yaml_data["entity"], conditions) except Exception as e: raise SubmissionException(e)
def query_add(request): query = Query() query.owner = request.user if request.GET.get("entity"): query.content_type = Query.get_content_type(request.GET.get("entity")) return query_form(request, BreadCrumbTrail.leading_to(query_add), instance=query)
def query_custom(request): try: content_type = Query.get_content_type(request.GET.get("entity")) except InvalidContentTypeError as e: messages.error(request, e) raise Http404() if content_type.model_class() not in QueryCondition.RELATION_MAP: messages.error( request, "Wrong table name in entity param. Please refer to query docs.") raise Http404() try: conditions = Query.parse_conditions(content_type, request.GET.get("conditions")) except InvalidConditionsError as e: messages.error(request, e) raise Http404() view = QueryCustomResultView( content_type=content_type, conditions=conditions, request=request, model=content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[content_type.model_class()] ) try: table = QUERY_CONTENT_TYPE_TABLE[content_type.model_class()]( None, request.user, view.get_table_data() ) except (FieldDoesNotExist, FieldError) as e: messages.error(request, e) raise Http404() config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) template = loader.get_template('lava_results_app/query_custom.html') return HttpResponse(template.render( { 'query_table': table, 'conditions': conditions, 'terms_data': table.prepare_terms_data(view), 'search_data': table.prepare_search_data(view), 'discrete_data': table.prepare_discrete_data(view), 'bread_crumb_trail': BreadCrumbTrail.leading_to(query_custom), 'context_help': ['lava-queries-charts'], }, request=request) )
def query_add(request): query = Query() query.owner = request.user if request.GET.get("entity"): query.content_type = Query.get_content_type(request.GET.get("entity")) return query_form( request, BreadCrumbTrail.leading_to(query_add), instance=query)
def get_query_results(notification): if notification.query_name: query = Query.objects.get(name=notification.query_name, owner=notification.query_owner) # We use query_owner as user here since we show only status. return query.get_results( notification.query_owner)[:notification.QUERY_LIMIT] else: return Query.get_queryset( notification.entity, Query.parse_conditions(notification.entity, notification.conditions), notification.QUERY_LIMIT)
def query_add(request): query = Query() query.owner = request.user if request.GET.get("entity"): query.content_type = ContentType.objects.get( model=request.GET.get("entity"), app_label=_get_app_label_for_model(request.GET.get("entity")) ) return query_form( request, BreadCrumbTrail.leading_to(query_add), instance=query)
def chart_custom(request): content_type = Query.get_content_type(request.GET.get("entity")) chart_type = request.GET.get("type") chart_type_choices = ChartQuery._meta.get_field("chart_type").choices if not chart_type: chart_type = ChartQuery._meta.get_field("chart_type").default else: found = False for choice in chart_type_choices: if chart_type in choice: found = True if not found: raise InvalidChartTypeError( "Wrong chart type param. Please refer to chart docs." ) if content_type.model_class() not in QueryCondition.RELATION_MAP: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to chart docs." ) if content_type.model_class() == TestCase and chart_type == "pass/fail": raise TestCasePassFailChartError( "Chart of TestCase entity cannot be of pass/fail chart type." ) conditions = Query.parse_conditions(content_type, request.GET.get("conditions")) chart = Chart(name="Custom") chart_query = ChartQuery(id=0) chart_query.chart = chart chart_query.chart_type = chart_type chart_data = {} chart_data[0] = chart_query.get_data(request.user, content_type, conditions) template = loader.get_template("lava_results_app/chart_display.html") return HttpResponse( template.render( { "chart": chart, "chart_data": simplejson.dumps(chart_data), "bread_crumb_trail": BreadCrumbTrail.leading_to(chart_custom), "can_admin": False, }, request=request, ) )
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) query_conditions = Query.serialize_conditions( query.querycondition_set.all()) template = loader.get_template("lava_results_app/query_detail.html") return HttpResponse( template.render( { "query": query, "query_conditions": query_conditions, "bread_crumb_trail": BreadCrumbTrail.leading_to( query_detail, username=username, name=name), "context_help": ["lava-queries-charts"], "condition_form": QueryConditionForm(instance=None, initial={ "query": query, "table": query.content_type }), }, request=request, ))
def query_form(request, bread_crumb_trail, instance=None, is_copy=False): if request.method == 'POST': form = QueryForm(request.user, request.POST, instance=instance, is_copy=is_copy) if form.is_valid(): query = form.save() if request.GET.get("conditions"): conditions = Query.parse_conditions( query.content_type, request.GET.get("conditions")) for condition in conditions: condition.query = query condition.save() return HttpResponseRedirect(query.get_absolute_url() + "/+detail") else: form = QueryForm(request.user, instance=instance, is_copy=is_copy) form.fields['owner'].initial = request.user query_name = None if is_copy: query_name = instance.name instance.name = None return render_to_response( 'lava_results_app/query_form.html', { 'bread_crumb_trail': bread_crumb_trail, 'is_copy': is_copy, 'query_name': query_name, 'form': form, }, RequestContext(request))
def query_form(request, bread_crumb_trail, instance=None, is_copy=False): if request.method == 'POST': form = QueryForm(request.user, request.POST, instance=instance, is_copy=is_copy) if form.is_valid(): query = form.save() if request.GET.get("conditions"): conditions = Query.parse_conditions( query.content_type, request.GET.get("conditions")) for condition in conditions: condition.query = query condition.save() return HttpResponseRedirect(query.get_absolute_url() + "/+detail") else: form = QueryForm(request.user, instance=instance, is_copy=is_copy) form.fields['owner'].initial = request.user query_name = None if is_copy: query_name = instance.name instance.name = None template = loader.get_template('lava_results_app/query_form.html') return HttpResponse(template.render( { 'bread_crumb_trail': bread_crumb_trail, 'is_copy': is_copy, 'query_name': query_name, 'form': form, 'context_help': ['lava-queries-charts'], }, request=request))
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) query_conditions = Query.serialize_conditions( query.querycondition_set.all()) template = loader.get_template('lava_results_app/query_detail.html') return HttpResponse( template.render( { 'query': query, 'query_conditions': query_conditions, 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_detail, username=username, name=name), 'context_help': ['lava-queries-charts'], 'condition_form': QueryConditionForm(instance=None, initial={ 'query': query, 'table': query.content_type }), }, request=request))
def chart_custom(request): content_type = Query.get_content_type(request.GET.get("entity")) chart_type = request.GET.get("type") chart_type_choices = ChartQuery._meta.get_field_by_name( 'chart_type')[0].choices if not chart_type: chart_type = ChartQuery._meta.get_field_by_name( 'chart_type')[0].default else: found = False for choice in chart_type_choices: if chart_type in choice: found = True if not found: raise InvalidChartTypeError( "Wrong chart type param. Please refer to chart docs.") if content_type.model_class() not in QueryCondition.RELATION_MAP: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to chart docs.") if content_type.model_class() == TestCase and chart_type == "pass/fail": raise TestCasePassFailChartError( "Chart of TestCase entity cannot be of pass/fail chart type.") conditions = Query.parse_conditions( content_type, request.GET.get("conditions")) chart = Chart(name="Custom") chart_query = ChartQuery(id=0) chart_query.chart = chart chart_query.chart_type = chart_type chart_data = {} chart_data[0] = chart_query.get_data(request.user, content_type, conditions) template = loader.get_template('lava_results_app/chart_display.html') return HttpResponse(template.render( { 'chart': chart, 'chart_data': simplejson.dumps(chart_data), 'bread_crumb_trail': BreadCrumbTrail.leading_to( chart_custom), 'can_admin': False, }, request=request) )
def query_display(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) if not request.user.is_superuser: if not query.is_published and query.owner != request.user: raise PermissionDenied view = QueryResultView( query=query, request=request, model=query.content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[query.content_type.model_class()], ) table = QUERY_CONTENT_TYPE_TABLE[query.content_type.model_class()]( query, request.user, view.get_table_data()) try: config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) except ProgrammingError: raise QueryViewDoesNotExistError( "Query view does not exist. Please contact query owner or system " "administrator.") omitted = [ result.content_object for result in QueryOmitResult.objects.filter(query=query) ] template = loader.get_template("lava_results_app/query_display.html") return HttpResponse( template.render( { "query": query, "entity": query.content_type.model, "conditions": Query.serialize_conditions(query.querycondition_set.all()), "omitted": omitted, "query_table": table, "terms_data": table.prepare_terms_data(view), "search_data": table.prepare_search_data(view), "discrete_data": table.prepare_discrete_data(view), "bread_crumb_trail": BreadCrumbTrail.leading_to( query_display, username=username, name=name), "context_help": ["lava-queries-charts"], }, request=request, ))
def query_custom(request): content_type = Query.get_content_type(request.GET.get("entity")) if content_type.model_class() not in QueryCondition.RELATION_MAP: raise InvalidContentTypeError( "Wrong table name in entity param. Please refer to query docs.") view = QueryCustomResultView( content_type=content_type, conditions=Query.parse_conditions(content_type, request.GET.get("conditions")), request=request, model=content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[content_type.model_class()] ) try: table = QUERY_CONTENT_TYPE_TABLE[content_type.model_class()]( view.get_table_data() ) except FieldError: raise InvalidConditionsError("Conditions URL incorrect: Field does " "not exist. Please refer to query docs.") config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) return render_to_response( 'lava_results_app/query_custom.html', { 'query_table': table, 'terms_data': table.prepare_terms_data(view), 'search_data': table.prepare_search_data(view), 'discrete_data': table.prepare_discrete_data(view), 'bread_crumb_trail': BreadCrumbTrail.leading_to(query_custom), 'context_help': BreadCrumbTrail.leading_to(query_list), }, RequestContext(request) )
def query_display(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) if not request.user.is_superuser: if not query.is_published and query.owner != request.user: raise PermissionDenied view = QueryResultView( query=query, request=request, model=query.content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[query.content_type.model_class()] ) table = QUERY_CONTENT_TYPE_TABLE[query.content_type.model_class()]( query, request.user, view.get_table_data() ) try: config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) except ProgrammingError: raise QueryViewDoesNotExistError( "Query view does not exist. Please contact query owner or system " "administrator.") omitted = [result.content_object for result in QueryOmitResult.objects.filter(query=query)] template = loader.get_template('lava_results_app/query_display.html') return HttpResponse(template.render( { 'query': query, 'entity': query.content_type.model, 'conditions': Query.serialize_conditions( query.querycondition_set.all()), 'omitted': omitted, 'query_table': table, 'terms_data': table.prepare_terms_data(view), 'search_data': table.prepare_search_data(view), 'discrete_data': table.prepare_discrete_data(view), 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_display, username=username, name=name), 'context_help': ['lava-queries-charts'], }, request=request) )
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) query_conditions = Query.serialize_conditions( query.querycondition_set.all()) template = loader.get_template('lava_results_app/query_detail.html') return HttpResponse(template.render( { 'query': query, 'query_conditions': query_conditions, 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_detail, username=username, name=name), 'context_help': ['lava-queries-charts'], 'condition_form': QueryConditionForm( instance=None, initial={'query': query, 'table': query.content_type}), }, request=request) )
def query_form(request, bread_crumb_trail, instance=None, is_copy=False): if request.method == "POST": form = QueryForm(request.user, request.POST, instance=instance, is_copy=is_copy) if form.is_valid(): query = form.save() if request.GET.get("conditions"): conditions = Query.parse_conditions( query.content_type, request.GET.get("conditions")) for condition in conditions: condition.query = query condition.save() return HttpResponseRedirect(query.get_absolute_url() + "/+detail") else: form = QueryForm(request.user, instance=instance, is_copy=is_copy) form.fields["owner"].initial = request.user query_name = None if is_copy: query_name = instance.name instance.name = None template = loader.get_template("lava_results_app/query_form.html") return HttpResponse( template.render( { "bread_crumb_trail": bread_crumb_trail, "is_copy": is_copy, "query_name": query_name, "form": form, "context_help": ["lava-queries-charts"], }, request=request, ))
def create_notification(job, data): # Create notification object. notification = Notification() if "verbosity" in data: notification.verbosity = Notification.VERBOSITY_MAP[data["verbosity"]] if "type" in data["criteria"]: notification.type = Notification.TYPE_MAP[data["criteria"]["type"]] if "compare" in data: if "blacklist" in data["compare"]: notification.blacklist = data["compare"]["blacklist"] if "query" in data["compare"]: query_data = data["compare"]["query"] if "username" in query_data: # DoesNotExist scenario already verified in validate username = query_data["username"] notification.query_owner = User.objects.get(username=username) notification.query_name = query_data["name"] else: # Custom query. notification.entity = Query.get_content_type( query_data["entity"]) if "conditions" in query_data: # Save conditions as a string. conditions = [ "%s%s%s" % (key, Query.CONDITION_DIVIDER, value) for (key, value) in query_data["conditions"].items() ] notification.conditions = Query.CONDITIONS_SEPARATOR.join( conditions) notification.test_job = job notification.template = Notification.DEFAULT_TEMPLATE notification.save() if "recipients" in data: for recipient in data["recipients"]: notification_recipient = NotificationRecipient( notification=notification) notification_recipient.method = NotificationRecipient.METHOD_MAP[ recipient["to"]["method"]] if "user" in recipient["to"]: user = User.objects.get(username=recipient["to"]["user"]) notification_recipient.user = user if "email" in recipient["to"]: notification_recipient.email = recipient["to"]["email"] if "handle" in recipient["to"]: notification_recipient.irc_handle = recipient["to"]["handle"] if "server" in recipient["to"]: notification_recipient.irc_server = recipient["to"]["server"] # Ignore unique constraint violation. with contextlib.suppress(IntegrityError): notification_recipient.save() else: # You can do "callbacks only" without having recipients, in that # case, no notification will be sent. if "callbacks" not in data and "callback" not in data: # But if there's no callback and no recipients then we add a # submitter as a default recipient. # Ignore unique constraint violation. with contextlib.suppress(IntegrityError): notification_recipient = NotificationRecipient.objects.create( user=job.submitter, notification=notification) # Add callbacks. if "callbacks" in data: for callback in data["callbacks"]: create_callback(job, callback, notification) if "callback" in data: create_callback(job, data["callback"], notification)
def make_custom_query(self, entity, conditions, limit=200): """ Name ---- `make_custom_query` (`entity`, `conditions`, `limit`) Description ----------- Construct and run a custom query and return the results. Arguments --------- `entity`: string The entity you want to query `conditions`: string The conditions of the query `limit`: integer Add a limit to the number of results returned. Defaults to 200. Return value ------------ A list of dictionaries containing the query results. The user should be authenticated with a username and token. Example ------- # Get all test jobs submitted by the user 'kernel-ci', and which ended # as 'Incomplete': server.results.make_custom_query("testjob", "testjob__submitter__exact__kernel-ci," "testjob__health__exact__Incomplete") [{ jobXX }, { jobXY }, ...] # Get all test cases in a test suite named 'custom-tests', that failed, # and for whom the job ended after '2017-04-26 00:00:00'. server.results.make_custom_query("testcase", "testsuite__name__exact__1_custom-tests," "testcase__result__exact__Test failed," "testjob__end_time__gt__2017-04-26 00:00:00") [{ testcaseXX }, { testcaseXY }, ...] """ self._authenticate() try: content_type = Query.get_content_type(entity) except InvalidContentTypeError: raise xmlrpclib.Fault( 400, "Wrong table name in entity parameter. " "Please refer to query docs.") if content_type.model_class() not in QueryCondition.RELATION_MAP: raise xmlrpclib.Fault( 400, "Wrong table name in entity parameter. " "Please refer to query docs.") conditions = Query.parse_conditions(content_type, conditions) try: results = Query.get_queryset(content_type, conditions).visible_by_user(self.user) except FieldDoesNotExist: raise xmlrpclib.Fault(400, "Conditions URL incorrect: Field does not exist. " "Please refer to query docs.") return list(results[:limit])
def get_queryset(self): return Query.get_queryset(self.content_type, self.conditions).visible_by_user( self.request.user)
def get_queryset(self): return Query.get_queryset( self.content_type, self.conditions).visible_by_user( self.request.user)
def make_custom_query(self, entity, conditions, limit=200): """ Name ---- `make_custom_query` (`entity`, `conditions`, `limit`) Description ----------- Construct and run a custom query and return the results. Arguments --------- `entity`: string The entity you want to query `conditions`: string The conditions of the query `limit`: integer Add a limit to the number of results returned. Defaults to 200. Return value ------------ A list of dictionaries containing the query results. The user should be authenticated with a username and token. Example ------- # Get all test jobs submitted by the user 'kernel-ci', and which ended # as 'Incomplete': server.results.make_custom_query("testjob", "testjob__submitter__exact__kernel-ci," "testjob__health__exact__Incomplete") [{ jobXX }, { jobXY }, ...] # Get all test cases in a test suite named 'custom-tests', that failed, # and for whom the job ended after '2017-04-26 00:00:00'. server.results.make_custom_query("testcase", "testsuite__name__exact__1_custom-tests," "testcase__result__exact__Test failed," "testjob__end_time__gt__2017-04-26 00:00:00") [{ testcaseXX }, { testcaseXY }, ...] """ self._authenticate() try: content_type = Query.get_content_type(entity) except InvalidContentTypeError: raise xmlrpc.client.Fault( 400, "Wrong table name in entity parameter. " "Please refer to query docs.") if content_type.model_class() not in QueryCondition.RELATION_MAP: raise xmlrpc.client.Fault( 400, "Wrong table name in entity parameter. " "Please refer to query docs.") conditions = Query.parse_conditions(content_type, conditions) try: results = Query.get_queryset(content_type, conditions).visible_by_user(self.user) except FieldDoesNotExist: raise xmlrpc.client.Fault( 400, "Conditions URL incorrect: Field does not exist. " "Please refer to query docs.") return list(results[:limit])
def get_queryset(self): return Query.get_results(self.content_type, self.conditions)