Skip to content

Commit 9f2f7ca

Browse files
committed
Add __str__ and get_absolute_url to SegmentFinancialInfo model
Implement standard model methods to align with NetBox conventions and improve model consistency with Segment structure.
1 parent e3a9bbd commit 9f2f7ca

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cesnet_service_path_plugin/models/segment_financial_info.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.db import models
22
from django.conf import settings
3+
from django.urls import reverse
34
from netbox.models import NetBoxModel
45

56

@@ -48,6 +49,15 @@ class SegmentFinancialInfo(NetBoxModel):
4849

4950
notes = models.TextField(blank=True, help_text="Additional financial notes")
5051

52+
class Meta:
53+
ordering = ("segment",)
54+
55+
def __str__(self):
56+
return f"{self.segment.name} - Financial Info"
57+
58+
def get_absolute_url(self):
59+
return reverse("plugins:cesnet_service_path_plugin:segmentfinancialinfo", args=[self.pk])
60+
5161
@property
5262
def total_commitment_cost(self):
5363
"""Calculate total cost over commitment period."""
@@ -64,6 +74,3 @@ def total_cost_including_setup(self):
6474
if self.non_recurring_charge:
6575
total += self.non_recurring_charge
6676
return total if total > 0 else None
67-
68-
class Meta:
69-
ordering = ("segment",)

0 commit comments

Comments
 (0)