Esempio n. 1
0
def index(request):
    dr = DeviceRepository()
    devices = dr.get_all_devices()
    free_devices = list(filter((lambda x: x.reserved_by is None), devices))

    return render(request, 'www/index.html', {
        'devices': devices,
        'free_devices': free_devices
    })
Esempio n. 2
0
def reserve(request):
    device_pk = request.GET.get('device_pk', '')
    user_pk = request.GET.get('user_pk', '')

    dr = DeviceRepository()
    ur = UserRepository()

    device = dr.get_by_pk(device_pk)
    user = ur.get_by_pk(user_pk)

    device.reserve(user)

    return redirect('devices:index')
Esempio n. 3
0
def free(request, pk):
    dr = DeviceRepository()
    device = dr.get_by_pk(pk)
    device.set_free()

    return redirect('devices:index')