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

View File

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