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

filter SoUD devices when scanning the network to import new facilities #8383

Merged
merged 2 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ function facilityIsAvailableAtLocation(facilityId, location) {
}

function fetchAddressesWithFacility(facilityId = '', LocationResource = NetworkLocationResource) {
return LocationResource.fetchCollection({ force: true }).then(locations => {
return LocationResource.fetchCollection({
force: true,
getParams: { subset_of_users_device: false },
}).then(locations => {
if (facilityId !== '') {
const locationsWithAvailabilityPromises = locations.map(location => {
// Need to wrap in normal promise, otherwise Promise.all will cause some of these
Expand Down
5 changes: 5 additions & 0 deletions kolibri/core/discovery/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import viewsets
from rest_framework.exceptions import NotFound
from rest_framework.response import Response
Expand All @@ -15,6 +16,10 @@ class NetworkLocationViewSet(viewsets.ModelViewSet):
permission_classes = [NetworkLocationPermissions | NotProvisionedHasPermission]
serializer_class = NetworkLocationSerializer
queryset = NetworkLocation.objects.all()
filter_backends = [DjangoFilterBackend]
filterset_fields = [
Copy link
Member

Choose a reason for hiding this comment

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

And I had forgotten that for fields only filtering you can just do this instead of even defining a FilterSet!

"subset_of_users_device",
]


class DynamicNetworkLocationViewSet(NetworkLocationViewSet):
Expand Down