mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #2118: Added latitude and longitude fields to Site
This commit is contained in:
@ -1,7 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.validators import UniqueTogetherValidator
|
from rest_framework.validators import UniqueTogetherValidator
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
@ -63,9 +61,9 @@ class SiteSerializer(CustomFieldModelSerializer):
|
|||||||
model = Site
|
model = Site
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'name', 'slug', 'status', 'region', 'tenant', 'facility', 'asn', 'time_zone', 'description',
|
'id', 'name', 'slug', 'status', 'region', 'tenant', 'facility', 'asn', 'time_zone', 'description',
|
||||||
'physical_address', 'shipping_address', 'contact_name', 'contact_phone', 'contact_email', 'comments',
|
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
||||||
'tags', 'custom_fields', 'created', 'last_updated', 'count_prefixes', 'count_vlans', 'count_racks',
|
'contact_email', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'count_prefixes',
|
||||||
'count_devices', 'count_circuits',
|
'count_vlans', 'count_racks', 'count_devices', 'count_circuits',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
model = Site
|
model = Site
|
||||||
fields = [
|
fields = [
|
||||||
'name', 'slug', 'status', 'region', 'tenant_group', 'tenant', 'facility', 'asn', 'time_zone', 'description',
|
'name', 'slug', 'status', 'region', 'tenant_group', 'tenant', 'facility', 'asn', 'time_zone', 'description',
|
||||||
'physical_address', 'shipping_address', 'contact_name', 'contact_phone', 'contact_email', 'comments',
|
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
||||||
'tags',
|
'contact_email', 'comments', 'tags',
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
'physical_address': SmallTextarea(attrs={'rows': 3}),
|
'physical_address': SmallTextarea(attrs={'rows': 3}),
|
||||||
@ -129,7 +129,9 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
'time_zone': "Local time zone",
|
'time_zone': "Local time zone",
|
||||||
'description': "Short description (will appear in sites list)",
|
'description': "Short description (will appear in sites list)",
|
||||||
'physical_address': "Physical location of the building (e.g. for GPS)",
|
'physical_address': "Physical location of the building (e.g. for GPS)",
|
||||||
'shipping_address': "If different from the physical address"
|
'shipping_address': "If different from the physical address",
|
||||||
|
'latitude': "Latitude in decimal format (xx.yyyyyy)",
|
||||||
|
'longitude': "Longitude in decimal format (xx.yyyyyy)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
25
netbox/dcim/migrations/0060_site_latitude_longitude.py
Normal file
25
netbox/dcim/migrations/0060_site_latitude_longitude.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.12 on 2018-06-21 18:45
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('dcim', '0059_devicetype_add_created_updated_times'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='site',
|
||||||
|
name='latitude',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=6, max_digits=8, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='site',
|
||||||
|
name='longitude',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -135,6 +135,18 @@ class Site(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
max_length=200,
|
max_length=200,
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
latitude = models.DecimalField(
|
||||||
|
max_digits=8,
|
||||||
|
decimal_places=6,
|
||||||
|
blank=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
longitude = models.DecimalField(
|
||||||
|
max_digits=9,
|
||||||
|
decimal_places=6,
|
||||||
|
blank=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
contact_name = models.CharField(
|
contact_name = models.CharField(
|
||||||
max_length=50,
|
max_length=50,
|
||||||
blank=True
|
blank=True
|
||||||
@ -164,7 +176,7 @@ class Site(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
|
|
||||||
csv_headers = [
|
csv_headers = [
|
||||||
'name', 'slug', 'status', 'region', 'tenant', 'facility', 'asn', 'time_zone', 'description', 'physical_address',
|
'name', 'slug', 'status', 'region', 'tenant', 'facility', 'asn', 'time_zone', 'description', 'physical_address',
|
||||||
'shipping_address', 'contact_name', 'contact_phone', 'contact_email', 'comments',
|
'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone', 'contact_email', 'comments',
|
||||||
]
|
]
|
||||||
|
|
||||||
serializer = 'dcim.api.serializers.SiteSerializer'
|
serializer = 'dcim.api.serializers.SiteSerializer'
|
||||||
@ -191,6 +203,8 @@ class Site(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
self.description,
|
self.description,
|
||||||
self.physical_address,
|
self.physical_address,
|
||||||
self.shipping_address,
|
self.shipping_address,
|
||||||
|
self.latitude,
|
||||||
|
self.longitude,
|
||||||
self.contact_name,
|
self.contact_name,
|
||||||
self.contact_phone,
|
self.contact_phone,
|
||||||
self.contact_email,
|
self.contact_email,
|
||||||
|
@ -175,6 +175,16 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>GPS Coordinates</td>
|
||||||
|
<td>
|
||||||
|
{% if site.latitude and site.longitude %}
|
||||||
|
{{ site.latitude }}, {{ site.longitude }}
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">N/A</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Contact Name</td>
|
<td>Contact Name</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% render_field form.physical_address %}
|
{% render_field form.physical_address %}
|
||||||
{% render_field form.shipping_address %}
|
{% render_field form.shipping_address %}
|
||||||
|
{% render_field form.latitude %}
|
||||||
|
{% render_field form.longitude %}
|
||||||
{% render_field form.contact_name %}
|
{% render_field form.contact_name %}
|
||||||
{% render_field form.contact_phone %}
|
{% render_field form.contact_phone %}
|
||||||
{% render_field form.contact_email %}
|
{% render_field form.contact_email %}
|
||||||
|
Reference in New Issue
Block a user