Compare commits

..

No commits in common. '7aa5da28fe39f3d12b2201d64128a3f70b50854d' and '1f53998eb07bbdd67dfd9b2504d5fe7af15a1ad4' have entirely different histories.

@ -1,23 +0,0 @@
# Generated by Django 4.0.4 on 2023-05-28 10:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("app", "0011_room_description"),
]
operations = [
migrations.AlterField(
model_name="shift",
name="deleted",
field=models.BooleanField(db_index=True, default=False),
),
migrations.AlterField(
model_name="shift",
name="start_at",
field=models.DateTimeField(db_index=True),
),
]

@ -26,13 +26,13 @@ class Room(models.Model):
class Shift(models.Model): class Shift(models.Model):
room = models.ForeignKey(Room, on_delete=models.RESTRICT) room = models.ForeignKey(Room, on_delete=models.RESTRICT)
start_at = models.DateTimeField(db_index=True) start_at = models.DateTimeField()
duration = models.DurationField() duration = models.DurationField()
required_helpers = models.IntegerField( required_helpers = models.IntegerField(
default=0, help_text="When this is set to zero, the room value is used instead." default=0, help_text="When this is set to zero, the room value is used instead."
) )
description = models.TextField(blank=True, default="") description = models.TextField(blank=True, default="")
deleted = models.BooleanField(default=False, db_index=True) deleted = models.BooleanField(default=False)
def with_reg_count(): def with_reg_count():
return Shift.objects.annotate( return Shift.objects.annotate(

@ -93,9 +93,7 @@ def add_helper_shift(self):
@login_required @login_required
def shift_detail(request, pk): def shift_detail(request, pk):
shift = get_object_or_404( shift = get_object_or_404(Shift, pk=pk)
Shift.with_reg_count().prefetch_related("shiftregistration_set__helper"), pk=pk
)
form = HelperShift() form = HelperShift()
if request.method == "POST": if request.method == "POST":
form = HelperShift(request.POST) form = HelperShift(request.POST)

Loading…
Cancel
Save