Exemplo n.º 1
0
 def render_with_sql(self, request, query, run_query=True, error=None):
     rows = url_get_rows(request)
     context = query_viewmodel(
         request.user,
         query,
         title="Playground",
         run_query=run_query,
         error=error,
         rows=rows,
     )
     context.update({"no_jquery": True})
     return self.render_template("reports/playground.html", context)
Exemplo n.º 2
0
 def get(self, request, query_id):
     query, form = QueryView.get_instance_and_form(request, query_id)
     query.save()  # updates the modified date
     show = url_get_show(request)
     rows = url_get_rows(request)
     vm = query_viewmodel(request.user,
                          query,
                          form=form,
                          run_query=show,
                          rows=rows)
     fullscreen = url_get_fullscreen(request)
     template = 'fullscreen' if fullscreen else 'query'
     return self.render_template(f'explorer/{template}.html', vm)
Exemplo n.º 3
0
 def post(self, request, query_id):
     if not app_settings.EXPLORER_PERMISSION_CHANGE(request):
         return HttpResponseRedirect(
             reverse_lazy('query_detail', kwargs={'query_id': query_id}))
     show = url_get_show(request)
     query, form = QueryView.get_instance_and_form(request, query_id)
     success = form.is_valid() and form.save()
     vm = query_viewmodel(request.user,
                          query,
                          form=form,
                          run_query=show,
                          rows=url_get_rows(request),
                          message="Query saved." if success else None)
     return self.render_template('explorer/query.html', vm)
Exemplo n.º 4
0
 def render_with_sql(self, request, query, run_query=True, error=None):
     rows = url_get_rows(request)
     fullscreen = url_get_fullscreen(request)
     template = 'fullscreen' if fullscreen else 'play'
     form = QueryForm(request.POST if len(request.POST) else None,
                      instance=query)
     return self.render_template(
         f'explorer/{template}.html',
         query_viewmodel(request.user,
                         query,
                         title="Playground",
                         run_query=run_query,
                         error=error,
                         rows=rows,
                         form=form))