Add themes to users DB

This commit is contained in:
Andrew 2022-09-26 21:23:16 -04:00
parent 0cba81788e
commit 05f08773a3
3 changed files with 21 additions and 0 deletions

View File

@ -241,6 +241,7 @@ class UsersController:
email="default@example.com",
enabled: bool = True,
superuser: bool = False,
theme="default",
):
return self.users_helper.add_user(
username,
@ -249,6 +250,7 @@ class UsersController:
email=email,
enabled=enabled,
superuser=superuser,
theme=theme,
)
@staticmethod

View File

@ -43,6 +43,7 @@ class Users(BaseModel):
hints = BooleanField(default=True)
manager = IntegerField(default=None, null=True)
pfp = CharField(default="/static/assets/images/faces-clipart/pic-3.png")
theme = CharField(default="default")
class Meta:
table_name = "users"
@ -210,6 +211,7 @@ class HelperUsers:
email: t.Optional[str] = None,
enabled: bool = True,
superuser: bool = False,
theme: str = "default",
) -> str:
if password is not None:
pw_enc = self.helper.encode_pass(password)
@ -225,6 +227,7 @@ class HelperUsers:
Users.superuser: superuser,
Users.created: Helpers.get_time_as_string(),
Users.manager: manager,
Users.theme: theme,
}
).execute()
return user_id

View File

@ -0,0 +1,16 @@
# Generated by database migrator
import peewee
def migrate(migrator, database, **kwargs):
migrator.add_columns("users", theme=peewee.CharField(default="default"))
"""
Write your migrations here.
"""
def rollback(migrator, database, **kwargs):
migrator.drop_columns("users", ["theme"])
"""
Write your rollback migrations here.
"""