2
0
Fork 0

Reformat code using black

This commit is contained in:
Luca 2023-05-10 23:42:27 +02:00
parent 52241ec1ac
commit eb21bfe099
2 changed files with 5 additions and 4 deletions

View File

@ -1,21 +1,22 @@
from django.contrib import admin
from .models import *
def assign_random_shifts(modeladmin, request, queryset):
for member in queryset:
member.assign_random_shifts()
# Register your models here.
class FallbackAssignmentInline(admin.TabularInline):
model = FallbackAssignment
@admin.register(TeamMember)
class TeamMemberAdmin(admin.ModelAdmin):
fields = ["name"]
list_display = ["name"]
inlines = (FallbackAssignmentInline,)
actions = (assign_random_shifts,)

View File

@ -3,10 +3,10 @@ from shiftregister.app.models import *
class TeamMember(models.Model):
name = models.CharField(max_length=100)
fallback_shifts = models.ManyToManyField(Shift, through='FallbackAssignment')
fallback_shifts = models.ManyToManyField(Shift, through="FallbackAssignment")
def assign_random_shifts(self):
shifts = Shift.objects.order_by('?')[:5]
shifts = Shift.objects.order_by("?")[:5]
for shift in shifts:
self.fallback_shifts.add(shift)