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

Fixes: #17732 - PNG background color in docs #17783

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 0 additions & 8 deletions docs/configuration/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ The maximum size (in bytes) of an incoming HTTP request (i.e. `GET` or `POST` da

---

## DJANGO_ADMIN_ENABLED

Default: False

Setting this to True installs the `django.contrib.admin` app and enables the [Django admin UI](https://docs.djangoproject.com/en/5.0/ref/contrib/admin/). This may be necessary to support older plugins which do not integrate with the native NetBox interface.

---

## ENFORCE_GLOBAL_UNIQUE

!!! tip "Dynamic Configuration Parameter"
Expand Down
1 change: 1 addition & 0 deletions docs/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ img {
display: block;
margin-left: auto;
margin-right: auto;
background-color: rgba(255, 255, 255, 0.64);
}

/* Tables */
Expand Down
6 changes: 6 additions & 0 deletions docs/models/circuits/circuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ The operational status of the circuit. By default, the following statuses are av
!!! tip "Custom circuit statuses"
Additional circuit statuses may be defined by setting `Circuit.status` under the [`FIELD_CHOICES`](../../configuration/data-validation.md#field_choices) configuration parameter.

### Distance

!!! info "This field was introduced in NetBox v4.2."

The distance between the circuit's two endpoints, including a unit designation (e.g. 100 meters or 25 feet).

### Description

A brief description of the circuit.
Expand Down
4 changes: 4 additions & 0 deletions docs/models/dcim/inventoryitem.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ The serial number assigned by the manufacturer.
### Asset Tag

A unique, locally-administered label used to identify hardware resources.

### Status

The inventory item's operational status.
4 changes: 4 additions & 0 deletions docs/models/dcim/poweroutlet.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ An alternative physical label identifying the power outlet.

The type of power outlet.

### Color

The power outlet's color (optional).

### Power Port

When modeling a device which redistributes power from an upstream supply, such as a power distribution unit (PDU), each power outlet should be mapped to the respective [power port](./powerport.md) on the device which supplies power. For example, a 24-outlet PDU may two power ports, each distributing power to 12 of its outlets.
Expand Down
3 changes: 3 additions & 0 deletions docs/models/extras/branch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Branches

!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.

A branch is a collection of related [staged changes](./stagedchange.md) that have been prepared for merging into the active database. A branch can be merged by executing its `commit()` method. Deleting a branch will delete all its related changes.

## Fields
Expand Down
3 changes: 3 additions & 0 deletions docs/models/extras/stagedchange.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Staged Changes

!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.

A staged change represents the creation of a new object or the modification or deletion of an existing object to be performed at some future point. Each change must be assigned to a [branch](./branch.md).

Changes can be applied individually via the `apply()` method, however it is recommended to apply changes in bulk using the parent branch's `commit()` method.
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/development/staged-changes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Staged Changes

!!! danger "Experimental Feature"
This feature is still under active development and considered experimental in nature. Its use in production is strongly discouraged at this time.
!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.

NetBox provides a programmatic API to stage the creation, modification, and deletion of objects without actually committing those changes to the active database. This can be useful for performing a "dry run" of bulk operations, or preparing a set of changes for administrative approval, for example.

Expand Down
4 changes: 3 additions & 1 deletion netbox/circuits/api/serializers_/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dcim.api.serializers_.sites import SiteSerializer
from netbox.api.fields import ChoiceField, RelatedObjectCountField
from netbox.api.serializers import NetBoxModelSerializer, WritableNestedSerializer
from netbox.choices import DistanceUnitChoices
from tenancy.api.serializers_.tenants import TenantSerializer

from .providers import ProviderAccountSerializer, ProviderNetworkSerializer, ProviderSerializer
Expand Down Expand Up @@ -80,13 +81,14 @@ class CircuitSerializer(NetBoxModelSerializer):
termination_a = CircuitCircuitTerminationSerializer(read_only=True, allow_null=True)
termination_z = CircuitCircuitTerminationSerializer(read_only=True, allow_null=True)
assignments = CircuitGroupAssignmentSerializer_(nested=True, many=True, required=False)
distance_unit = ChoiceField(choices=DistanceUnitChoices, allow_blank=True, required=False, allow_null=True)

class Meta:
model = Circuit
fields = [
'id', 'url', 'display_url', 'display', 'cid', 'provider', 'provider_account', 'type', 'status', 'tenant',
'install_date', 'termination_date', 'commit_rate', 'description', 'termination_a', 'termination_z',
'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'assignments',
'distance', 'distance_unit', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'assignments',
]
brief_fields = ('id', 'url', 'display', 'provider', 'cid', 'description')

Expand Down
2 changes: 1 addition & 1 deletion netbox/circuits/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CircuitFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilte

class Meta:
model = Circuit
fields = ('id', 'cid', 'description', 'install_date', 'termination_date', 'commit_rate')
fields = ('id', 'cid', 'description', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit')

def search(self, queryset, name, value):
if not value.strip():
Expand Down
13 changes: 13 additions & 0 deletions netbox/circuits/forms/bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from circuits.models import *
from dcim.models import Site
from ipam.models import ASN
from netbox.choices import DistanceUnitChoices
from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import add_blank_choice
Expand Down Expand Up @@ -160,6 +161,17 @@ class CircuitBulkEditForm(NetBoxModelBulkEditForm):
options=CircuitCommitRateChoices
)
)
distance = forms.DecimalField(
label=_('Distance'),
min_value=0,
required=False
)
distance_unit = forms.ChoiceField(
label=_('Distance unit'),
choices=add_blank_choice(DistanceUnitChoices),
required=False,
initial=''
)
description = forms.CharField(
label=_('Description'),
max_length=100,
Expand All @@ -171,6 +183,7 @@ class CircuitBulkEditForm(NetBoxModelBulkEditForm):
fieldsets = (
FieldSet('provider', 'type', 'status', 'description', name=_('Circuit')),
FieldSet('provider_account', 'install_date', 'termination_date', 'commit_rate', name=_('Service Parameters')),
FieldSet('distance', 'distance_unit', name=_('Attributes')),
FieldSet('tenant', name=_('Tenancy')),
)
nullable_fields = (
Expand Down
9 changes: 8 additions & 1 deletion netbox/circuits/forms/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from circuits.choices import *
from circuits.models import *
from dcim.models import Site
from netbox.choices import DistanceUnitChoices
from netbox.forms import NetBoxModelImportForm
from tenancy.models import Tenant
from utilities.forms.fields import CSVChoiceField, CSVModelChoiceField, SlugField
Expand Down Expand Up @@ -94,6 +95,12 @@ class CircuitImportForm(NetBoxModelImportForm):
choices=CircuitStatusChoices,
help_text=_('Operational status')
)
distance_unit = CSVChoiceField(
label=_('Distance unit'),
choices=DistanceUnitChoices,
required=False,
help_text=_('Distance unit')
)
tenant = CSVModelChoiceField(
label=_('Tenant'),
queryset=Tenant.objects.all(),
Expand All @@ -106,7 +113,7 @@ class Meta:
model = Circuit
fields = [
'cid', 'provider', 'provider_account', 'type', 'status', 'tenant', 'install_date', 'termination_date',
'commit_rate', 'description', 'comments', 'tags'
'commit_rate', 'distance', 'distance_unit', 'description', 'comments', 'tags'
]


Expand Down
13 changes: 12 additions & 1 deletion netbox/circuits/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from circuits.models import *
from dcim.models import Region, Site, SiteGroup
from ipam.models import ASN
from netbox.choices import DistanceUnitChoices
from netbox.forms import NetBoxModelFilterSetForm
from tenancy.forms import TenancyFilterForm, ContactModelFilterForm
from utilities.forms import add_blank_choice
from utilities.forms.fields import ColorField, DynamicModelMultipleChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import DatePicker, NumberWithOptions
Expand Down Expand Up @@ -114,7 +116,7 @@ class CircuitFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFi
fieldsets = (
FieldSet('q', 'filter_id', 'tag'),
FieldSet('provider_id', 'provider_account_id', 'provider_network_id', name=_('Provider')),
FieldSet('type_id', 'status', 'install_date', 'termination_date', 'commit_rate', name=_('Attributes')),
FieldSet('type_id', 'status', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit', name=_('Attributes')),
FieldSet('region_id', 'site_group_id', 'site_id', name=_('Location')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts')),
Expand Down Expand Up @@ -188,6 +190,15 @@ class CircuitFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFi
options=CircuitCommitRateChoices
)
)
distance = forms.DecimalField(
label=_('Distance'),
required=False,
)
distance_unit = forms.ChoiceField(
label=_('Distance unit'),
choices=add_blank_choice(DistanceUnitChoices),
required=False
)
tag = TagFilterField(model)


Expand Down
16 changes: 13 additions & 3 deletions netbox/circuits/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from netbox.forms import NetBoxModelForm
from tenancy.forms import TenancyForm
from utilities.forms.fields import CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField
from utilities.forms.rendering import FieldSet, TabbedGroups
from utilities.forms.rendering import FieldSet, InlineFields, TabbedGroups
from utilities.forms.widgets import DatePicker, NumberWithOptions

__all__ = (
Expand Down Expand Up @@ -108,7 +108,17 @@ class CircuitForm(TenancyForm, NetBoxModelForm):
comments = CommentField()

fieldsets = (
FieldSet('provider', 'provider_account', 'cid', 'type', 'status', 'description', 'tags', name=_('Circuit')),
FieldSet(
'provider',
'provider_account',
'cid',
'type',
'status',
InlineFields('distance', 'distance_unit', label=_('Distance')),
'description',
'tags',
name=_('Circuit')
),
FieldSet('install_date', 'termination_date', 'commit_rate', name=_('Service Parameters')),
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
)
Expand All @@ -117,7 +127,7 @@ class Meta:
model = Circuit
fields = [
'cid', 'type', 'provider', 'provider_account', 'status', 'install_date', 'termination_date', 'commit_rate',
'description', 'tenant_group', 'tenant', 'comments', 'tags',
'distance', 'distance_unit', 'description', 'tenant_group', 'tenant', 'comments', 'tags',
]
widgets = {
'install_date': DatePicker(),
Expand Down
28 changes: 28 additions & 0 deletions netbox/circuits/migrations/0045_circuit_distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.9 on 2024-09-26 22:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('circuits', '0044_circuit_groups'),
]

operations = [
migrations.AddField(
model_name='circuit',
name='_abs_distance',
field=models.DecimalField(blank=True, decimal_places=4, max_digits=10, null=True),
),
migrations.AddField(
model_name='circuit',
name='distance',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True),
),
migrations.AddField(
model_name='circuit',
name='distance_unit',
field=models.CharField(blank=True, max_length=50),
),
]
12 changes: 2 additions & 10 deletions netbox/circuits/models/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from circuits.choices import *
from dcim.models import CabledObjectModel
from netbox.models import ChangeLoggedModel, OrganizationalModel, PrimaryModel
from netbox.models.mixins import DistanceMixin
from netbox.models.features import ContactsMixin, CustomFieldsMixin, CustomLinksMixin, ExportTemplatesMixin, ImageAttachmentsMixin, TagsMixin
from utilities.fields import ColorField

Expand All @@ -28,16 +29,13 @@ class CircuitType(OrganizationalModel):
blank=True
)

def get_absolute_url(self):
return reverse('circuits:circuittype', args=[self.pk])

class Meta:
ordering = ('name',)
verbose_name = _('circuit type')
verbose_name_plural = _('circuit types')


class Circuit(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
class Circuit(ContactsMixin, ImageAttachmentsMixin, DistanceMixin, PrimaryModel):
"""
A communications circuit connects two points. Each Circuit belongs to a Provider; Providers may have multiple
circuits. Each circuit is also assigned a CircuitType and a Site, and may optionally be assigned to a particular
Expand Down Expand Up @@ -140,9 +138,6 @@ class Meta:
def __str__(self):
return self.cid

def get_absolute_url(self):
return reverse('circuits:circuit', args=[self.pk])

def get_status_color(self):
return CircuitStatusChoices.colors.get(self.status)

Expand Down Expand Up @@ -173,9 +168,6 @@ class Meta:
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse('circuits:circuitgroup', args=[self.pk])


class CircuitGroupAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLoggedModel):
"""
Expand Down
10 changes: 0 additions & 10 deletions netbox/circuits/models/providers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import models
from django.db.models import Q
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from netbox.models import PrimaryModel
Expand Down Expand Up @@ -45,9 +44,6 @@ class Meta:
def __str__(self):
return self.name

def get_absolute_url(self):
return reverse('circuits:provider', args=[self.pk])


class ProviderAccount(ContactsMixin, PrimaryModel):
"""
Expand Down Expand Up @@ -91,9 +87,6 @@ def __str__(self):
return f'{self.account} ({self.name})'
return f'{self.account}'

def get_absolute_url(self):
return reverse('circuits:provideraccount', args=[self.pk])


class ProviderNetwork(PrimaryModel):
"""
Expand Down Expand Up @@ -128,6 +121,3 @@ class Meta:

def __str__(self):
return self.name

def get_absolute_url(self):
return reverse('circuits:providernetwork', args=[self.pk])
1 change: 1 addition & 0 deletions netbox/circuits/tables/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
commit_rate = CommitRateColumn(
verbose_name=_('Commit Rate')
)
distance = columns.DistanceColumn()
comments = columns.MarkdownColumn(
verbose_name=_('Comments')
)
Expand Down
Loading