Add team members view

pull/1/head
Luca 2 years ago
parent e007e67e83
commit 3eeb853f40

@ -8,4 +8,5 @@ urlpatterns = [
views.my_fallback_shifts,
name="my_fallback_shifts",
),
path("members/", views.team_members, name="team_members"),
]

@ -1,4 +1,7 @@
from base64 import urlsafe_b64decode
from django.contrib.auth.decorators import login_required
from django.db.models import Count
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from shiftregister.fallback.models import TeamMember
@ -26,3 +29,18 @@ def my_fallback_shifts(request, team_member_id):
"is_draw": is_draw,
}
return render(request, "my_fallback_shifts.html", context)
@login_required
def team_members(request):
response = HttpResponse(
"\n".join(
f"{member.name} {member.url()}"
for member in TeamMember.objects.annotate(
shift_count=Count("fallback_shifts")
).filter(fallback_shifts__gt=0)
)
)
response.headers["Content-Type"] = "text/plain; charset=utf-8"
return response

Loading…
Cancel
Save