From 194616c993c9ce7e58e93e25a1d1c5d2ee2e0550 Mon Sep 17 00:00:00 2001 From: Simon Oliver Tveit Date: Thu, 23 Nov 2023 11:17:12 +0100 Subject: [PATCH] Update poe state during save --- python/nav/web/portadmin/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/nav/web/portadmin/views.py b/python/nav/web/portadmin/views.py index 202669c0fb..23ddb3383a 100644 --- a/python/nav/web/portadmin/views.py +++ b/python/nav/web/portadmin/views.py @@ -390,11 +390,23 @@ def set_interface_values(account, interface, request): set_ifalias(account, handler, interface, request) set_vlan(account, handler, interface, request) set_admin_status(handler, interface, request) + set_poe_state(handler, interface, request) save_to_database([interface]) else: messages.info(request, 'Could not connect to netbox') +def set_poe_state(handler, interface, request): + if 'poe_state' in request.POST: + poe_state_name = request.POST.get('poe_state') + for option in handler.get_poe_state_options(): + if option.name == poe_state_name: + handler.set_poe_state(interface, option) + return + # If there was no match between posted value and known states + raise ValueError(f"Invalid PoE state name: {poe_state_name}") + + def build_ajax_messages(request): """Create a structure suitable for converting to json from messages""" ajax_messages = []