Skip to content

Commit

Permalink
Merge pull request #7575 from netbox-community/1344-contacts
Browse files Browse the repository at this point in the history
Closes #1344: Contact objects
  • Loading branch information
jeremystretch authored Oct 19, 2021
2 parents 6015c47 + 554b44b commit ba7361b
Show file tree
Hide file tree
Showing 50 changed files with 1,971 additions and 75 deletions.
5 changes: 5 additions & 0 deletions docs/core-functionality/contacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contacts

{!models/tenancy/contact.md!}
{!models/tenancy/contactgroup.md!}
{!models/tenancy/contactrole.md!}
31 changes: 31 additions & 0 deletions docs/models/tenancy/contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contacts

A contact represent an individual or group that has been associated with an object in NetBox for administrative reasons. For example, you might assign one or more operational contacts to each site. Contacts can be arranged within nested contact groups.

Each contact must include a name, which is unique to its parent group (if any). The following optional descriptors are also available:

* Title
* Phone
* Email
* Address

## Contact Assignment

Each contact can be assigned to one or more objects, allowing for the efficient reuse of contact information. When assigning a contact to an object, the user may optionally specify a role and/or priority (primary, secondary, tertiary, or inactive) to better convey the nature of the contact's relationship to the assigned object.

The following models support the assignment of contacts:

* circuits.Circuit
* circuits.Provider
* dcim.Device
* dcim.Location
* dcim.Manufacturer
* dcim.PowerPanel
* dcim.Rack
* dcim.Region
* dcim.Site
* dcim.SiteGroup
* tenancy.Tenant
* virtualization.Cluster
* virtualization.ClusterGroup
* virtualization.VirtualMachine
3 changes: 3 additions & 0 deletions docs/models/tenancy/contactgroup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contact Groups

Contacts can be organized into arbitrary groups. These groups can be recursively nested for convenience. Each contact within a group must have a unique name, but other attributes can be repeated.
3 changes: 3 additions & 0 deletions docs/models/tenancy/contactrole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contact Roles

Contacts can be organized by functional roles, which are fully customizable by the user. For example, you might create roles for administrative, operational, or emergency contacts.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ nav:
- Circuits: 'core-functionality/circuits.md'
- Power Tracking: 'core-functionality/power.md'
- Tenancy: 'core-functionality/tenancy.md'
- Contacts: 'core-functionality/contacts.md'
- Customization:
- Custom Fields: 'customization/custom-fields.md'
- Custom Validation: 'customization/custom-validation.md'
Expand Down
10 changes: 10 additions & 0 deletions netbox/circuits/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class Provider(PrimaryModel):
blank=True
)

# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)

objects = RestrictedQuerySet.as_manager()

clone_fields = [
Expand Down Expand Up @@ -203,6 +208,11 @@ class Circuit(PrimaryModel):
comments = models.TextField(
blank=True
)

# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down
10 changes: 10 additions & 0 deletions netbox/dcim/models/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class Manufacturer(OrganizationalModel):
blank=True
)

# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)

objects = RestrictedQuerySet.as_manager()

class Meta:
Expand Down Expand Up @@ -584,6 +589,11 @@ class Device(PrimaryModel, ConfigContextModel):
comments = models.TextField(
blank=True
)

# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down
5 changes: 5 additions & 0 deletions netbox/dcim/models/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class PowerPanel(PrimaryModel):
name = models.CharField(
max_length=100
)

# Generic relations
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down
5 changes: 5 additions & 0 deletions netbox/dcim/models/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@ class Rack(PrimaryModel):
comments = models.TextField(
blank=True
)

# Generic relations
vlan_groups = GenericRelation(
to='ipam.VLANGroup',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='rack'
)
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down
20 changes: 20 additions & 0 deletions netbox/dcim/models/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ class Region(NestedGroupModel):
max_length=200,
blank=True
)

# Generic relations
vlan_groups = GenericRelation(
to='ipam.VLANGroup',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='region'
)
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)

def get_absolute_url(self):
return reverse('dcim:region', args=[self.pk])
Expand Down Expand Up @@ -100,12 +105,17 @@ class SiteGroup(NestedGroupModel):
max_length=200,
blank=True
)

