monitoritemmodel.py 784 B

1234567891011121314151617181920212223242526
  1. from django.db import models
  2. class MonitorItem(models.Model):
  3. id = models.CharField(max_length=255, primary_key=True)
  4. _value = models.TextField(db_column="value", blank=True, null=True)
  5. type = models.CharField(max_length=255, default="int")
  6. updated = models.DateTimeField(blank=True, null=True)
  7. class Meta:
  8. app_label = 'misago'
  9. @property
  10. def value(self):
  11. if self.type in ("int", "integer"):
  12. return int(self._value)
  13. if self.type == "float":
  14. return float(self._value)
  15. return self._value
  16. @value.setter
  17. def value(self, v):
  18. if self.type in ("int", "integer"):
  19. self._value = int(v)
  20. if self.type == "float":
  21. self._value = float(v)
  22. self._value = v