Skip to content

Commit

Permalink
Merge pull request #2316 from hmpf/dependency-hell
Browse files Browse the repository at this point in the history
Upgrade dependencies that will need a newer version to run on Django 3.2 or later
  • Loading branch information
lunkwill42 authored Nov 26, 2021
2 parents 0d4290d + 605afa2 commit 073a6ce
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion python/nav/auditlog/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ class LogEntryViewSet(NAVDefaultsMixin, viewsets.ReadOnlyModelViewSet):
)
queryset = LogEntry.objects.all()
serializer_class = LogEntrySerializer
filter_fields = ('subsystem', 'object_pk', 'verb')
filterset_fields = ('subsystem', 'object_pk', 'verb')
search_fields = ('summary',)
ordering = ('timestamp',)
20 changes: 10 additions & 10 deletions python/nav/web/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@

router = routers.SimpleRouter()
router.register(r'account', views.AccountViewSet)
router.register(r'accountgroup', views.AccountGroupViewSet, base_name='accountgroup')
router.register(r'accountgroup', views.AccountGroupViewSet, basename='accountgroup')
router.register(r'rack', views.RackViewSet)
router.register(r'room', views.RoomViewSet)
router.register(r'location', views.LocationViewSet)
router.register(
r'management-profile',
views.ManagementProfileViewSet,
base_name="management-profile",
basename="management-profile",
)
router.register(r'netbox', views.NetboxViewSet)
router.register(r'interface', views.InterfaceViewSet)
router.register(r'prefix', views.PrefixViewSet)
router.register(r'vlan', views.VlanViewSet)
router.register(r'cabling', views.CablingViewSet, base_name='cabling')
router.register(r'patch', views.PatchViewSet, base_name='patch')
router.register(r'cam', views.CamViewSet, base_name='cam')
router.register(r'arp', views.ArpViewSet, base_name='arp')
router.register(r'cabling', views.CablingViewSet, basename='cabling')
router.register(r'patch', views.PatchViewSet, basename='patch')
router.register(r'cam', views.CamViewSet, basename='cam')
router.register(r'arp', views.ArpViewSet, basename='arp')
router.register(
r'servicehandler', views.ServiceHandlerViewSet, base_name='servicehandler'
r'servicehandler', views.ServiceHandlerViewSet, basename='servicehandler'
)
router.register(r'alert', views.AlertHistoryViewSet, base_name='alert')
router.register(r'alert', views.AlertHistoryViewSet, basename='alert')
router.register(
r'unrecognized-neighbor',
views.UnrecognizedNeighborViewSet,
base_name='unrecognized-neighbor',
basename='unrecognized-neighbor',
)
router.register(r'auditlog', auditlogapi.LogEntryViewSet, base_name='auditlog')
router.register(r'auditlog', auditlogapi.LogEntryViewSet, basename='auditlog')


