fix: standardize UTC timestamp handling
This commit is contained in:
+5
-6
@@ -1,11 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flask_login import UserMixin
|
||||
from werkzeug.security import check_password_hash, generate_password_hash
|
||||
|
||||
from .extensions import db
|
||||
from .time_utils import utc_now
|
||||
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
@@ -15,7 +14,7 @@ class User(UserMixin, db.Model):
|
||||
username = db.Column(db.String(100), unique=True, nullable=False)
|
||||
password_hash = db.Column(db.String(255), nullable=False)
|
||||
is_admin = db.Column(db.Boolean, default=False, nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=utc_now)
|
||||
|
||||
def set_password(self, password: str) -> None:
|
||||
self.password_hash = generate_password_hash(password)
|
||||
@@ -33,7 +32,7 @@ class PasswordResetToken(db.Model):
|
||||
token_hash = db.Column(db.String(64), unique=True, nullable=False, index=True)
|
||||
expires_at = db.Column(db.DateTime, nullable=False)
|
||||
used_at = db.Column(db.DateTime)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=utc_now, nullable=False)
|
||||
|
||||
user = db.relationship(
|
||||
"User",
|
||||
@@ -52,7 +51,7 @@ class UploadRecord(db.Model):
|
||||
saved_path = db.Column(db.String(500), nullable=False)
|
||||
prediction_path = db.Column(db.String(500), nullable=False)
|
||||
image_path = db.Column(db.String(500), nullable=False)
|
||||
upload_time = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
upload_time = db.Column(db.DateTime, default=utc_now)
|
||||
|
||||
user = db.relationship("User", backref=db.backref("uploads", lazy=True))
|
||||
|
||||
@@ -63,7 +62,7 @@ class AppSetting(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
key = db.Column(db.String(100), unique=True, nullable=False)
|
||||
value = db.Column(db.String(255), nullable=False)
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
updated_at = db.Column(db.DateTime, default=utc_now, onupdate=utc_now)
|
||||
|
||||
@classmethod
|
||||
def get_bool(cls, key: str, default: bool = False) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user