[System] avatar URL needs to be generated as path might change
This commit is contained in:
parent
40651c3279
commit
6612a84cd3
|
@ -47,7 +47,7 @@ def configure_app(app):
|
|||
logging.config.dictConfig(logger_config)
|
||||
|
||||
if "secret_key" not in config["FLASCHENGEIST"]:
|
||||
logger.warn("No secret key was configured, please configure one for production systems!")
|
||||
logger.warning("No secret key was configured, please configure one for production systems!")
|
||||
app.config["SECRET_KEY"] = "0a657b97ef546da90b2db91862ad4e29"
|
||||
else:
|
||||
app.config["SECRET_KEY"] = config["FLASCHENGEIST"]["secret_key"]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from flask import url_for
|
||||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||
|
||||
from . import ModelSerializeMixin
|
||||
|
@ -54,9 +55,9 @@ class User(db.Model, ModelSerializeMixin):
|
|||
firstname: str = db.Column(db.String(50), nullable=False)
|
||||
lastname: str = db.Column(db.String(50), nullable=False)
|
||||
mail: str = db.Column(db.String(60), nullable=False)
|
||||
avatar_url: Optional[str] = db.Column(db.String(60))
|
||||
birthday: Optional[date] = db.Column(db.Date)
|
||||
roles: [str] = []
|
||||
avatar_url: Optional[str] = ""
|
||||
|
||||
roles_: [Role] = db.relationship("Role", secondary=association_table, cascade="save-update, merge")
|
||||
_id = db.Column("id", db.Integer, primary_key=True)
|
||||
|
@ -65,6 +66,10 @@ class User(db.Model, ModelSerializeMixin):
|
|||
"_UserAttribute", collection_class=attribute_mapped_collection("name"), cascade="all, delete"
|
||||
)
|
||||
|
||||
@property
|
||||
def avatar_url(self):
|
||||
return url_for('users.get_avatar', userid=self.userid)
|
||||
|
||||
@property
|
||||
def roles(self):
|
||||
return [role.name for role in self.roles_]
|
||||
|
|
Loading…
Reference in New Issue