Skip to content

Commit

Permalink
show calendar without events
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Jul 30, 2024
1 parent 60b73a5 commit 7ec31e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 0 additions & 6 deletions ephios/core/templates/core/event_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ <h3 class="mx-3">

{% if mode == "list" %}
{% include "core/fragments/event_list_list_mode.html" %}
{% elif not event_list %}
<div class="mb-3">
<h5 class="mt-5 text-center">
{% translate "No results" %}
</h5>
</div>
{% elif mode == "calendar" %}
{{ calendar }}
{% elif mode == "day" %}
Expand Down
4 changes: 4 additions & 0 deletions ephios/core/templates/core/fragments/event_list_day_mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ <h2 class="card-title clearfix text-truncate fs-6">
</div>
</a>
</div>
{% empty %}
<h5 class="mt-5 text-center">
{% translate "No results" %}
</h5>
{% endfor %}

{% for event in event_list %}
Expand Down
16 changes: 8 additions & 8 deletions ephios/core/views/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,7 @@ def _get_day_context(self):
.prefetch_related(Prefetch("shifts", queryset=Shift.objects.order_by("start_time")))
)

if not events.exists():
ctx.update({"event_list": events, "date": this_date})
return ctx

css_context = self._build_day_css_context(events, shifts)

ctx.update(
{
"event_list": events,
Expand All @@ -359,7 +354,6 @@ def _get_day_context(self):
**css_context,
}
)

return ctx

def _build_day_css_context(self, events, shifts):
Expand Down Expand Up @@ -390,8 +384,14 @@ def _build_day_css_context(self, events, shifts):

shifts_by_event_layouted[event.pk] = columns
css_shift_tops = ""
earliest_shift_start = min(shift.start_time for shift in shifts)
latest_shift_end = max(shift.end_time for shift in shifts)
try:
earliest_shift_start = min(shift.start_time for shift in shifts)
latest_shift_end = max(shift.end_time for shift in shifts)
except ValueError:
# empty shifts
earliest_shift_start = latest_shift_end = timezone.now()
total_height = 2

# calculate timescale based on shortest shift
# to not make things too small, consider a maximum of 4 hours and a minimum of 15 minutes
shortest_shift_duration_in_hours = max(
Expand Down

0 comments on commit 7ec31e3

Please sign in to comment.