mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Closes #7748: Remove legacy contact fields from site model
This commit is contained in:
parent
8680981990
commit
d2d2978288
@ -8,8 +8,15 @@
|
||||
### Breaking Changes
|
||||
|
||||
* Automatic redirection of legacy slug-based URL paths has been removed.
|
||||
* The `contact_name`, `contact_phone`, and `contact_email` fields have been removed from the site model. Please use the new contact model introduced in NetBox v3.1 to store contact information for sites.
|
||||
|
||||
### Other Changes
|
||||
|
||||
* [#7731](https://github.com/netbox-community/netbox/issues/7731) - Require Python 3.8 or later
|
||||
* [#7748](https://github.com/netbox-community/netbox/issues/7748) - Remove legacy contact fields from site model
|
||||
* [#8031](https://github.com/netbox-community/netbox/issues/8031) - Remove automatic redirection of legacy slug-based URLs
|
||||
|
||||
### REST API Changes
|
||||
|
||||
* dcim.Site
|
||||
* Removed the `contact_name`, `contact_phone`, and `contact_email` fields
|
||||
|
@ -133,9 +133,9 @@ class SiteSerializer(PrimaryModelSerializer):
|
||||
model = Site
|
||||
fields = [
|
||||
'id', 'url', 'display', 'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'asn', 'asns',
|
||||
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
|
||||
'contact_phone', 'contact_email', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
|
||||
'circuit_count', 'device_count', 'prefix_count', 'rack_count', 'virtualmachine_count', 'vlan_count',
|
||||
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'comments',
|
||||
'tags', 'custom_fields', 'created', 'last_updated', 'circuit_count', 'device_count', 'prefix_count',
|
||||
'rack_count', 'virtualmachine_count', 'vlan_count',
|
||||
]
|
||||
|
||||
|
||||
|
@ -140,10 +140,9 @@ class SiteFilterSet(PrimaryModelFilterSet, TenancyFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = Site
|
||||
fields = [
|
||||
'id', 'name', 'slug', 'facility', 'asn', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
||||
'contact_email',
|
||||
]
|
||||
fields = (
|
||||
'id', 'name', 'slug', 'facility', 'asn', 'latitude', 'longitude',
|
||||
)
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -154,9 +153,6 @@ class SiteFilterSet(PrimaryModelFilterSet, TenancyFilterSet):
|
||||
Q(description__icontains=value) |
|
||||
Q(physical_address__icontains=value) |
|
||||
Q(shipping_address__icontains=value) |
|
||||
Q(contact_name__icontains=value) |
|
||||
Q(contact_phone__icontains=value) |
|
||||
Q(contact_email__icontains=value) |
|
||||
Q(comments__icontains=value)
|
||||
)
|
||||
try:
|
||||
|
@ -96,8 +96,7 @@ class SiteCSVForm(CustomFieldModelCSVForm):
|
||||
model = Site
|
||||
fields = (
|
||||
'name', 'slug', 'status', 'region', 'group', 'tenant', 'facility', 'time_zone', 'description',
|
||||
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
||||
'contact_email', 'comments',
|
||||
'physical_address', 'shipping_address', 'latitude', 'longitude', 'comments',
|
||||
)
|
||||
help_texts = {
|
||||
'time_zone': mark_safe(
|
||||
|
@ -132,8 +132,8 @@ class SiteForm(TenancyForm, CustomFieldModelForm):
|
||||
model = Site
|
||||
fields = [
|
||||
'name', 'slug', 'status', 'region', 'group', 'tenant_group', 'tenant', 'facility', 'asn', 'asns',
|
||||
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
|
||||
'contact_phone', 'contact_email', 'comments', 'tags',
|
||||
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'comments',
|
||||
'tags',
|
||||
]
|
||||
fieldsets = (
|
||||
('Site', (
|
||||
@ -141,10 +141,7 @@ class SiteForm(TenancyForm, CustomFieldModelForm):
|
||||
'tags',
|
||||
)),
|
||||
('Tenancy', ('tenant_group', 'tenant')),
|
||||
('Contact Info', (
|
||||
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
||||
'contact_email',
|
||||
)),
|
||||
('Contact Info', ('physical_address', 'shipping_address', 'latitude', 'longitude')),
|
||||
)
|
||||
widgets = {
|
||||
'physical_address': SmallTextarea(
|
||||
|
23
netbox/dcim/migrations/0144_site_remove_deprecated_fields.py
Normal file
23
netbox/dcim/migrations/0144_site_remove_deprecated_fields.py
Normal file
@ -0,0 +1,23 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0143_remove_primary_for_related_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='site',
|
||||
name='contact_email',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='site',
|
||||
name='contact_name',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='site',
|
||||
name='contact_phone',
|
||||
),
|
||||
]
|
@ -288,18 +288,6 @@ class Site(PrimaryModel):
|
||||
null=True,
|
||||
help_text='GPS coordinate (longitude)'
|
||||
)
|
||||
contact_name = models.CharField(
|
||||
max_length=50,
|
||||
blank=True
|
||||
)
|
||||
contact_phone = models.CharField(
|
||||
max_length=20,
|
||||
blank=True
|
||||
)
|
||||
contact_email = models.EmailField(
|
||||
blank=True,
|
||||
verbose_name='Contact E-mail'
|
||||
)
|
||||
comments = models.TextField(
|
||||
blank=True
|
||||
)
|
||||
@ -320,7 +308,7 @@ class Site(PrimaryModel):
|
||||
|
||||
clone_fields = [
|
||||
'status', 'region', 'group', 'tenant', 'facility', 'asn', 'time_zone', 'description', 'physical_address',
|
||||
'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone', 'contact_email',
|
||||
'shipping_address', 'latitude', 'longitude',
|
||||
]
|
||||
|
||||
class Meta:
|
||||
|
@ -97,8 +97,7 @@ class SiteTable(BaseTable):
|
||||
model = Site
|
||||
fields = (
|
||||
'pk', 'id', 'name', 'slug', 'status', 'facility', 'region', 'group', 'tenant', 'asn_count', 'time_zone',
|
||||
'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name',
|
||||
'contact_phone', 'contact_email', 'comments', 'tags',
|
||||
'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'comments', 'tags',
|
||||
)
|
||||
default_columns = ('pk', 'name', 'status', 'facility', 'region', 'group', 'tenant', 'description')
|
||||
|
||||
|
@ -151,9 +151,9 @@ class SiteTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
ASN.objects.bulk_create(asns)
|
||||
|
||||
sites = (
|
||||
Site(name='Site 1', slug='site-1', region=regions[0], group=groups[0], tenant=tenants[0], status=SiteStatusChoices.STATUS_ACTIVE, facility='Facility 1', asn=65001, latitude=10, longitude=10, contact_name='Contact 1', contact_phone='123-555-0001', contact_email='contact1@example.com'),
|
||||
Site(name='Site 2', slug='site-2', region=regions[1], group=groups[1], tenant=tenants[1], status=SiteStatusChoices.STATUS_PLANNED, facility='Facility 2', asn=65002, latitude=20, longitude=20, contact_name='Contact 2', contact_phone='123-555-0002', contact_email='contact2@example.com'),
|
||||
Site(name='Site 3', slug='site-3', region=regions[2], group=groups[2], tenant=tenants[2], status=SiteStatusChoices.STATUS_RETIRED, facility='Facility 3', asn=65003, latitude=30, longitude=30, contact_name='Contact 3', contact_phone='123-555-0003', contact_email='contact3@example.com'),
|
||||
Site(name='Site 1', slug='site-1', region=regions[0], group=groups[0], tenant=tenants[0], status=SiteStatusChoices.STATUS_ACTIVE, facility='Facility 1', asn=65001, latitude=10, longitude=10),
|
||||
Site(name='Site 2', slug='site-2', region=regions[1], group=groups[1], tenant=tenants[1], status=SiteStatusChoices.STATUS_PLANNED, facility='Facility 2', asn=65002, latitude=20, longitude=20),
|
||||
Site(name='Site 3', slug='site-3', region=regions[2], group=groups[2], tenant=tenants[2], status=SiteStatusChoices.STATUS_RETIRED, facility='Facility 3', asn=65003, latitude=30, longitude=30),
|
||||
)
|
||||
Site.objects.bulk_create(sites)
|
||||
sites[0].asns.set([asns[0]])
|
||||
@ -189,18 +189,6 @@ class SiteTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
params = {'longitude': [10, 20]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_contact_name(self):
|
||||
params = {'contact_name': ['Contact 1', 'Contact 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_contact_phone(self):
|
||||
params = {'contact_phone': ['123-555-0001', '123-555-0002']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_contact_email(self):
|
||||
params = {'contact_email': ['contact1@example.com', 'contact2@example.com']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_status(self):
|
||||
params = {'status': [SiteStatusChoices.STATUS_ACTIVE, SiteStatusChoices.STATUS_PLANNED]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
@ -144,9 +144,6 @@ class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
'shipping_address': '742 Evergreen Terrace, Springfield, USA',
|
||||
'latitude': Decimal('35.780000'),
|
||||
'longitude': Decimal('-78.642000'),
|
||||
'contact_name': 'Hank Hill',
|
||||
'contact_phone': '123-555-9999',
|
||||
'contact_email': 'hank@stricklandpropane.com',
|
||||
'comments': 'Test site',
|
||||
'tags': [t.pk for t in tags],
|
||||
}
|
||||
|
@ -127,52 +127,6 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{# Legacy contact fields #}
|
||||
{% with deprecation_warning="This field will be removed in a future release. Please migrate this data to contact objects." %}
|
||||
{% if object.contact_name %}
|
||||
<tr>
|
||||
<th scope="row">Contact Name</th>
|
||||
<td>
|
||||
{% if object.contact_name %}
|
||||
<div class="float-end text-warning">
|
||||
<i class="mdi mdi-alert" title="{{ deprecation_warning }}"></i>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ object.contact_name|placeholder }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if object.contact_phone %}
|
||||
<tr>
|
||||
<th scope="row">Contact Phone</th>
|
||||
<td>
|
||||
{% if object.contact_phone %}
|
||||
<div class="float-end text-warning">
|
||||
<i class="mdi mdi-alert" title="{{ deprecation_warning }}"></i>
|
||||
</div>
|
||||
<a href="tel:{{ object.contact_phone }}">{{ object.contact_phone }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if object.contact_email %}
|
||||
<tr>
|
||||
<th scope="row">Contact E-Mail</th>
|
||||
<td>
|
||||
{% if object.contact_email %}
|
||||
<div class="float-end text-warning">
|
||||
<i class="mdi mdi-alert" title="{{ deprecation_warning }}"></i>
|
||||
</div>
|
||||
<a href="mailto:{{ object.contact_email }}">{{ object.contact_email }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user