示例#1
0
 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"))
示例#2
0
文件: admin.py 项目: dhan88/qbe
 def run_link(self, obj):
     info = self.model._meta.app_label, self.model._meta.module_name
     pickled = pickle_encode(obj.query_data)
     query_hash = md5(pickled + settings.SECRET_KEY).hexdigest()
     return u'<span class="nowrap"><a href="%s">%s</a> | <a href="%s?hash=%s">%s</a></span>' % \
         (reverse("admin:%s_%s_run" % info, args=(obj.pk,)), _("Run"),
          reverse("qbe_form"), query_hash, _("Edit & Run"))
示例#3
0
 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"))
示例#4
0
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return redirect("qbe_form")
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = getattr(settings, 'QBE_SHOW_ROW_NUMBER', True)
        admin_name = getattr(settings, "QBE_ADMIN", "admin")
        aliases = getattr(settings, 'QBE_ALIASES', False)
        labels = formset.get_labels(row_number=row_number, aliases=aliases)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit,
                                      offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        context = {
            'formset': formset,
            'title': _(u"Query by Example"),
            'results': results,
            'labels': labels,
            #'query': query,
            'count': count,
            'limit': limit,
            'page': page,
            'offset': offset + 1,
            'offset_limit': offset + limit,
            'pickled': pickled,
            'query_hash': query_hash,
            'admin_urls': (admin_name != None and formset.has_admin_urls()),
            'formats': formats,
            'savedqueries_installed': 'django_qbe.savedqueries'
            in settings.INSTALLED_APPS,
            'QBE_MENU_EDIT': getattr(settings, 'QBE_MENU_EDIT', False),
            'QBE_SHOW_BREADCRUMBS': getattr(settings, 'QBE_SHOW_BREADCRUMBS',
                                            True)
        }
        return render(request, 'qbe_results.html', context)
    return redirect("qbe_form")
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
文件: admin.py 项目: dhan88/qbe
 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 = md5(pickled + settings.SECRET_KEY).hexdigest()
     query_key = "qbe_query_%s" % query_hash
     if not query_key in request.session:
         request.session[query_key] = data
     return HttpResponseRedirect(reverse("qbe_results", args=(query_hash, )))
示例#8
0
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return redirect("qbe_form")
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = getattr(settings, 'QBE_SHOW_ROW_NUMBER', True)
        admin_name = getattr(settings, "QBE_ADMIN", "admin")
        aliases = getattr(settings, 'QBE_ALIASES', False)
        labels = formset.get_labels(row_number=row_number, aliases=aliases)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit, offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        context = {
            'formset': formset,
            'title': _(u"Query by Example"),
            'results': results,
            'labels': labels,
            #'query': query,
            'count': count,
            'limit': limit,
            'page': page,
            'offset': offset + 1,
            'offset_limit': offset + limit,
            'pickled': pickled,
            'query_hash': query_hash,
            'admin_urls': (admin_name != None and formset.has_admin_urls()),
            'formats': formats,
            'savedqueries_installed': 'django_qbe.savedqueries' in settings.INSTALLED_APPS,
            'QBE_MENU_EDIT': getattr(settings, 'QBE_MENU_EDIT', False),
            'QBE_SHOW_BREADCRUMBS': getattr(settings, 'QBE_SHOW_BREADCRUMBS', True)
        }
        return render(request, 'qbe_results.html', context)
    return redirect("qbe_form")
示例#9
0
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return HttpResponseRedirect(reverse("qbe_form"))
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = True
        admin_name = getattr(settings, "QBE_ADMIN", "admin")
        labels = formset.get_labels(row_number=row_number)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit,
                                      offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
        return render_to_response('qbe_results.html', {
            'formset': formset,
            'title': _(u"Query by Example"),
            'results': results,
            'labels': labels,
            'query': query,
            'count': count,
            'limit': limit,
            'page': page,
            'offset': offset + 1,
            'offset_limit': offset + limit,
            'pickled': pickled,
            'query_hash': query_hash,
            'admin_urls': (admin_name != None),
            'formats': formats,
            'ADMIN_MEDIA_PREFIX': admin_media_prefix
        },
                                  context_instance=RequestContext(request))
示例#10
0
文件: views.py 项目: pombredanne/qbe
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")
示例#11
0
文件: views.py 项目: maxwell-k/qbe
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")
示例#12
0
文件: views.py 项目: lorenzogil/qbe
def qbe_proxy(request):
    if request.POST:
        data = request.POST.copy()
        formset = QueryByExampleFormSet(data=data)
        if formset.is_valid():
            pickled = pickle_encode(data)
            query_hash = md5(pickled + settings.SECRET_KEY).hexdigest()
            query_key = "qbe_query_%s" % query_hash
            request.session[query_key] = data
            reverse_url = reverse("qbe_results", args=(query_hash, ))
            return HttpResponseRedirect(reverse_url)
    return HttpResponseRedirect(reverse("qbe_form"))
