Esempio n. 1
0
def removeFavoriteQuery(request):
    if request.user:
        query_id = request.REQUEST.get("id", None)
        if query_id:
            query = FavoriteQuery(pk=query_id)
            query.delete()

            return HttpResponse("[true, %s]" % query_id, content_type="application/javascript")

    return HttpResponse("[false]", content_type="application/javascript")
Esempio n. 2
0
def addFavoriteQuery(request):
    if request.user:
        url = request.REQUEST.get("url", None)
        if url and len(url):
            name = request.REQUEST.get("name", "").strip()
            if len(name) == 0:
                name = url

            query = FavoriteQuery(user=request.user, name=name, url=url)
            query.save()
            return HttpResponse("[true, %d]" % query.id, content_type="application/javascript")

    return HttpResponse("[false]", content_type="application/javascript")