mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-22 23:46:44 -06:00
Workflow improvements
This commit is contained in:
parent
599d733df9
commit
eba9677142
@ -359,6 +359,16 @@ INTERFACE_BUTTONS = """
|
|||||||
<i class="mdi mdi-wifi-off" aria-hidden="true"></i>
|
<i class="mdi mdi-wifi-off" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif record.type == 'virtual' %}
|
||||||
|
{% if perms.vpn.add_tunnel and not record.tunnel_termination %}
|
||||||
|
<a href="{% url 'vpn:tunnel_add' %}?termination1_type=dcim.device&termination1_parent={{ record.device.pk }}&termination1_interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Create a tunnel" class="btn btn-success btn-sm">
|
||||||
|
<i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
{% elif perms.vpn.delete_tunneltermination and record.tunnel_termination %}
|
||||||
|
<a href="{% url 'vpn:tunneltermination_delete' pk=record.tunnel_termination.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove tunnel" class="btn btn-danger btn-sm">
|
||||||
|
<i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
{% elif record.is_wired and perms.dcim.add_cable %}
|
{% elif record.is_wired and perms.dcim.add_cable %}
|
||||||
<a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
|
<a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
|
||||||
<a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
|
<a href="#" class="btn btn-outline-dark btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
|
||||||
|
@ -257,6 +257,12 @@ class TunnelTerminationCreateForm(NetBoxModelForm):
|
|||||||
'virtual_machine_id': '$parent',
|
'virtual_machine_id': '$parent',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
# Assign the interface
|
||||||
|
self.instance.interface = self.cleaned_data['interface']
|
||||||
|
|
||||||
|
|
||||||
class IPSecProfileForm(NetBoxModelForm):
|
class IPSecProfileForm(NetBoxModelForm):
|
||||||
comments = CommentField()
|
comments = CommentField()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@ -127,6 +128,18 @@ class TunnelTermination(CustomFieldsMixin, CustomLinksMixin, TagsMixin, ChangeLo
|
|||||||
def get_role_color(self):
|
def get_role_color(self):
|
||||||
return TunnelTerminationRoleChoices.colors.get(self.role)
|
return TunnelTerminationRoleChoices.colors.get(self.role)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
# Check that the selected Interface is not already attached to a Tunnel
|
||||||
|
if self.interface.tunnel_termination:
|
||||||
|
raise ValidationError({
|
||||||
|
'interface': _("Interface {name} is already attached to a tunnel ({tunnel}).").format(
|
||||||
|
name=self.interface.name,
|
||||||
|
tunnel=self.interface.tunnel_termination.tunnel
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
objectchange.related_object = self.tunnel
|
objectchange.related_object = self.tunnel
|
||||||
|
Loading…
Reference in New Issue
Block a user