Beispiel #1
0
def get_activity(request):
    try:
        last = request.GET['last']
    except KeyError:
        last = 1

    items = Activity.get_latest(last_id=last)
    return json_write_items(items)
Beispiel #2
0
def utility_track(request, pk):
    try:
        home = Home.get(pk)
        item = Track.objects.filter(home=home).order_by('-created')[:1]
    except Home.DoesNotExist:
        item = Track()
    except Track.DoesNotExist:
        item = Track()
    return json_write_items(item)
Beispiel #3
0
def utility_daily(request, pk):
    try:
        home = Home.get(pk)
        item = Daily.objects.filter(home=home).order_by('-created')[:30]
    except Home.DoesNotExist:
        item = Daily()
    except Daily.DoesNotExist:
        item = Daily()

    return json_write_items(item)
Beispiel #4
0
def device_monthly(request, pk):
    try:
        device = Device.get(pk)
        items = Monthly.objects.filter(device=device).order_by('-created')[:12]
    except Device.DoesNotExist:
        items = Monthly()
    except Monthly.DoesNotExist:
        items = Monthly()

    return json_write_items(items)
Beispiel #5
0
def device_activity(request, pk):
    try:
        device = Device.get(pk)
        items = Activity.objects.filter(
            device=device).order_by('-created')[:20]
    except Device.DoesNotExist:
        items = Activity()
    except Activity.DoesNotExist:
        items = Activity()

    return json_write_items(items)
Beispiel #6
0
def get_home_devices(request):
    try:
        home = Home.get(request.GET['home'])
        hardwares = Hardware.objects.filter(home=home)
        devices = Device.objects.filter(hardware=hardwares)
    except KeyError:
        devices = None

    items = []
    for device in devices:
        try:
            status = Status.objects.get(device=device)
            items.append(status)
        except Status.DoesNotExist:
            continue

    return json_write_items(items)