Skip to content

Commit

Permalink
Add buddy information to extra shifts display
Browse files Browse the repository at this point in the history
  • Loading branch information
Tubo committed Mar 15, 2024
1 parent 6cde872 commit 3accc89
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions radscheduler/core/views/extra_duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ def interest(request, interest_id):
@staff_member_required
def edit_page(request):
subquery = ShiftInterest.objects.filter(registrar=request.user.registrar, shift=OuterRef("pk"))
buddy_shifts = Shift.objects.filter(date=OuterRef("date"), type=OuterRef("type"), extra_duty=False).values(
"registrar__user__username"
)
extra_shifts = (
Shift.objects.filter(extra_duty=True, date__gte=date.today() - timedelta(days=30))
.annotate(
interest_id=Subquery(subquery.values("pk")),
comment=Subquery(subquery.values("comment")),
buddy=Subquery(buddy_shifts[:1]),
)
.order_by("-date")
.select_related("registrar__user")
Expand Down
5 changes: 4 additions & 1 deletion radscheduler/templates/extra_duties/edit_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
{{ shift.date|date:"Y-m-d D" }}
{% if shift.date in holidays %}🎉{% endif %}
</th>
<td>{{ shift.get_type_display }}</td>
<td>
{{ shift.get_type_display }}
{% if shift.buddy %}- {{ shift.buddy }}{% endif %}
</td>
<td>
{% for interest in shift.interests.all %}
{{ interest.registrar }}
Expand Down
6 changes: 3 additions & 3 deletions radscheduler/templates/extra_duties/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<table class="table text-center">
<thead>
<tr>
<th scope="col" class="w-25">Date</th>
<th scope="col" class="w-25">Type</th>
<th scope="col" class="w-25 text-start">Date</th>
<th scope="col" class="w-25 text-start">Type</th>
<th scope="col" class="w-25">People interested</th>
<th scope="col" class="w-25"></th>
<th scope="col" class="w-25">Winner</th>
</tr>
</thead>
<tbody>
Expand Down
9 changes: 6 additions & 3 deletions radscheduler/templates/extra_duties/row.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
hx-swap="outerHTML"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
class="h-50">
<th scope="row">
{{ shift.date|date:"Y-m-d D" }}
<th scope="row" class="font-monospace text-start">
{{ shift.date|date:"Y-m-d" }}
{% if shift.date in holidays %}🎉{% endif %}
</th>
<td>{{ shift.get_type_display }}</td>
<td class="text-start">
<span class="">{{ shift.get_type_display }}</span>
<span class="text-secondary">({{ shift.date|date:"D" }})</span>
</td>
<td>{{ shift.interests.count }}</td>
<td>
{% if shift.registrar %}
Expand Down

0 comments on commit 3accc89

Please sign in to comment.