fix: property/value stringification
This commit is contained in:
parent
dbfd024e07
commit
41e66b0962
|
@ -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}"
|
||||
|
|
Loading…
Reference in New Issue