2
0
Fork 0

Add team members view

This commit is contained in:
Luca 2023-05-17 16:16:47 +02:00
parent e007e67e83
commit 3eeb853f40
2 changed files with 19 additions and 0 deletions

View File

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

View File

@ -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