mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add themes to users DB
This commit is contained in:
parent
0cba81788e
commit
05f08773a3
@ -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
|
||||
|
@ -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
|
||||
|
16
app/migrations/20220926_user_theme.py
Normal file
16
app/migrations/20220926_user_theme.py
Normal 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.
|
||||
"""
|
Loading…
Reference in New Issue
Block a user