Reformat code using black

pull/1/head
Luca 2 years ago
parent 52241ec1ac
commit eb21bfe099

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

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

Loading…
Cancel
Save