def chart_add(request): chart = Chart() chart.owner = request.user return chart_form(request, BreadCrumbTrail.leading_to(chart_add), instance=chart, query_id=request.GET.get("query_id"))
def chart_add(request): chart = Chart() chart.owner = request.user return chart_form( request, BreadCrumbTrail.leading_to(chart_add), instance=chart, query_id=request.GET.get("query_id"))
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, ) )