filter room info for valid data only
This commit is contained in:
parent
5a826c04a6
commit
68dbab1cb6
|
@ -20,6 +20,9 @@ class Room(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def valid_shifts(self):
|
||||||
|
return self.shift_set.filter(deleted=False)
|
||||||
|
|
||||||
|
|
||||||
class Shift(models.Model):
|
class Shift(models.Model):
|
||||||
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
|
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
|
||||||
|
@ -68,6 +71,14 @@ class Shift(models.Model):
|
||||||
).count()
|
).count()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def valid_registrations(self):
|
||||||
|
return self.shiftregistration_set.filter(
|
||||||
|
state__in=[
|
||||||
|
ShiftRegistration.RegState.REGISTERED,
|
||||||
|
ShiftRegistration.RegState.CHECKED_IN,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Helper(models.Model):
|
class Helper(models.Model):
|
||||||
phone = PhoneNumberField(unique=True, editable=False)
|
phone = PhoneNumberField(unique=True, editable=False)
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for shift in room.shift_set.all|dictsort:"start_at" %}
|
{% for shift in room.valid_shifts.all|dictsort:"start_at" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ shift.start_at }}</td>
|
<td>{{ shift.start_at }}</td>
|
||||||
<td>{% for reg in shift.shiftregistration_set.all %}{{ reg.helper.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
|
<td>{% for reg in shift.valid_registrations.all %}{{ reg.helper.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -366,5 +366,10 @@ def mark_as_read(request, pk):
|
||||||
|
|
||||||
|
|
||||||
def room_view_token(request, token):
|
def room_view_token(request, token):
|
||||||
tk = get_object_or_404(RoomViewToken, pk=token)
|
return render(
|
||||||
return render(request, "room_registrations.html", {"room": tk.room})
|
request,
|
||||||
|
"room_registrations.html",
|
||||||
|
{
|
||||||
|
"room": get_object_or_404(RoomViewToken, pk=token).room,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue