Skip to content

Commit

Permalink
Merge branch '5.8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Nov 30, 2023
2 parents 39af697 + ce3e2d0 commit f0bf31f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This changelog format was introduced in NAV 5.4.0. Older changelogs can be
found in the [HISTORY](HISTORY) file.

## [5.8.2] - 2023-11-30

### Fixed

- Fix broken "operate as user" function in User and API Administration tool ([#2766](https://github.com/Uninett/nav/issues/2766), [#2777](https://github.com/Uninett/nav/pull/2777))
- Fix crashing PDU widget ([#2776](https://github.com/Uninett/nav/pull/2776))
- Fix bug that caused PortAdmin to stop working for Cisco switches ([#2773](https://github.com/Uninett/nav/issues/2773), ([#2774](https://github.com/Uninett/nav/pull/2774))


## [5.8.1] - 2023-11-29

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions python/nav/web/navlets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, *args, **kwargs):
self.fields['room_id'].choices = [('', '----------')] + [
(r.pk, str(r))
for r in Room.objects.filter(
netbox__category='POWER',
netbox__sensors__internal_name__startswith='rPDULoadStatusLoad',
netboxes__category='POWER',
netboxes__sensors__internal_name__startswith='rPDULoadStatusLoad',
).distinct('id')
]
6 changes: 4 additions & 2 deletions python/nav/web/portadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ def populate_infodict(request, netbox, interfaces):
XMLParseError,
POEStateNotSupportedError,
) as error:
readonly = True
messages.error(request, str(error))
supports_poe = False
_logger.error(
'Error getting PoE information from netbox %s: %s', str(netbox), str(error)
)

if handler and not handler.is_configurable():
add_readonly_reason(request, handler)
Expand Down
3 changes: 1 addition & 2 deletions python/nav/web/useradmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from nav.models.manage import Organization
from nav.models.api import APIToken

from nav.web.auth import sudo
from nav.web.auth.sudo import sudo
from nav.web.useradmin import forms


Expand Down Expand Up @@ -396,7 +396,6 @@ def group_detail(request, group_id=None):
privilege_form = forms.PrivilegeForm()

if request.method == 'POST':

if 'submit_group' in request.POST:
group_form = forms.AccountGroupForm(request.POST, instance=group)

Expand Down
15 changes: 15 additions & 0 deletions tests/integration/web/useradmin_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.urls import reverse


def test_operate_as_this_user_should_not_crash(db, client, admin_account):
url = reverse('useradmin-account_detail', args=(admin_account.pk,))
response = client.post(
url,
follow=True,
data={
"account": admin_account.pk,
"submit_sudo": "Operate+as+this+user",
},
)

assert response.status_code == 200
16 changes: 15 additions & 1 deletion tests/integration/widget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nav.web.navlets.roomstatus import RoomStatus
from nav.web.navlets.feedreader import FeedReaderNavlet
from nav.models.event import AlertHistory, AlertHistoryMessage
from nav.models.profiles import AccountNavlet
from nav.models.profiles import AccountDashboard, AccountNavlet
from nav.models.fields import INFINITY

import pytest
Expand Down Expand Up @@ -39,6 +39,20 @@ def test_get_navlet_should_return_200(client, admin_navlet):
assert response.status_code == 200


def test_get_pdu_navlet_in_edit_mode_should_return_200(client, admin_account):
"""Tests a GET request against the pdu navlet in edit mode"""
pdu_navlet = AccountNavlet.objects.create(
navlet="nav.web.navlets.pdu.PduWidget",
account=admin_account,
)
url = reverse('get-user-navlet', kwargs={'navlet_id': pdu_navlet.id}) + "?mode=EDIT"
print(
"Testing admin navlet instance of {!r} at {!r}".format(pdu_navlet.navlet, url)
)
response = client.get(url)
assert response.status_code == 200


#
# Fixtures
#
Expand Down

0 comments on commit f0bf31f

Please sign in to comment.