示例#1
0
def show_form(request, query_set=None, javascript=False, model=None, statistics_variable=None):
    if request.method == "POST" and request.is_ajax():
        query = request.POST
        user = request.user
        rdict = build_graph(query, user)
        wiki_code = reverse_translate_query(query)
        rdict["wiki_code"] = wiki_code
        rdict["query_link"] = b64encode(smart_str(query.urlencode()))
        json = simplejson.dumps(rdict, ensure_ascii=False)
        return HttpResponse(json, mimetype="application/javascript")
    else:
        username = ""
        if request.user.is_anonymous() == True:
            username = "******"
        else:
            username = request.user.get_full_name()
            if username == "":
                username = request.user.username
        form = DbForm()

        response_dic = {"form": form, "request": request, "username": username}
        if statistics_variable:
            response_dic["statistics_variable"] = statistics_variable
            response_template = "/simple_graph_form.html"
        else:
            response_template = "/graph_form.html"
        return render_to_response(response_template, response_dic, context_instance=RequestContext(request))
示例#2
0
def show_form(request,
              query_set=None,
              javascript=False,
              model=None,
              statistics_variable=None):
    if request.method == "POST" and request.is_ajax():
        query = request.POST
        user = request.user
        rdict = build_graph(query, user)
        wiki_code = reverse_translate_query(query)
        rdict['wiki_code'] = wiki_code
        rdict['query_link'] = b64encode(smart_str(query.urlencode()))
        json = simplejson.dumps(rdict, ensure_ascii=False)
        return HttpResponse(json, mimetype='application/javascript')
    else:
        username = ""
        if request.user.is_anonymous() == True:
            username = "******"
        else:
            username = request.user.get_full_name()
            if username == "":
                username = request.user.username
        form = DbForm()

        response_dic = {"form": form, "request": request, "username": username}
        if statistics_variable:
            response_dic['statistics_variable'] = statistics_variable
            response_template = "/simple_graph_form.html"
        else:
            response_template = "/graph_form.html"
        return render_to_response(response_template,
                                  response_dic,
                                  context_instance=RequestContext(request))
示例#3
0
	def StatisticsPattern(self,pattern):
		query = pattern.group(1)
		translated_query=QueryDict(translate_query_string(query))
		text='[div id="graph'+str(self.graph_counter)+'" class="graph"][/div]'
		rdict = build_graph(translated_query,self.user)
		json = simplejson.dumps(rdict, ensure_ascii=False)
 		self.json_data+='graphs['+str(self.graph_counter)+']='+json+';'
		self.graph_counter += 1
	       	return text
示例#4
0
def show_graph(request, query_string):
    query_string = smart_unicode(b64decode(query_string))
    user = request.user
    query = QueryDict(query_string)
    rdict = build_graph(query, user)
    rdict["query_string"] = query_string
    json = simplejson.dumps(rdict, ensure_ascii=False)
    return render_to_response(
        "/graph.html", {"request": request, "json": json}, context_instance=RequestContext(request)
    )
示例#5
0
 def StatisticsPattern(self, pattern):
     query = pattern.group(1)
     translated_query = QueryDict(translate_query_string(query))
     text = '[div id="graph' + str(
         self.graph_counter) + '" class="graph"][/div]'
     rdict = build_graph(translated_query, self.user)
     json = simplejson.dumps(rdict, ensure_ascii=False)
     self.json_data += 'graphs[' + str(
         self.graph_counter) + ']=' + json + ';'
     self.graph_counter += 1
     return text
示例#6
0
def show_graph(request, query_string):
    query_string = smart_unicode(b64decode(query_string))
    user = request.user
    query = QueryDict(query_string)
    rdict = build_graph(query, user)
    rdict['query_string'] = query_string
    json = simplejson.dumps(rdict, ensure_ascii=False)
    return render_to_response("/graph.html", {
        "request": request,
        "json": json
    },
                              context_instance=RequestContext(request))