Skip to content

Commit

Permalink
set measurement.user when in api
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Sauer committed Jan 21, 2025
1 parent fb9108e commit 6df4c4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def post(self, request, *args, **kwargs):
time_measured=station_data['time'],
time_received=time_received,
room = station.current_room,
user = station.current_user,
)
measurement.save()

Expand Down
6 changes: 2 additions & 4 deletions app/main/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from devices.models import Device, DeviceStatus

def get_or_create_station(station_info: dict):
def get_or_create_station(station_info: dict):
'''
station_info dict:
{
Expand All @@ -28,11 +28,9 @@ def get_or_create_station(station_info: dict):
)
if created:
station.device_name = station_info['device']
station.firmware = station_info['firmware']
station.last_update = datetime.datetime.now(datetime.timezone.utc)
station.api_key = station_info['apikey']
station.model = station_info['model']
station.firmware = station_info['firmware']
station.api_key = station_info['apikey']

# add a new DeviceStatus
station_status = DeviceStatus.objects.create(
Expand Down

0 comments on commit 6df4c4c

Please sign in to comment.