fix: property/value stringification

This commit is contained in:
Luca 2024-11-10 01:24:51 +01:00
parent dbfd024e07
commit 41e66b0962
1 changed files with 4 additions and 4 deletions

View File

@ -23,8 +23,8 @@ class Property(models.Model):
)
def __str__(self):
return (
self.name + f" [{self.unit}]" if self.type == Property.Type.QUANTITY else ""
return self.name + (
f" [{self.unit}]" if self.type == Property.Type.QUANTITY else ""
)
@ -48,13 +48,13 @@ class Value(models.Model):
def __str__(self):
match self.property.type:
case Property.Type.QUANTITY:
s = str(integer)
s = str(self.integer)
scale = self.property.scale
if scale > 0:
s += "0" * scale
elif scale < 0:
s = str(integer).rjust(abs(scale) + 1, "0")
s = str(self.integer).rjust(abs(scale) + 1, "0")
s = s[:scale] + "." + s[scale:]
return f"{s} {self.property.unit}"