|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
from base64 import urlsafe_b64encode
|
|
|
|
|
from django.contrib import admin
|
|
|
|
|
from django.shortcuts import reverse
|
|
|
|
|
from .models import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -26,11 +28,21 @@ class FallbackAssignmentInline(admin.TabularInline):
|
|
|
|
|
|
|
|
|
|
@admin.register(TeamMember)
|
|
|
|
|
class TeamMemberAdmin(admin.ModelAdmin):
|
|
|
|
|
fields = ("id", "name")
|
|
|
|
|
readonly_fields = ("id",)
|
|
|
|
|
fields = ("id", "name", "url")
|
|
|
|
|
readonly_fields = ("id", "url")
|
|
|
|
|
list_display = ("name", "shift_count")
|
|
|
|
|
inlines = (FallbackAssignmentInline,)
|
|
|
|
|
actions = (assign_random_shifts, clear_shifts, reshuffle_shifts)
|
|
|
|
|
|
|
|
|
|
def shift_count(self, object):
|
|
|
|
|
return object.fallback_shifts.count()
|
|
|
|
|
|
|
|
|
|
def url(self, object):
|
|
|
|
|
return "https://helfen.kntkt.de" + reverse(
|
|
|
|
|
"my_fallback_shifts",
|
|
|
|
|
kwargs={
|
|
|
|
|
"team_member_id": urlsafe_b64encode(
|
|
|
|
|
object.id.to_bytes(3, byteorder="big")
|
|
|
|
|
).decode("utf-8")
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|