urlpatterns = [
Expand Down
39 changes: 17 additions & 22 deletions python/nav/web/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
from django_filters.rest_framework import DjangoFilterBackend, FilterSet
from django_filters.filters import ModelMultipleChoiceFilter
from rest_framework import status, filters, viewsets, exceptions
from rest_framework.decorators import (
api_view,
renderer_classes,
list_route,
detail_route,
)
from rest_framework.decorators import api_view, renderer_classes, action
from rest_framework.reverse import reverse_lazy
from rest_framework.renderers import (
JSONRenderer,
Expand Down Expand Up @@ -284,7 +279,7 @@ class AccountViewSet(NAVAPIMixin, viewsets.ModelViewSet):

queryset = profiles.Account.objects.all()
serializer_class = serializers.AccountSerializer
filter_fields = ('login', 'ext_sync')
filterset_fields = ('login', 'ext_sync')
search_fields = ('name',)


Expand Down Expand Up @@ -324,7 +319,7 @@ class RoomViewSet(LoggerMixin, NAVAPIMixin, viewsets.ModelViewSet):

queryset = manage.Room.objects.all()
serializer_class = serializers.RoomSerializer
filter_fields = ('location', 'description')
filterset_fields = ('location', 'description')


class LocationViewSet(LoggerMixin, NAVAPIMixin, viewsets.ModelViewSet):
Expand All @@ -342,7 +337,7 @@ class LocationViewSet(LoggerMixin, NAVAPIMixin, viewsets.ModelViewSet):

queryset = manage.Location.objects.all()
serializer_class = serializers.LocationSerializer
filter_fields = ('id', 'parent')
filterset_fields = ('id', 'parent')
search_fields = ('description',)


Expand All @@ -361,7 +356,7 @@ class UnrecognizedNeighborViewSet(NAVAPIMixin, viewsets.ReadOnlyModelViewSet):

queryset = manage.UnrecognizedNeighbor.objects.all()
serializer_class = serializers.UnrecognizedNeighborSerializer
filter_fields = ('netbox', 'source')
filterset_fields = ('netbox', 'source')
search_fields = ('remote_name',)


Expand Down Expand Up @@ -395,7 +390,7 @@ class NetboxViewSet(LoggerMixin, NAVAPIMixin, viewsets.ModelViewSet):

queryset = manage.Netbox.objects.all()
serializer_class = serializers.NetboxSerializer
filter_fields = (
filterset_fields = (
'ip',
'sysname',
'room',
Expand Down Expand Up @@ -498,7 +493,7 @@ class InterfaceViewSet(NAVAPIMixin, viewsets.ReadOnlyModelViewSet):

# NaturalIfnameFilter returns a list, so IfClassFilter needs to come first
filter_backends = NAVAPIMixin.filter_backends + (IfClassFilter, NaturalIfnameFilter)
filter_class = InterfaceFilterClass
filterset_class = InterfaceFilterClass

def get_serializer_class(self):
request = self.request
Expand All @@ -512,7 +507,7 @@ def get_renderers(self):
self.renderer_classes += (InterfaceFragmentRenderer,)
return super(InterfaceViewSet, self).get_renderers()

@detail_route()
@action(detail=True)
def metrics(self, _request, pk=None):
"""List all metrics for this interface
Expand All @@ -521,7 +516,7 @@ def metrics(self, _request, pk=None):
"""
return Response(self.get_object().get_port_metrics())

@detail_route()
@action(detail=True)
def last_used(self, _request, pk=None):
"""Return last used timestamp for this interface
Expand Down Expand Up @@ -561,7 +556,7 @@ class PatchViewSet(NAVAPIMixin, viewsets.ReadOnlyModelViewSet):
'cabling__room', 'interface__netbox'
).all()
serializer_class = serializers.PatchSerializer
filter_fields = ('cabling', 'cabling__room', 'interface', 'interface__netbox')
filterset_fields = ('cabling', 'cabling__room', 'interface', 'interface__netbox')
search_fields = ('cabling__jack',)


Expand All @@ -584,7 +579,7 @@ class CablingViewSet(NAVAPIMixin, viewsets.ReadOnlyModelViewSet):
"""

serializer_class = serializers.CablingSerializer
filter_fields = ('room', 'jack', 'building', 'target_room', 'category')
filterset_fields = ('room', 'jack', 'building', 'target_room', 'category')
search_fields = ('jack', 'target_room', 'building')

def get_queryset(self):
Expand Down Expand Up @@ -668,7 +663,7 @@ class CamViewSet(MachineTrackerViewSet):

model_class = manage.Cam
serializer_class = serializers.CamSerializer
filter_fields = ('netbox', 'ifindex', 'port')
filterset_fields = ('netbox', 'ifindex', 'port')

def list(self, request):
"""Override list so that we can control what is returned"""
Expand Down Expand Up @@ -710,7 +705,7 @@ class ArpViewSet(MachineTrackerViewSet):

model_class = manage.Arp
serializer_class = serializers.ArpSerializer
filter_fields = ('netbox', 'prefix')
filterset_fields = ('netbox', 'prefix')

def list(self, request):
"""Override list so that we can control what is returned"""
Expand Down Expand Up @@ -756,7 +751,7 @@ class VlanViewSet(NAVAPIMixin, viewsets.ModelViewSet):

queryset = manage.Vlan.objects.all()
serializer_class = serializers.VlanSerializer
filter_fields = [
filterset_fields = [
'vlan',
'net_type',
'net_ident',
Expand All @@ -780,9 +775,9 @@ class PrefixViewSet(NAVAPIMixin, viewsets.ModelViewSet):

queryset = manage.Prefix.objects.all()
serializer_class = serializers.PrefixSerializer
filter_fields = ('vlan', 'net_address', 'vlan__vlan')
filterset_fields = ('vlan', 'net_address', 'vlan__vlan')

@list_route()
@action(detail=False)
def search(self, request):
"""Do string-like prefix searching. Currently only supports net_address."""
net_address = request.GET.get('net_address', None)
Expand Down Expand Up @@ -1054,7 +1049,7 @@ class RackViewSet(NAVAPIMixin, viewsets.ReadOnlyModelViewSet):

queryset = rack.Rack.objects.all()
serializer_class = serializers.RackSerializer
filter_fields = ['room', 'rackname']
filterset_fields = ['room', 'rackname']
search_fields = ['rackname']


Expand Down
10 changes: 5 additions & 5 deletions python/nav/web/ipam/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from rest_framework import viewsets, status, routers
from rest_framework import serializers
from rest_framework.response import Response
from rest_framework.decorators import detail_route, list_route
from rest_framework.decorators import action
from nav.ip import IP

from nav.models.manage import Prefix
Expand Down Expand Up @@ -112,7 +112,7 @@ def get_queryset(self):
queryset.filter_full_prefixes()
return queryset.finalize()

@list_route(methods=["get"])
@action(detail=False, methods=["get"])
def suggest(self, request, *args, **kwargs):
"Suggests subnets of size=?number_of_hosts for ?prefix"
params = SuggestParams(data=request.query_params)
Expand All @@ -127,7 +127,7 @@ def suggest(self, request, *args, **kwargs):
)
return Response(payload, status=status.HTTP_200_OK)

@detail_route(methods=["get"])
@action(detail=True, methods=["get"])
def usage(self, request, *args, **kwargs):
"Return usage for Prefix.pk == pk"
pk = kwargs.pop("pk", None)
Expand Down Expand Up @@ -205,5 +205,5 @@ def list(self, request, *args, **kwargs):


router = routers.SimpleRouter()
router.register(r"^/find", PrefixFinderSet, base_name="ipam-api-finder")
router.register(r"^", PrefixViewSet, base_name="ipam-api")
router.register(r"^/find", PrefixFinderSet, basename="ipam-api-finder")
router.register(r"^", PrefixViewSet, basename="ipam-api")
6 changes: 5 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ Pillow>3.3.2,<8.1
pyrad==2.1
sphinx==3.3.1
sphinxcontrib-django
# Needed for autogenerated docs
Markdown==3.3.6

feedparser==6.0.8
markdown==2.5.1
dnspython==1.15.0

django-filter>=2
djangorestframework>=3.12,<3.13

# REST framework
iso8601

Expand Down
2 changes: 0 additions & 2 deletions requirements/django22.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Django>=2.2,<2.3
django-filter>=2
django-crispy-forms>=1.7,<1.8
crispy-forms-foundation>=0.7,<0.8
djangorestframework>=3.9,<3.10
1 change: 1 addition & 0 deletions requirements/django32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Django>=3.2,<3.3

0 comments on commit 073a6ce

Please sign in to comment.