Skip to content

Commit

Permalink
15156 fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson committed Jun 20, 2024
2 parents 0188813 + 6819186 commit 80b8fa6
Show file tree
Hide file tree
Showing 22 changed files with 267 additions and 19 deletions.
4 changes: 4 additions & 0 deletions docs/models/wireless/wirelesslink.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ The security cipher used to apply wireless authentication. Options include:
### Pre-Shared Key

The security key configured on each client to grant access to the secured wireless LAN. This applies only to certain authentication types.

### Distance

The numeric distance of the link, including a unit designation (e.g. 100 meters or 25 feet).
30 changes: 30 additions & 0 deletions docs/release-notes/version-4.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# NetBox v4.1

## v4.1.0 (FUTURE)

### Breaking Changes

* Several filters deprecated in v4.0 have been removed (see [#15410](https://github.com/netbox-community/netbox/issues/15410)).
* The unit size for virtual disk size has been changed from 1 gigabyte to 1 megabyte. Existing values have been updated accordingly.

### New Features

### Enhancements

* [#7537](https://github.com/netbox-community/netbox/issues/7537) - Add a serial number field for virtual machines
* [#16359](https://github.com/netbox-community/netbox/issues/16359) - Enable plugins to embed content in the top navigation bar

### Other Changes

* [#14692](https://github.com/netbox-community/netbox/issues/14692) - Change atomic unit for virtual disks from 1GB to 1MB
* [#15410](https://github.com/netbox-community/netbox/issues/15410) - Removed various deprecated filters
* [#15908](https://github.com/netbox-community/netbox/issues/15908) - Indicate product edition in release data
* [#16388](https://github.com/netbox-community/netbox/issues/16388) - Move all change logging resources from `extras` to `core`

### REST API Changes

* The `/api/extras/object-changes/` endpoint has moved to `/api/core/object-changes/`
* virtualization.VirtualMachine
* Added the optional `serial` field
* wireless.WirelessLink
* Added the optional `distance` and `distance_unit` fields
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ nav:
- git Cheat Sheet: 'development/git-cheat-sheet.md'
- Release Notes:
- Summary: 'release-notes/index.md'
- Version 4.1: 'release-notes/version-4.1.md'
- Version 4.0: 'release-notes/version-4.0.md'
- Version 3.7: 'release-notes/version-3.7.md'
- Version 3.6: 'release-notes/version-3.6.md'
Expand Down
5 changes: 0 additions & 5 deletions netbox/dcim/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,6 @@ class Meta:
'a_terminations_type', 'b_terminations_type', 'type', 'status', 'tenant_group', 'tenant', 'label', 'color',
'length', 'length_unit', 'description', 'comments', 'tags',
]
error_messages = {
'length': {
'max_value': _('Maximum length is 32767 (any unit)')
}
}


class PowerPanelForm(NetBoxModelForm):
Expand Down
2 changes: 2 additions & 0 deletions netbox/dcim/svg/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ def render(self):
labels = [f"{cable}"] if len(links) > 2 else [f"Wireless {cable}", cable.get_status_display()]
if cable.ssid:
description.append(f"{cable.ssid}")
if cable.distance and cable.distance_unit:
description.append(f"{cable.distance} {cable.get_distance_unit_display()}")
near = [term for term in near_terminations if term.object == cable.interface_a]
far = [term for term in far_terminations if term.object == cable.interface_b]
if not (near and far):
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/tables/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class CableTable(TenancyColumnsMixin, NetBoxTable):
status = columns.ChoiceFieldColumn()
length = columns.TemplateColumn(
template_code=CABLE_LENGTH,
order_by=('_abs_length', 'length_unit')
order_by=('_abs_length')
)
color = columns.ColorColumn()
comments = columns.MarkdownColumn()
Expand Down
69 changes: 68 additions & 1 deletion netbox/extras/migrations/0116_move_objectchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update_dashboard_widgets(apps, schema_editor):

for dashboard in Dashboard.objects.all():
for key, widget in dashboard.config.items():
if getattr(widget['config'], 'model') == 'extras.objectchange':
if widget['config'].get('model') == 'extras.objectchange':
widget['config']['model'] = 'core.objectchange'
elif models := widget['config'].get('models'):
models = list(map(lambda x: x.replace('extras.objectchange', 'core.objectchange'), models))
Expand All @@ -44,6 +44,73 @@ class Migration(migrations.Migration):
name='ObjectChange',
table='core_objectchange',
),

# Rename PK sequence
migrations.RunSQL(
"ALTER TABLE extras_objectchange_id_seq"
" RENAME TO core_objectchange_id_seq"
),

# Rename indexes. Hashes generated by schema_editor._create_index_name()
migrations.RunSQL(
"ALTER INDEX extras_objectchange_pkey"
" RENAME TO core_objectchange_pkey"
),
migrations.RunSQL(
"ALTER INDEX extras_obje_changed_927fe5_idx"
" RENAME TO core_objectchange_changed_object_type_id_cha_79a9ed1e"
),
migrations.RunSQL(
"ALTER INDEX extras_obje_related_bfcdef_idx"
" RENAME TO core_objectchange_related_object_type_id_rel_a71d604a"
),
migrations.RunSQL(
"ALTER INDEX extras_objectchange_changed_object_type_id_b755bb60"
" RENAME TO core_objectchange_changed_object_type_id_2070ade6"
),
migrations.RunSQL(
"ALTER INDEX extras_objectchange_related_object_type_id_fe6e521f"
" RENAME TO core_objectchange_related_object_type_id_b80958af"
),
migrations.RunSQL(
"ALTER INDEX extras_objectchange_request_id_4ae21e90"
" RENAME TO core_objectchange_request_id_d9d160ac"
),
migrations.RunSQL(
"ALTER INDEX extras_objectchange_time_224380ea"
" RENAME TO core_objectchange_time_800f60a5"
),
migrations.RunSQL(
"ALTER INDEX extras_objectchange_user_id_7fdf8186"
" RENAME TO core_objectchange_user_id_2b2142be"
),

# Rename constraints
migrations.RunSQL(
"ALTER TABLE core_objectchange RENAME CONSTRAINT "
"extras_objectchange_changed_object_id_check TO "
"core_objectchange_changed_object_id_check"
),
migrations.RunSQL(
"ALTER TABLE core_objectchange RENAME CONSTRAINT "
"extras_objectchange_related_object_id_check TO "
"core_objectchange_related_object_id_check"
),
migrations.RunSQL(
"ALTER TABLE core_objectchange RENAME CONSTRAINT "
"extras_objectchange_changed_object_type__b755bb60_fk_django_co TO "
"core_objectchange_changed_object_type_id_2070ade6"
),
migrations.RunSQL(
"ALTER TABLE core_objectchange RENAME CONSTRAINT "
"extras_objectchange_related_object_type__fe6e521f_fk_django_co TO "
"core_objectchange_related_object_type_id_b80958af"
),
migrations.RunSQL(
"ALTER TABLE core_objectchange RENAME CONSTRAINT "
"extras_objectchange_user_id_7fdf8186_fk_auth_user_id TO "
"core_objectchange_user_id_2b2142be"
),
],
),
migrations.RunPython(
Expand Down
10 changes: 10 additions & 0 deletions netbox/templates/wireless/wirelesslink.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ <h5 class="card-header">{% trans "Link Properties" %}</h5>
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Distance" %}</th>
<td>
{% if object.distance is not None %}
{{ object.distance|floatformat }} {{ object.get_distance_unit_display }}
{% else %}
{{ ''|placeholder }}
{% endif %}
</td>
</tr>
</table>
</div>
{% include 'inc/panels/tags.html' %}
Expand Down
5 changes: 3 additions & 2 deletions netbox/wireless/api/serializers_/wirelesslinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class WirelessLinkSerializer(NetBoxModelSerializer):
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
auth_type = ChoiceField(choices=WirelessAuthTypeChoices, required=False, allow_blank=True)
auth_cipher = ChoiceField(choices=WirelessAuthCipherChoices, required=False, allow_blank=True)
distance_unit = ChoiceField(choices=WirelessLinkDistanceUnitChoices, allow_blank=True, required=False, allow_null=True)

class Meta:
model = WirelessLink
fields = [
'id', 'url', 'display_url', 'display', 'interface_a', 'interface_b', 'ssid', 'status', 'tenant',
'auth_type', 'auth_cipher', 'auth_psk', 'description', 'comments', 'tags', 'custom_fields',
'created', 'last_updated',
'auth_type', 'auth_cipher', 'auth_psk', 'distance', 'distance_unit', 'description',
'comments', 'tags', 'custom_fields', 'created', 'last_updated',
]
brief_fields = ('id', 'url', 'display', 'ssid', 'description')
18 changes: 18 additions & 0 deletions netbox/wireless/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,21 @@ class WirelessAuthCipherChoices(ChoiceSet):
(CIPHER_TKIP, 'TKIP'),
(CIPHER_AES, 'AES'),
)


class WirelessLinkDistanceUnitChoices(ChoiceSet):

# Metric
UNIT_KILOMETER = 'km'
UNIT_METER = 'm'

# Imperial
UNIT_MILE = 'mi'
UNIT_FOOT = 'ft'

CHOICES = (
(UNIT_KILOMETER, _('Kilometers')),
(UNIT_METER, _('Meters')),
(UNIT_MILE, _('Miles')),
(UNIT_FOOT, _('Feet')),
)
2 changes: 1 addition & 1 deletion netbox/wireless/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class WirelessLinkFilterSet(NetBoxModelFilterSet, TenancyFilterSet):

class Meta:
model = WirelessLink
fields = ('id', 'ssid', 'auth_psk', 'description')
fields = ('id', 'ssid', 'auth_psk', 'distance', 'distance_unit', 'description')

def search(self, queryset, name, value):
if not value.strip():
Expand Down
16 changes: 14 additions & 2 deletions netbox/wireless/forms/bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
required=False,
label=_('Pre-shared key')
)
distance = forms.DecimalField(
label=_('Distance'),
min_value=0,
required=False
)
distance_unit = forms.ChoiceField(
label=_('Distance unit'),
choices=add_blank_choice(WirelessLinkDistanceUnitChoices),
required=False,
initial=''
)
description = forms.CharField(
label=_('Description'),
max_length=200,
Expand All @@ -135,8 +146,9 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
model = WirelessLink
fieldsets = (
FieldSet('ssid', 'status', 'tenant', 'description'),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication'))
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
FieldSet('distance', 'distance_unit', name=_('Attributes')),
)
nullable_fields = (
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'distance', 'comments',
)
10 changes: 8 additions & 2 deletions netbox/wireless/forms/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ class WirelessLinkImportForm(NetBoxModelImportForm):
required=False,
help_text=_('Authentication cipher')
)
distance_unit = CSVChoiceField(
label=_('Distance unit'),
choices=WirelessLinkDistanceUnitChoices,
required=False,
help_text=_('Distance unit')
)

class Meta:
model = WirelessLink
fields = (
'interface_a', 'interface_b', 'ssid', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments', 'tags',
'interface_a', 'interface_b', 'ssid', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk',
'distance', 'distance_unit', 'description', 'comments', 'tags',
)
11 changes: 10 additions & 1 deletion netbox/wireless/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class WirelessLinkFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
model = WirelessLink
fieldsets = (
FieldSet('q', 'filter_id', 'tag'),
FieldSet('ssid', 'status', name=_('Attributes')),
FieldSet('ssid', 'status', 'distance', 'distance_unit', name=_('Attributes')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
Expand All @@ -98,4 +98,13 @@ class WirelessLinkFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
label=_('Pre-shared key'),
required=False
)
distance = forms.DecimalField(
label=_('Distance'),
required=False,
)
distance_unit = forms.ChoiceField(
label=_('Distance unit'),
choices=add_blank_choice(WirelessLinkDistanceUnitChoices),
required=False
)
tag = TagFilterField(model)
6 changes: 3 additions & 3 deletions netbox/wireless/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
fieldsets = (
FieldSet('site_a', 'location_a', 'device_a', 'interface_a', name=_('Side A')),
FieldSet('site_b', 'location_b', 'device_b', 'interface_b', name=_('Side B')),
FieldSet('status', 'ssid', 'description', 'tags', name=_('Link')),
FieldSet('status', 'ssid', 'distance', 'distance_unit', 'description', 'tags', name=_('Link')),
FieldSet('tenant_group', 'tenant', name=_('Tenancy')),
FieldSet('auth_type', 'auth_cipher', 'auth_psk', name=_('Authentication')),
)
Expand All @@ -168,8 +168,8 @@ class Meta:
model = WirelessLink
fields = [
'site_a', 'location_a', 'device_a', 'interface_a', 'site_b', 'location_b', 'device_b', 'interface_b',
'status', 'ssid', 'tenant_group', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments', 'tags',
'status', 'ssid', 'tenant_group', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk',
'distance', 'distance_unit', 'description', 'comments', 'tags',
]
widgets = {
'auth_psk': PasswordInput(
Expand Down
28 changes: 28 additions & 0 deletions netbox/wireless/migrations/0009_wirelesslink_distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2024-06-12 18:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wireless', '0001_squashed_0008'),
]

operations = [
migrations.AddField(
model_name='wirelesslink',
name='_abs_distance',
field=models.DecimalField(blank=True, decimal_places=4, max_digits=10, null=True),
),
migrations.AddField(
model_name='wirelesslink',
name='distance',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True),
),
migrations.AddField(
model_name='wirelesslink',
name='distance_unit',
field=models.CharField(blank=True, max_length=50),
),
]
Loading

0 comments on commit 80b8fa6

Please sign in to comment.