- commit
- 0af1339798783ec0b00880d77018051c68944ccd
- parent
- d0d33aa74c50b9d51dd84aace2afe8107a3ae7fa
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-02-29 13:17
Use different colors for bookings
Diffstat
| M | rebelstuff/templates/rebelstuff/calendar.html | 2 | +- |
| M | rebelstuff/templatetags/rebelstuff.py | 6 | ++++++ |
| M | settings/base.py | 8 | ++++++++ |
3 files changed, 15 insertions, 1 deletions
diff --git a/rebelstuff/templates/rebelstuff/calendar.html b/rebelstuff/templates/rebelstuff/calendar.html
@@ -74,7 +74,7 @@ 74 74 <div class="calendar-grid" style="grid-template-rows: repeat({{ stuff.amount }}, 1fr)"> 75 75 {% for item in stuff|month_bookingitem_list:date_list %} 76 76 {% for i in item.amount|range %}77 -1 <div class="calendar-item" style="grid-column-start: {{ item.start.day }}; grid-column-end: {{ item.end.day }}; border-color: red">-1 77 <div class="calendar-item" style="grid-column-start: {{ item.start.day }}; grid-column-end: {{ item.end.day }}; border-color: {{ item.booking.pk|calendar_color }}"> 78 78 <a class="calendar-link" href="{% url 'admin:rebelstuff_booking_change' item.booking.id %}">{{ item.booking.name }}</a> 79 79 </div> 80 80 {% endfor %}
diff --git a/rebelstuff/templatetags/rebelstuff.py b/rebelstuff/templatetags/rebelstuff.py
@@ -1,4 +1,5 @@ 1 1 from django import template -1 2 from django.conf import settings 2 3 from django.db.models import Case, When, Value, F 3 4 4 5 register = template.Library() @@ -24,3 +25,8 @@ def month_bookingitem_list(stuff, date_list): 24 25 default=F('booking__end'), 25 26 ), 26 27 ) -1 28 -1 29 -1 30 @register.filter -1 31 def calendar_color(i): -1 32 return settings.CALENDAR_COLORS[i % len(settings.CALENDAR_COLORS)]
diff --git a/settings/base.py b/settings/base.py
@@ -98,3 +98,11 @@ USE_TZ = True 98 98 99 99 STATIC_URL = '/static/' 100 100 LOGIN_URL = '/login/' -1 101 -1 102 CALENDAR_COLORS = [ -1 103 '#e41a1c', -1 104 '#377eb8', -1 105 '#4daf4a', -1 106 '#984ea3', -1 107 '#ff7f00', -1 108 ]