Skip to content

Commit

Permalink
Allow doors to be created via the admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
proffalken committed Sep 4, 2023
1 parent bf131fa commit 100ee3c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions memberportal/api_access/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def save_or_create_door(sender, instance, **kwargs):
created = instance.pk is None
door_all_members_changed = False
door_maintenance_lockout_changed = False
door = Doors.objects.get(pk=instance.id)
door = None

# if we didn't just create the door check if it's properties have changed
if not created:
door = Doors.objects.get(pk=instance.id)
door_all_members_changed = instance.all_members != door.all_members
door_maintenance_lockout_changed = instance.locked_out != door.locked_out

Expand Down Expand Up @@ -60,7 +61,8 @@ def save_or_create_door(sender, instance, **kwargs):
)

# update the door object on the websocket consumer
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
"door_" + door.serial_number, {"type": "update_door_device"}
)
if door is not None:
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
"door_" + door.serial_number, {"type": "update_door_device"}
)

0 comments on commit 100ee3c

Please sign in to comment.