def run_link(self, obj): info = self.model._meta.app_label, self.model._meta.module_name pickled = pickle_encode(obj.query_data) query_hash = get_query_hash(pickled) return u'<span class="nowrap"><a href="%s">%s</a> | <a href="%s">%s</a></span>' % \ (reverse("admin:%s_%s_run" % info, args=(obj.pk,)), _("Run"), reverse("qbe_form", kwargs={'query_hash': query_hash}), _("Edit"))
def qbe_bookmark(request): data = request.GET.get("data", None) if data: query_hash = get_query_hash(data) query_key = "qbe_query_%s" % query_hash request.session[query_key] = pickle_decode(data) return redirect("qbe_results", query_hash) else: return redirect("qbe_form")
def run_view(self, request, object_id, extra_context=None): obj = self.get_object(request, unquote(object_id)) data = obj.query_data pickled = pickle_encode(data) query_hash = get_query_hash(pickled) query_key = "qbe_query_%s" % query_hash if not query_key in request.session: request.session[query_key] = data return redirect("qbe_results", query_hash)
def qbe_proxy(request): if request.POST: data = request.POST.copy() db_alias = request.session.get("qbe_database", "default") formset = QueryByExampleFormSet(data=data, using=db_alias) if formset.is_valid(): pickled = pickle_encode(data) query_hash = get_query_hash(pickled) query_key = "qbe_query_%s" % query_hash request.session[query_key] = data return redirect("qbe_results", query_hash=query_hash) return redirect("qbe_form")