Reformat code using black
This commit is contained in:
parent
52241ec1ac
commit
eb21bfe099
|
@ -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,)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue