implement fallback assignment admin view, dumb random fallback assignment
This commit is contained in:
parent
5f434adf05
commit
01ac707ab7
|
@ -70,3 +70,10 @@ class EnableAsta(types.BooleanPreference):
|
|||
section = helper
|
||||
name = "enable_asta"
|
||||
default = True
|
||||
|
||||
|
||||
@global_preferences_registry.register
|
||||
class FallbackQuota(types.FloatPreference):
|
||||
section = helper
|
||||
name = "fallback_quota"
|
||||
default = 0.7
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
from django.contrib import admin
|
||||
from .models import TeamMember
|
||||
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,6 +3,12 @@ from shiftregister.app.models import *
|
|||
|
||||
class TeamMember(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
fallback_shifts = models.ManyToManyField(Shift, through='FallbackAssignment')
|
||||
|
||||
def assign_random_shifts(self):
|
||||
shifts = Shift.objects.order_by('?')[:5]
|
||||
for shift in shifts:
|
||||
self.fallback_shifts.add(shift)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}"
|
||||
|
|
Loading…
Reference in New Issue