This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/resources/models.py

26 lines
602 B
Python
Raw Normal View History

2018-04-10 15:06:39 +00:00
from datetime import datetime
from ereuse_devicehub.db import db
STR_SIZE = 64
STR_BIG_SIZE = 128
STR_SM_SIZE = 32
2018-06-10 16:47:49 +00:00
STR_XSM_SIZE = 16
2018-04-10 15:06:39 +00:00
class Thing(db.Model):
__abstract__ = True
updated = db.Column(db.DateTime, onupdate=datetime.utcnow)
2018-06-12 14:50:05 +00:00
updated.comment = """
When this was last changed.
"""
2018-04-10 15:06:39 +00:00
created = db.Column(db.DateTime, default=datetime.utcnow)
2018-06-12 14:50:05 +00:00
created.comment = """
When Devicehub created this.
"""
2018-07-14 14:41:22 +00:00
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
if not self.created:
self.created = datetime.utcnow()