mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 04:56:29 -06:00
Closes #695: Added is_private field to RIR
This commit is contained in:
parent
6e5950be77
commit
f007b0dbde
@ -28,7 +28,7 @@ class RIRAdmin(admin.ModelAdmin):
|
|||||||
prepopulated_fields = {
|
prepopulated_fields = {
|
||||||
'slug': ['name'],
|
'slug': ['name'],
|
||||||
}
|
}
|
||||||
list_display = ['name', 'slug']
|
list_display = ['name', 'slug', 'is_private']
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Aggregate)
|
@admin.register(Aggregate)
|
||||||
|
@ -58,13 +58,13 @@ class RIRSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RIR
|
model = RIR
|
||||||
fields = ['id', 'name', 'slug']
|
fields = ['id', 'name', 'slug', 'is_private']
|
||||||
|
|
||||||
|
|
||||||
class RIRNestedSerializer(RIRSerializer):
|
class RIRNestedSerializer(RIRSerializer):
|
||||||
|
|
||||||
class Meta(RIRSerializer.Meta):
|
class Meta(RIRSerializer.Meta):
|
||||||
pass
|
fields = ['id', 'name', 'slug']
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -46,6 +46,13 @@ class VRFFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
|||||||
fields = ['name', 'rd']
|
fields = ['name', 'rd']
|
||||||
|
|
||||||
|
|
||||||
|
class RIRFilter(django_filters.FilterSet):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = RIR
|
||||||
|
fields = ['is_private']
|
||||||
|
|
||||||
|
|
||||||
class AggregateFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
class AggregateFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
||||||
q = django_filters.MethodFilter(
|
q = django_filters.MethodFilter(
|
||||||
action='search',
|
action='search',
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
"pk": 1,
|
"pk": 1,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "ARIN",
|
"name": "ARIN",
|
||||||
"slug": "arin"
|
"slug": "arin",
|
||||||
|
"is_private": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -51,7 +52,8 @@
|
|||||||
"pk": 2,
|
"pk": 2,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "RIPE",
|
"name": "RIPE",
|
||||||
"slug": "ripe"
|
"slug": "ripe",
|
||||||
|
"is_private": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -59,7 +61,8 @@
|
|||||||
"pk": 3,
|
"pk": 3,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "APNIC",
|
"name": "APNIC",
|
||||||
"slug": "apnic"
|
"slug": "apnic",
|
||||||
|
"is_private": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -67,7 +70,8 @@
|
|||||||
"pk": 4,
|
"pk": 4,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "LACNIC",
|
"name": "LACNIC",
|
||||||
"slug": "lacnic"
|
"slug": "lacnic",
|
||||||
|
"is_private": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -75,7 +79,8 @@
|
|||||||
"pk": 5,
|
"pk": 5,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "AFRINIC",
|
"name": "AFRINIC",
|
||||||
"slug": "afrinic"
|
"slug": "afrinic",
|
||||||
|
"is_private": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -83,7 +88,8 @@
|
|||||||
"pk": 6,
|
"pk": 6,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "RFC 1918",
|
"name": "RFC 1918",
|
||||||
"slug": "rfc-1918"
|
"slug": "rfc-1918",
|
||||||
|
"is_private": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,15 @@ class RIRForm(forms.ModelForm, BootstrapMixin):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RIR
|
model = RIR
|
||||||
fields = ['name', 'slug']
|
fields = ['name', 'slug', 'is_private']
|
||||||
|
|
||||||
|
|
||||||
|
class RIRFilterForm(forms.Form, BootstrapMixin):
|
||||||
|
is_private = forms.NullBooleanField(required=False, label='Private', widget=forms.Select(choices=[
|
||||||
|
('', '---------'),
|
||||||
|
('True', 'Yes'),
|
||||||
|
('False', 'No'),
|
||||||
|
]))
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
20
netbox/ipam/migrations/0011_rir_add_is_private.py
Normal file
20
netbox/ipam/migrations/0011_rir_add_is_private.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10 on 2016-12-06 18:27
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ipam', '0010_ipaddress_help_texts'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='rir',
|
||||||
|
name='is_private',
|
||||||
|
field=models.BooleanField(default=False, help_text=b'IP space managed by this RIR is considered private', verbose_name=b'Private'),
|
||||||
|
),
|
||||||
|
]
|
@ -103,6 +103,8 @@ class RIR(models.Model):
|
|||||||
"""
|
"""
|
||||||
name = models.CharField(max_length=50, unique=True)
|
name = models.CharField(max_length=50, unique=True)
|
||||||
slug = models.SlugField(unique=True)
|
slug = models.SlugField(unique=True)
|
||||||
|
is_private = models.BooleanField(default=False, verbose_name='Private',
|
||||||
|
help_text='IP space managed by this RIR is considered private')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
|
@ -126,6 +126,7 @@ class VRFTable(BaseTable):
|
|||||||
class RIRTable(BaseTable):
|
class RIRTable(BaseTable):
|
||||||
pk = ToggleColumn()
|
pk = ToggleColumn()
|
||||||
name = tables.LinkColumn(verbose_name='Name')
|
name = tables.LinkColumn(verbose_name='Name')
|
||||||
|
is_private = tables.BooleanColumn(verbose_name='Private')
|
||||||
aggregate_count = tables.Column(verbose_name='Aggregates')
|
aggregate_count = tables.Column(verbose_name='Aggregates')
|
||||||
stats_total = tables.Column(accessor='stats.total', verbose_name='Total',
|
stats_total = tables.Column(accessor='stats.total', verbose_name='Total',
|
||||||
footer=lambda table: sum(r.stats['total'] for r in table.data))
|
footer=lambda table: sum(r.stats['total'] for r in table.data))
|
||||||
@ -142,7 +143,8 @@ class RIRTable(BaseTable):
|
|||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = RIR
|
model = RIR
|
||||||
fields = ('pk', 'name', 'aggregate_count', 'stats_total', 'stats_active', 'stats_reserved', 'stats_deprecated', 'stats_available', 'utilization', 'actions')
|
fields = ('pk', 'name', 'is_private', 'aggregate_count', 'stats_total', 'stats_active', 'stats_reserved',
|
||||||
|
'stats_deprecated', 'stats_available', 'utilization', 'actions')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -154,6 +154,8 @@ class VRFBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
|
|||||||
|
|
||||||
class RIRListView(ObjectListView):
|
class RIRListView(ObjectListView):
|
||||||
queryset = RIR.objects.annotate(aggregate_count=Count('aggregates'))
|
queryset = RIR.objects.annotate(aggregate_count=Count('aggregates'))
|
||||||
|
filter = filters.RIRFilter
|
||||||
|
filter_form = forms.RIRFilterForm
|
||||||
table = tables.RIRTable
|
table = tables.RIRTable
|
||||||
edit_permissions = ['ipam.change_rir', 'ipam.delete_rir']
|
edit_permissions = ['ipam.change_rir', 'ipam.delete_rir']
|
||||||
template_name = 'ipam/rir_list.html'
|
template_name = 'ipam/rir_list.html'
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
IPv4 Stats
|
IPv4 Stats
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{% url 'ipam:rir_list' %}?family=6" class="btn btn-default">
|
<a href="{% url 'ipam:rir_list' %}?family=6{% if request.GET %}&{{ request.GET.urlencode }}{% endif %}" class="btn btn-default">
|
||||||
<span class="fa fa-table" aria-hidden="true"></span>
|
<span class="fa fa-table" aria-hidden="true"></span>
|
||||||
IPv6 Stats
|
IPv6 Stats
|
||||||
</a>
|
</a>
|
||||||
@ -26,11 +26,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>RIRs</h1>
|
<h1>RIRs</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-9">
|
||||||
{% include 'utilities/obj_table.html' with bulk_delete_url='ipam:rir_bulk_delete' %}
|
{% include 'utilities/obj_table.html' with bulk_delete_url='ipam:rir_bulk_delete' %}
|
||||||
|
{% if request.GET.family == '6' %}
|
||||||
|
<div class="alert alert-info pull-right"><strong>Note:</strong> Numbers shown indicate /64 prefixes.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
{% include 'inc/filter_panel.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if request.GET.family == '6' %}
|
|
||||||
<div class="pull-right text-muted"><strong>Note:</strong> Numbers shown indicate /64 prefixes.</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user