diff --git a/hc/accounts/views.py b/hc/accounts/views.py index 2b0dee56..d894fe26 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -252,28 +252,35 @@ def notifications(request): def badges(request): _ensure_own_team(request) - tags = set() - for check in Check.objects.filter(user=request.team.user): - tags.update(check.tags_list()) + teams = [request.profile] + for membership in request.user.memberships.all(): + teams.append(membership.team) - username = request.user.username - urls = [] - for tag in sorted(tags, key=lambda s: s.lower()): - if not re.match("^[\w-]+$", tag): - continue + badge_sets = [] + for team in teams: + tags = set() + for check in Check.objects.filter(user=team.user): + tags.update(check.tags_list()) - urls.append({ - "svg": get_badge_url(username, tag), - "json": get_badge_url(username, tag, format="json"), - }) + sorted_tags = sorted(tags, key=lambda s: s.lower()) + sorted_tags.append("*") # For the "overall status" badge + + urls = [] + username = team.user.username + for tag in sorted_tags: + if not re.match("^[\w-]+$", tag) and tag != "*": + continue + + urls.append({ + "svg": get_badge_url(username, tag), + "json": get_badge_url(username, tag, format="json"), + }) + + badge_sets.append({"team": team, "urls": urls}) ctx = { "page": "profile", - "urls": urls, - "master": { - "svg": get_badge_url(username, "*"), - "json": get_badge_url(username, "*", format="json") - } + "badges": badge_sets } return render(request, "accounts/badges.html", ctx) diff --git a/static/css/settings.css b/static/css/settings.css index 9c805acd..fce8acb9 100644 --- a/static/css/settings.css +++ b/static/css/settings.css @@ -11,10 +11,6 @@ padding-bottom: 24px; } -#badges-description, #b-format { - margin-bottom: 24px; -} - .page-profile .icon-ok { color: #5cb85c; } @@ -33,7 +29,11 @@ border-top: 0; } -.table td.have-tags { +.table.badges th { + border-top: 0; + color: #777777; + font-weight: normal; + font-size: 12px; padding-top: 32px; } diff --git a/templates/accounts/badges.html b/templates/accounts/badges.html index b9253c21..27cf6fc2 100644 --- a/templates/accounts/badges.html +++ b/templates/accounts/badges.html @@ -28,8 +28,10 @@

Status Badges

{% site_name %} provides status badges for each of the tags - you have used. The badges have public, but hard-to-guess - URLs. If you wish, you can add them to your READMEs, + you have used. Additionally, the "{% site_name %}" + badge shows the overall status of all checks in your + account. The badges have public, but hard-to-guess + URLs. You can use them to your READMEs, dashboards or status pages.

@@ -43,7 +45,11 @@ - {% for urldict in urls %} + {% for badge_set in badges %} + + + + {% for urldict in badge_set.urls %} {% endfor %} - - - - - - - + {% endfor %}
{{ badge_set.team }}
@@ -53,20 +59,15 @@
Overall status:
- - - {{ master.svg }} -
- {% for urldict in urls %} + {% for badge_set in badges %} + + + + + {% for urldict in badge_set.urls %} @@ -75,15 +76,7 @@ {% endfor %} - - - - - - + {% endfor %}
{{ badge_set.team }}
Overall status:
- - {{ master.json }} -