Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change] WiFi session admin: switched to autocomplete filters #468

Merged
merged 3 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openwisp_monitoring/device/filters.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from django.utils.translation import gettext_lazy as _
from swapper import load_model

from openwisp_users.multitenancy import MultitenantRelatedOrgFilter
from openwisp_users.multitenancy import MultitenantOrgFilter
from openwisp_utils.admin_theme.filters import AutocompleteFilter

Device = load_model('config', 'Device')


class DeviceOrganizationFilter(MultitenantRelatedOrgFilter):
class DeviceOrganizationFilter(MultitenantOrgFilter):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MultitenantRelatedOrgFilter should be used for filtering with models other than Organization. E.g. filtering WifiSessions according to device

rel_model = Device
parameter_name = 'device__organization'

Expand Down
5 changes: 0 additions & 5 deletions openwisp_monitoring/device/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,6 @@ def _assert_org2_wifi_session_in_response(
)

with self.subTest('Test device filter'):
# Filter by device name
response = self.client.get(url, {'device': org2_device.name})
_assert_org2_wifi_session_in_response(
response, org1_interface_data, org2_interface_data
)
Comment on lines -781 to -785
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The autocomplete filter will always perform a lookup with UUID of the object. This test was required when we were using InputFilter.

# Filter by device pk
response = self.client.get(url, {'device': str(org2_device.pk)})
_assert_org2_wifi_session_in_response(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openwisp-controller @ https://github.com/openwisp/openwisp-controller/tarball/master
openwisp-controller @ https://github.com/openwisp/openwisp-controller/tarball/org-filter
influxdb~=5.3.1
django-cache-memoize~=0.1.0
django-nested-admin~=3.4.0
Expand Down