mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Delete deprecated ipam.Status model
This commit is contained in:
@ -8,14 +8,6 @@ class VRFAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'rd']
|
||||
|
||||
|
||||
@admin.register(Status)
|
||||
class StatusAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {
|
||||
'slug': ['name'],
|
||||
}
|
||||
list_display = ['name', 'slug', 'weight', 'bootstrap_class']
|
||||
|
||||
|
||||
@admin.register(Role)
|
||||
class RoleAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from dcim.api.serializers import SiteNestedSerializer, InterfaceNestedSerializer
|
||||
from ipam.models import VRF, Status, Role, RIR, Aggregate, Prefix, IPAddress, VLAN
|
||||
from ipam.models import VRF, Role, RIR, Aggregate, Prefix, IPAddress, VLAN
|
||||
|
||||
|
||||
#
|
||||
@ -21,23 +21,6 @@ class VRFNestedSerializer(VRFSerializer):
|
||||
fields = ['id', 'name', 'rd']
|
||||
|
||||
|
||||
#
|
||||
# Statuses
|
||||
#
|
||||
|
||||
class StatusSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Status
|
||||
fields = ['id', 'name', 'slug', 'weight', 'bootstrap_class']
|
||||
|
||||
|
||||
class StatusNestedSerializer(StatusSerializer):
|
||||
|
||||
class Meta(StatusSerializer.Meta):
|
||||
fields = ['id', 'name', 'slug']
|
||||
|
||||
|
||||
#
|
||||
# Roles
|
||||
#
|
||||
@ -97,7 +80,6 @@ class AggregateNestedSerializer(AggregateSerializer):
|
||||
class VLANSerializer(serializers.ModelSerializer):
|
||||
display_name = serializers.SerializerMethodField()
|
||||
site = SiteNestedSerializer()
|
||||
status = StatusNestedSerializer()
|
||||
role = RoleNestedSerializer()
|
||||
|
||||
class Meta:
|
||||
@ -122,7 +104,6 @@ class PrefixSerializer(serializers.ModelSerializer):
|
||||
site = SiteNestedSerializer()
|
||||
vrf = VRFNestedSerializer()
|
||||
vlan = VLANNestedSerializer()
|
||||
status = StatusNestedSerializer()
|
||||
role = RoleNestedSerializer()
|
||||
|
||||
class Meta:
|
||||
|
@ -9,10 +9,6 @@ urlpatterns = [
|
||||
url(r'^vrfs/$', VRFListView.as_view(), name='vrf_list'),
|
||||
url(r'^vrfs/(?P<pk>\d+)/$', VRFDetailView.as_view(), name='vrf_detail'),
|
||||
|
||||
# Statuses
|
||||
url(r'^statuses/$', StatusListView.as_view(), name='status_list'),
|
||||
url(r'^statuses/(?P<pk>\d+)/$', StatusDetailView.as_view(), name='status_detail'),
|
||||
|
||||
# Roles
|
||||
url(r'^roles/$', RoleListView.as_view(), name='role_list'),
|
||||
url(r'^roles/(?P<pk>\d+)/$', RoleDetailView.as_view(), name='role_detail'),
|
||||
|
@ -1,9 +1,9 @@
|
||||
from rest_framework import generics
|
||||
|
||||
from ipam.models import VRF, Status, Role, RIR, Aggregate, Prefix, IPAddress, VLAN
|
||||
from ipam.models import VRF, Role, RIR, Aggregate, Prefix, IPAddress, VLAN
|
||||
from ipam.filters import AggregateFilter, PrefixFilter, IPAddressFilter, VLANFilter
|
||||
from .serializers import VRFSerializer, StatusSerializer, RoleSerializer, RIRSerializer, AggregateSerializer, \
|
||||
PrefixSerializer, IPAddressSerializer, VLANSerializer
|
||||
from .serializers import VRFSerializer, RoleSerializer, RIRSerializer, AggregateSerializer, PrefixSerializer,\
|
||||
IPAddressSerializer, VLANSerializer
|
||||
|
||||
|
||||
class VRFListView(generics.ListAPIView):
|
||||
@ -22,22 +22,6 @@ class VRFDetailView(generics.RetrieveAPIView):
|
||||
serializer_class = VRFSerializer
|
||||
|
||||
|
||||
class StatusListView(generics.ListAPIView):
|
||||
"""
|
||||
List all statuses
|
||||
"""
|
||||
queryset = Status.objects.all()
|
||||
serializer_class = StatusSerializer
|
||||
|
||||
|
||||
class StatusDetailView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Retrieve a single status
|
||||
"""
|
||||
queryset = Status.objects.all()
|
||||
serializer_class = StatusSerializer
|
||||
|
||||
|
||||
class RoleListView(generics.ListAPIView):
|
||||
"""
|
||||
List all roles
|
||||
@ -91,7 +75,7 @@ class PrefixListView(generics.ListAPIView):
|
||||
"""
|
||||
List prefixes (filterable)
|
||||
"""
|
||||
queryset = Prefix.objects.select_related('site', 'vrf', 'vlan', 'status', 'role')
|
||||
queryset = Prefix.objects.select_related('site', 'vrf', 'vlan', 'role')
|
||||
serializer_class = PrefixSerializer
|
||||
filter_class = PrefixFilter
|
||||
|
||||
@ -100,7 +84,7 @@ class PrefixDetailView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Retrieve a single prefix
|
||||
"""
|
||||
queryset = Prefix.objects.select_related('site', 'vrf', 'vlan', 'status', 'role')
|
||||
queryset = Prefix.objects.select_related('site', 'vrf', 'vlan', 'role')
|
||||
serializer_class = PrefixSerializer
|
||||
|
||||
|
||||
@ -127,7 +111,7 @@ class VLANListView(generics.ListAPIView):
|
||||
"""
|
||||
List VLANs (filterable)
|
||||
"""
|
||||
queryset = VLAN.objects.select_related('site', 'status', 'role')
|
||||
queryset = VLAN.objects.select_related('site', 'role')
|
||||
serializer_class = VLANSerializer
|
||||
filter_class = VLANFilter
|
||||
|
||||
@ -136,5 +120,5 @@ class VLANDetailView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Retrieve a single VLAN
|
||||
"""
|
||||
queryset = VLAN.objects.select_related('site', 'status', 'role')
|
||||
queryset = VLAN.objects.select_related('site', 'role')
|
||||
serializer_class = VLANSerializer
|
||||
|
@ -3,7 +3,7 @@ from netaddr import IPNetwork
|
||||
from netaddr.core import AddrFormatError
|
||||
|
||||
from dcim.models import Site, Device, Interface
|
||||
from ipam.models import RIR, Aggregate, VRF, Prefix, IPAddress, VLAN, Status, Role
|
||||
from ipam.models import RIR, Aggregate, VRF, Prefix, IPAddress, VLAN, Role
|
||||
|
||||
|
||||
class VRFFilter(django_filters.FilterSet):
|
||||
|
@ -1,9 +1,3 @@
|
||||
- model: ipam.status
|
||||
pk: 1
|
||||
fields: {name: Active, slug: active, weight: 1000, bootstrap_class: 1}
|
||||
- model: ipam.status
|
||||
pk: 2
|
||||
fields: {name: Inactive, slug: inactive, weight: 500, bootstrap_class: 3}
|
||||
- model: ipam.role
|
||||
pk: 1
|
||||
fields: {name: Lab Network, slug: lab-network, weight: 1000}
|
||||
|
@ -5,8 +5,7 @@ from django.db.models import Count
|
||||
|
||||
from dcim.models import Site, Device, Interface
|
||||
from utilities.forms import BootstrapMixin, ConfirmationForm, APISelect, Livesearch, CSVDataField, BulkImportForm
|
||||
from .models import VRF, RIR, Aggregate, Role, Status, Prefix, IPAddress, VLAN, PREFIX_STATUS_CHOICES,\
|
||||
VLAN_STATUS_CHOICES
|
||||
from .models import VRF, RIR, Aggregate, Role, Prefix, IPAddress, VLAN, PREFIX_STATUS_CHOICES, VLAN_STATUS_CHOICES
|
||||
|
||||
|
||||
#
|
||||
@ -181,8 +180,6 @@ class PrefixFromCSVForm(forms.ModelForm):
|
||||
error_messages={'invalid_choice': 'VRF not found.'})
|
||||
site = forms.ModelChoiceField(queryset=Site.objects.all(), required=False, to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Site not found.'})
|
||||
status = forms.ModelChoiceField(queryset=Status.objects.all(), to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Invalid status.'})
|
||||
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False, to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Invalid role.'})
|
||||
|
||||
@ -201,7 +198,6 @@ class PrefixBulkEditForm(forms.Form, BootstrapMixin):
|
||||
vrf = forms.ModelChoiceField(queryset=VRF.objects.all(), required=False, label='VRF',
|
||||
help_text="Select the VRF to assign, or check below to remove VRF assignment")
|
||||
vrf_global = forms.BooleanField(required=False, label='Set VRF to global')
|
||||
status = forms.ModelChoiceField(queryset=Status.objects.all(), required=False)
|
||||
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False)
|
||||
description = forms.CharField(max_length=50, required=False)
|
||||
|
||||
@ -396,8 +392,6 @@ class VLANForm(forms.ModelForm, BootstrapMixin):
|
||||
class VLANFromCSVForm(forms.ModelForm):
|
||||
site = forms.ModelChoiceField(queryset=Site.objects.all(), to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Device not found.'})
|
||||
status = forms.ModelChoiceField(queryset=Status.objects.all(), to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Invalid status.'})
|
||||
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False, to_field_name='name',
|
||||
error_messages={'invalid_choice': 'Invalid role.'})
|
||||
|
||||
@ -413,7 +407,6 @@ class VLANImportForm(BulkImportForm, BootstrapMixin):
|
||||
class VLANBulkEditForm(forms.Form, BootstrapMixin):
|
||||
pk = forms.ModelMultipleChoiceField(queryset=VLAN.objects.all(), widget=forms.MultipleHiddenInput)
|
||||
site = forms.ModelChoiceField(queryset=Site.objects.all(), required=False)
|
||||
status = forms.ModelChoiceField(queryset=Status.objects.all(), required=False)
|
||||
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False)
|
||||
|
||||
|
||||
|
18
netbox/ipam/migrations/0005_delete_status.py
Normal file
18
netbox/ipam/migrations/0005_delete_status.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.5 on 2016-05-17 20:54
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ipam', '0004_auto_20160517_2044'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name='Status',
|
||||
),
|
||||
]
|
@ -27,15 +27,6 @@ VLAN_STATUS_CHOICES = (
|
||||
(3, 'Deprecated')
|
||||
)
|
||||
|
||||
BOOTSTRAP_CLASS_CHOICES = (
|
||||
(0, 'Default'),
|
||||
(1, 'Primary'),
|
||||
(2, 'Success'),
|
||||
(3, 'Info'),
|
||||
(4, 'Warning'),
|
||||
(5, 'Danger'),
|
||||
)
|
||||
|
||||
STATUS_CHOICE_CLASSES = {
|
||||
0: 'default',
|
||||
1: 'primary',
|
||||
@ -136,23 +127,6 @@ class Aggregate(models.Model):
|
||||
return int(children_size / self.prefix.size * 100)
|
||||
|
||||
|
||||
class Status(models.Model):
|
||||
"""
|
||||
The status of a prefix or VLAN (e.g. allocated, reserved, etc.)
|
||||
"""
|
||||
name = models.CharField(max_length=50, unique=True)
|
||||
slug = models.SlugField(unique=True)
|
||||
weight = models.PositiveSmallIntegerField(default=1000)
|
||||
bootstrap_class = models.PositiveSmallIntegerField(choices=BOOTSTRAP_CLASS_CHOICES, default=0)
|
||||
|
||||
class Meta:
|
||||
ordering = ['weight', 'name']
|
||||
verbose_name_plural = 'statuses'
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Role(models.Model):
|
||||
"""
|
||||
The role of an address resource (e.g. customer, infrastructure, mgmt, etc.)
|
||||
|
Reference in New Issue
Block a user