mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#10033 disable Add a Termination button if 2 terminations on L2VPN P2P
This commit is contained in:
@ -67,6 +67,12 @@ class L2VPN(NetBoxModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('ipam:l2vpn', args=[self.pk])
|
return reverse('ipam:l2vpn', args=[self.pk])
|
||||||
|
|
||||||
|
def can_add_termination(self):
|
||||||
|
if self.type in L2VPNTypeChoices.P2P and self.terminations.count() >= 2:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class L2VPNTermination(NetBoxModel):
|
class L2VPNTermination(NetBoxModel):
|
||||||
l2vpn = models.ForeignKey(
|
l2vpn = models.ForeignKey(
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% if perms.ipam.add_l2vpntermination %}
|
{% if perms.ipam.add_l2vpntermination %}
|
||||||
<div class="card-footer text-end noprint">
|
<div class="card-footer text-end noprint">
|
||||||
<a href="{% url 'ipam:l2vpntermination_add' %}?l2vpn={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-primary btn-sm">
|
<a href="{% url 'ipam:l2vpntermination_add' %}?l2vpn={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-primary btn-sm{% if not object.can_add_termination %} disabled{% endif %}"{% if not object.can_add_termination %} aria-disabled="true"{% endif %}>
|
||||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add a Termination
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add a Termination
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user