Esempio n. 1
0
def recent_api(request):
    if not 'key' in request.GET or not 'id' in request.GET:
        return HttpResponseBadRequest()
    key = request.GET['key']
    k = AccessKey.objects.get(key=key)
    update_last_activity(k.user)
    if request.GET.get("type") == "top":
        config = TopList.objects.get(pk=request.GET['id'])
        if config.user != k.user:
            return HttpResponseBadRequest()
        data = output_for_top(config)
    else:
        config = RecentConfig.objects.get(pk=request.GET['id'])
        if config.user != k.user:
            return HttpResponseBadRequest()
        data = output_for_recent(config)
    output = {
        'latest': data,
        'font': config.font or None,
        'font_size': config.font_size or None,
        'font_color': config.font_color or None,
    }

    output_s = json.dumps(output)
    return HttpResponse(output_s, content_type='text/plain')
Esempio n. 2
0
def recent_api(request):
    if not 'key' in request.GET or not 'id' in request.GET: 
        return HttpResponseBadRequest()
    key = request.GET['key']
    k = AccessKey.objects.get(key=key)
    update_last_activity(k.user)
    if request.GET.get("type") == "top":
        config = TopList.objects.get(pk=request.GET['id'])
        if config.user != k.user:
            return HttpResponseBadRequest()
        data = output_for_top(config)
    elif request.GET.get("type") == "meta":
        config = Meta.objects.get(pk=request.GET['id'])
        if config.user != k.user:
            return HttpResponseBadRequest()
        data = output_for_meta(config)    
    else:
        config = RecentConfig.objects.get(pk=request.GET['id'])
        if config.user != k.user:
            return HttpResponseBadRequest()
        data = output_for_recent(config)
    google_font = False
    try:
        google_font = check_google_font(config.font)
    except Exception, E:
        print "Failed to check font", E
Esempio n. 3
0
def all_recents(request):
    if not 'key' in request.GET:
        return HttpResponseBadRequest()
    key = request.GET['key']
    k = AccessKey.objects.get(key=key)
    update_last_activity(k.user)
    output = {}
    for i in RecentConfig.objects.filter(user=k.user):
        output['%s-%s' % (i.type, i.id)] = output_for_recent(i)
    for i in TopList.objects.filter(user=k.user):
        output['top-%s-%s' % (i.type, i.id)] = output_for_top(i)
    output_s = json.dumps(output)
    return HttpResponse(output_s, content_type='text/plain')
Esempio n. 4
0
def all_recents(request):
    if not 'key' in request.GET: 
        return HttpResponseBadRequest()
    key = request.GET['key']
    k = AccessKey.objects.get(key=key)
    update_last_activity(k.user)
    output = {}
    for i in RecentConfig.objects.filter(user=k.user):
        output['%s-%s' % (i.type, i.id)] = output_for_recent(i)
    for i in TopList.objects.filter(user=k.user):
        output['top-%s-%s' % (i.type, i.id)] = output_for_top(i)
    for i in Meta.objects.filter(user=k.user):
        output['meta-%s-%s' % (i.type, i.id)] = output_for_meta(i)
    output_s = json.dumps(output)
    return HttpResponse(output_s, content_type='text/plain')
Esempio n. 5
0
 def testTopOutput(self):
     self.assertEquals("foo: $1.00", output_for_top(self.top))
Esempio n. 6
0
 def testTopOutput(self):
     self.assertEquals("😇: $1.00", output_for_top(self.top).encode("utf-8"))
     self.assertEquals("😇: $4.00", output_for_top(self.top_no_session).encode("utf-8"))
Esempio n. 7
0
 def testTopOutput(self):
     self.assertEquals("baz 😀 : €4.90, bar: $5.00, foo: $1.00", output_for_top(self.top).encode("utf-8"))