Enhance UPS host display with location and IP address
This commit is contained in:
@@ -49,9 +49,12 @@ class UPSHost(models.Model):
|
||||
return sum(battery.quantity for battery in self.battery_set.all())
|
||||
|
||||
def __str__(self):
|
||||
parts = [f'{self.brand} {self.model}']
|
||||
if self.location:
|
||||
parts.append(f'[{self.location}]')
|
||||
if self.ip_address and not self.ip_address.startswith('-'):
|
||||
return f'{self.brand} {self.model} - {self.ip_address}'
|
||||
return f'{self.brand} {self.model}'
|
||||
parts.append(f'({self.ip_address})')
|
||||
return ' '.join(parts)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'UPS主机'
|
||||
|
||||
Reference in New Issue
Block a user