|
@ -1,5 +1,6 @@ |
|
|
from datetime import timedelta as td |
|
|
from datetime import timedelta as td |
|
|
|
|
|
|
|
|
|
|
|
from django.conf import settings |
|
|
from django.db import connection |
|
|
from django.db import connection |
|
|
from django.http import (HttpResponse, HttpResponseForbidden, |
|
|
from django.http import (HttpResponse, HttpResponseForbidden, |
|
|
HttpResponseNotFound, JsonResponse) |
|
|
HttpResponseNotFound, JsonResponse) |
|
@ -168,9 +169,15 @@ def badge(request, username, signature, tag, format="svg"): |
|
|
return HttpResponseNotFound() |
|
|
return HttpResponseNotFound() |
|
|
|
|
|
|
|
|
status = "up" |
|
|
status = "up" |
|
|
q = Check.objects.filter(user__username=username, tags__contains=tag) |
|
|
|
|
|
|
|
|
q = Check.objects.filter(user__username=username) |
|
|
|
|
|
if tag != "*": |
|
|
|
|
|
q = q.filter(tags__contains=tag) |
|
|
|
|
|
label = tag |
|
|
|
|
|
else: |
|
|
|
|
|
label = settings.MASTER_BADGE_LABEL |
|
|
|
|
|
|
|
|
for check in q: |
|
|
for check in q: |
|
|
if tag not in check.tags_list(): |
|
|
|
|
|
|
|
|
if tag != "*" and tag not in check.tags_list(): |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
if status == "up" and check.in_grace_period(): |
|
|
if status == "up" and check.in_grace_period(): |
|
@ -183,7 +190,7 @@ def badge(request, username, signature, tag, format="svg"): |
|
|
if format == "json": |
|
|
if format == "json": |
|
|
return JsonResponse({"status": status}) |
|
|
return JsonResponse({"status": status}) |
|
|
|
|
|
|
|
|
svg = get_badge_svg(tag, status) |
|
|
|
|
|
|
|
|
svg = get_badge_svg(label, status) |
|
|
return HttpResponse(svg, content_type="image/svg+xml") |
|
|
return HttpResponse(svg, content_type="image/svg+xml") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|