fix: property/value stringification
This commit is contained in:
parent
dbfd024e07
commit
41e66b0962
|
@ -23,8 +23,8 @@ class Property(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (
|
return self.name + (
|
||||||
self.name + f" [{self.unit}]" if self.type == Property.Type.QUANTITY else ""
|
f" [{self.unit}]" if self.type == Property.Type.QUANTITY else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ class Value(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
match self.property.type:
|
match self.property.type:
|
||||||
case Property.Type.QUANTITY:
|
case Property.Type.QUANTITY:
|
||||||
s = str(integer)
|
s = str(self.integer)
|
||||||
|
|
||||||
scale = self.property.scale
|
scale = self.property.scale
|
||||||
if scale > 0:
|
if scale > 0:
|
||||||
s += "0" * scale
|
s += "0" * scale
|
||||||
elif scale < 0:
|
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:]
|
s = s[:scale] + "." + s[scale:]
|
||||||
|
|
||||||
return f"{s} {self.property.unit}"
|
return f"{s} {self.property.unit}"
|
||||||
|
|
Loading…
Reference in New Issue