示例#13
0
文件: views.py 项目: CulturePlex/qbe
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return HttpResponseRedirect(reverse("qbe_form"))
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = True
        admin_name = getattr(settings, "QBE_ADMIN", "admin")
        labels = formset.get_labels(row_number=row_number)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit, offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
        return render_to_response('qbe_results.html',
                                  {'formset': formset,
                                   'title': _(u"Query by Example"),
                                   'results': results,
                                   'labels': labels,
                                   'query': query,
                                   'count': count,
                                   'limit': limit,
                                   'page': page,
                                   'offset': offset + 1,
                                   'offset_limit': offset + limit,
                                   'pickled': pickled,
                                   'query_hash': query_hash,
                                   'admin_urls': (admin_name != None),
                                   'formats': formats,
                                   'ADMIN_MEDIA_PREFIX': admin_media_prefix},
                                  context_instance=RequestContext(request))
示例#14
0
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 = md5(pickled + settings.SECRET_KEY).hexdigest()
            query_key = "qbe_query_%s" % query_hash
            request.session[query_key] = data
            reverse_url = reverse("qbe_results", args=(query_hash, ))
            return HttpResponseRedirect(reverse_url)
    return HttpResponseRedirect(reverse("qbe_form"))
示例#15
0
文件: views.py 项目: maxwell-k/qbe
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return redirect("qbe_form")
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = QBE_SHOW_ROW_NUMBER
        admin_name = QBE_ADMIN
        aliases = QBE_ALIASES
        labels = formset.get_labels(row_number=row_number, aliases=aliases)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit,
                                      offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        title_url = reverse("qbe_form")
        saved_query = None
        if QBE_SAVED_QUERIES:
            title_url = reverse("admin:app_list", args=["savedqueries"])
            from django_qbe.savedqueries.models import SavedQuery
            saved_queries = SavedQuery.objects.filter(query_hash=query_hash)
            saved_query = saved_queries.first()
        context = {
            'formset': formset,
            'title': _(u"Query by Example"),
            'title_url': title_url,
            'saved_query': saved_query,
            'results': results,
            'labels': labels,
            'query': query,
            'count': count,
            'limit': limit,
            'page': page,
            'offset': offset + 1,
            'offset_limit': offset + limit,
            'pickled': pickled,
            'query_hash': query_hash,
            'admin_urls': admin_name is not None and formset.has_admin_urls(),
            'formats': formats,
            'savedqueries_installed': QBE_SAVED_QUERIES,
            'aliases_enabled': QBE_ALIASES,
            'group_by_enabled': QBE_GROUP_BY
        }
        return render(request, 'qbe_results.html', context)
    return redirect("qbe_form")
示例#16
0
文件: views.py 项目: agronick/qbe
def qbe_results(request, query_hash):
    query_key = "qbe_query_%s" % (query_hash or "")
    if query_key in request.session:
        query_key = "qbe_query_%s" % query_hash
        data = request.session[query_key]
    else:
        return redirect("qbe_form")
    db_alias = data.get("database_alias", "default")
    if db_alias in DATABASES:
        request.session["qbe_database"] = db_alias
    else:
        db_alias = request.session.get("qbe_database", "default")
    formset = QueryByExampleFormSet(data=data, using=db_alias)
    if formset.is_valid():
        row_number = QBE_SHOW_ROW_NUMBER
        admin_name = QBE_ADMIN
        aliases = QBE_ALIASES
        labels = formset.get_labels(row_number=row_number, aliases=aliases)
        count = formset.get_count()
        limit = count
        try:
            page = int(request.GET.get("p", 0))
        except ValueError:
            page = 0
        if not request.GET.get("show", None):
            try:
                limit = int(data.get("limit", 100))
            except ValueError:
                limit = 100
        offset = limit * page
        results = formset.get_results(limit=limit, offset=offset,
                                      admin_name=admin_name,
                                      row_number=row_number)
        query = formset.get_raw_query(add_params=True)
        pickled = pickle_encode(data)
        title_url = reverse("qbe_form")
        saved_query = None
        if QBE_SAVED_QUERIES:
            title_url = reverse("admin:app_list", args=["savedqueries"])
            from django_qbe.savedqueries.models import SavedQuery
            saved_queries = SavedQuery.objects.filter(query_hash=query_hash)
            saved_query = saved_queries.first()
        context = {
            'formset': formset,
            'title': _(u"Query by Example"),
            'title_url': title_url,
            'saved_query': saved_query,
            'results': results,
            'labels': labels,
            'query': query,
            'count': count,
            'limit': limit,
            'page': page,
            'offset': offset + 1,
            'offset_limit': offset + limit,
            'pickled': pickled,
            'query_hash': query_hash,
            'admin_urls': admin_name is not None and formset.has_admin_urls(),
            'formats': formats,
            'savedqueries_installed': QBE_SAVED_QUERIES,
            'aliases_enabled': QBE_ALIASES,
            'group_by_enabled': QBE_GROUP_BY
        }
        return render(request, 'qbe_results.html', context)
    return redirect("qbe_form")