Skip to content

Commit

Permalink
Update poe state during save
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Nov 23, 2023
1 parent 02a0ea6 commit 194616c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/nav/web/portadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 393 in python/nav/web/portadmin/views.py

View check run for this annotation

Codecov / codecov/patch

python/nav/web/portadmin/views.py#L393

Added line #L393 was not covered by tests
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

Check warning on line 405 in python/nav/web/portadmin/views.py

View check run for this annotation

Codecov / codecov/patch

python/nav/web/portadmin/views.py#L400-L405

Added lines #L400 - L405 were not covered by tests
# If there was no match between posted value and known states
raise ValueError(f"Invalid PoE state name: {poe_state_name}")

Check warning on line 407 in python/nav/web/portadmin/views.py

View check run for this annotation

Codecov / codecov/patch

python/nav/web/portadmin/views.py#L407

Added line #L407 was not covered by tests


def build_ajax_messages(request):
"""Create a structure suitable for converting to json from messages"""
ajax_messages = []
Expand Down

0 comments on commit 194616c

Please sign in to comment.