# Generic relations
vlan_groups = GenericRelation(
to='ipam.VLANGroup',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='site_group'
)
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)

def get_absolute_url(self):
return reverse('dcim:sitegroup', args=[self.pk])
Expand Down Expand Up @@ -221,12 +231,17 @@ class Site(PrimaryModel):
comments = models.TextField(
blank=True
)

# Generic relations
vlan_groups = GenericRelation(
to='ipam.VLANGroup',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='site'
)
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down Expand Up @@ -291,12 +306,17 @@ class Location(NestedGroupModel):
max_length=200,
blank=True
)

# Generic relations
vlan_groups = GenericRelation(
to='ipam.VLANGroup',
content_type_field='scope_type',
object_id_field='scope_id',
related_query_name='location'
)
contacts = GenericRelation(
to='tenancy.ContactAssignment'
)
images = GenericRelation(
to='extras.ImageAttachment'
)
Expand Down
8 changes: 8 additions & 0 deletions netbox/netbox/navigation_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def get_model_buttons(app_label, model_name, actions=('add', 'import')):
get_model_item('tenancy', 'tenantgroup', 'Tenant Groups'),
),
),
MenuGroup(
label='Contacts',
items=(
get_model_item('tenancy', 'contact', 'Contacts'),
get_model_item('tenancy', 'contactgroup', 'Contact Groups'),
get_model_item('tenancy', 'contactrole', 'Contact Roles'),
),
),
),
)

Expand Down
11 changes: 6 additions & 5 deletions netbox/templates/circuits/circuit.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ <h5 class="card-header">
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'circuits/inc/circuit_termination.html' with termination=object.termination_a side='A' %}
{% include 'circuits/inc/circuit_termination.html' with termination=object.termination_z side='Z' %}
{% include 'inc/image_attachments_panel.html' %}
{% plugin_right_page object %}
</div>
{% include 'circuits/inc/circuit_termination.html' with termination=object.termination_a side='A' %}
{% include 'circuits/inc/circuit_termination.html' with termination=object.termination_z side='Z' %}
{% include 'inc/contacts_panel.html' %}
{% include 'inc/image_attachments_panel.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row">
<div class="col col-md-12">
Expand Down
3 changes: 2 additions & 1 deletion netbox/templates/circuits/provider.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ <h5 class="card-header">
</table>
</div>
</div>
{% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:provider_list' %}
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/custom_fields_panel.html' %}
{% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:provider_list' %}
{% include 'inc/comments_panel.html' %}
{% include 'inc/contacts_panel.html' %}
{% plugin_right_page object %}
</div>
<div class="col col-md-12">
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/device.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ <h5 class="card-header">
</div>
{% endif %}
</div>
{% include 'inc/contacts_panel.html' %}
{% include 'inc/image_attachments_panel.html' %}
<div class="card noprint">
<h5 class="card-header">
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/location.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ <h5 class="card-header">
</div>
<div class="col col-md-6">
{% include 'inc/custom_fields_panel.html' %}
{% include 'inc/contacts_panel.html' %}
{% include 'inc/image_attachments_panel.html' %}
{% plugin_right_page object %}
</div>
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/manufacturer.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h5 class="card-header">
</div>
<div class="col col-md-6">
{% include 'inc/custom_fields_panel.html' %}
{% include 'inc/contacts_panel.html' %}
{% plugin_right_page object %}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/powerpanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h5 class="card-header">
</div>
<div class="col col-md-6">
{% include 'inc/custom_fields_panel.html' %}
{% include 'inc/contacts_panel.html' %}
{% include 'inc/image_attachments_panel.html' %}
{% plugin_right_page object %}
</div>
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/rack.html
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ <h5 class="card-header">
</div>
{% endif %}
</div>
{% include 'inc/contacts_panel.html' %}
{% plugin_right_page object %}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions netbox/templates/dcim/region.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h5 class="card-header">
</div>
</div>
{% include 'inc/custom_fields_panel.html' %}
{% include 'inc/contacts_panel.html' %}
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
Expand Down
Loading

0 comments on commit ba7361b

Please sign in to comment.