Skip to content

Commit

Permalink
Add new api device list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thorrak committed Aug 10, 2023
1 parent 3d7072a commit 031b562
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/api/devices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.http import JsonResponse
from django.urls import reverse
from constance import config

from app.models import BrewPiDevice


def get_devices(req):
active_devices = list(BrewPiDevice.objects.filter(status=BrewPiDevice.STATUS_ACTIVE).values_list('id', flat=True))
return JsonResponse(active_devices, safe=False, json_dumps_params={'indent': 4})

3 changes: 2 additions & 1 deletion fermentrack_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import app.beer_views
import app.api.lcd
import app.api.clog
import app.api.devices

import firmware_flash.urls
import gravity.urls
Expand Down Expand Up @@ -107,7 +108,7 @@
url(r'^api/log/(?P<return_type>text|json)/(?P<device_type>\w{1,20})/(?P<logfile>stdout|stderr)/$', app.api.clog.get_device_log_combined, name="get_app_log"),
url(r'^api/log/(?P<return_type>text|json)/(?P<device_type>\w{1,20})/(?P<logfile>stdout|stderr)/l(?P<lines>\d{1,20})/$', app.api.clog.get_device_log_combined, name="get_app_log_lines"),
# api/gravity views are located in the gravity app

url(r'^api/devices/$', app.api.devices.get_devices, name="getDevices"), # For all devices/LCDs

# Login/Logout Views
url(r'^accounts/login/$', app.views.login, name='login'), # This is also settings.LOGIN_URL
Expand Down

0 comments on commit 031b562

Please sign in to comment.