initial shift overview and shift admin view

pull/1/head
parent 85d05299c6
commit bb81f69cb3

@ -3,7 +3,19 @@ from django.contrib import admin
from .models import Room, Shift, Helper, ShiftRegistration, Message, LoginToken
admin.site.register(Room)
admin.site.register(Shift)
@admin.register(Shift)
class ShiftAdmin(admin.ModelAdmin):
list_display = ('room_name', 'start_at', 'free_slots')
def room_name(self, object):
return object.room.name
#def helpeprs(self, object):
# object.helppers.count()
def free_slots(self, object):
return object.room.required_helpers - object.shiftregistration_set.count()
#admin.site.register(Shift)
admin.site.register(Helper)
admin.site.register(ShiftRegistration)
admin.site.register(Message)

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}Help!{% endblock %}</title>
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block title %}Freie Schichten{% endblock %}
{% block content %}
<h2>Freie Scchichten:</h2>
<ul>
{% for shift in free_shifts %}
<li>{{ shift.room.name }} {{shift.start_at}}<a href="todo reg url">Mithelfen</a></li>
{% endfor %}
</ul>
{% endblock %}

@ -1,4 +1,12 @@
from django.http import HttpResponse
from django.shortcuts import render
from .models import Shift
import datetime
from django.db.models import F, Count
def index(request):
return HttpResponse('Hello, world!')
# dont show shifts starting in <60 minutes?
# currently only sorts by date
free_shifts = Shift.objects.annotate(reg_count=Count('shiftregistration')).filter(start_at__gt=datetime.datetime.now(),
room__required_helpers__gt=F('reg_count')).order_by('start_at')
context = {'free_shifts': free_shifts}
return render(request, 'shiftlist.html', context)

Loading…
Cancel
Save