forked from open-webui/open-webui
chore: 🚨 lint and format
This commit is contained in:
parent
037793161e
commit
07cc7f15d5
25 changed files with 190 additions and 180 deletions
|
@ -8,7 +8,6 @@ from utils.misc import get_gravatar_url
|
|||
from apps.web.internal.db import DB
|
||||
from apps.web.models.chats import Chats
|
||||
|
||||
|
||||
####################
|
||||
# User DB Schema
|
||||
####################
|
||||
|
@ -46,13 +45,16 @@ class UserRoleUpdateForm(BaseModel):
|
|||
|
||||
|
||||
class UsersTable:
|
||||
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
self.db.create_tables([User])
|
||||
|
||||
def insert_new_user(
|
||||
self, id: str, name: str, email: str, role: str = "pending"
|
||||
) -> Optional[UserModel]:
|
||||
def insert_new_user(self,
|
||||
id: str,
|
||||
name: str,
|
||||
email: str,
|
||||
role: str = "pending") -> Optional[UserModel]:
|
||||
user = UserModel(
|
||||
**{
|
||||
"id": id,
|
||||
|
@ -61,8 +63,7 @@ class UsersTable:
|
|||
"role": role,
|
||||
"profile_image_url": get_gravatar_url(email),
|
||||
"timestamp": int(time.time()),
|
||||
}
|
||||
)
|
||||
})
|
||||
result = User.create(**user.model_dump())
|
||||
if result:
|
||||
return user
|
||||
|
@ -92,7 +93,8 @@ class UsersTable:
|
|||
def get_num_users(self) -> Optional[int]:
|
||||
return User.select().count()
|
||||
|
||||
def update_user_role_by_id(self, id: str, role: str) -> Optional[UserModel]:
|
||||
def update_user_role_by_id(self, id: str,
|
||||
role: str) -> Optional[UserModel]:
|
||||
try:
|
||||
query = User.update(role=role).where(User.id == id)
|
||||
query.execute()
|
||||
|
@ -110,7 +112,8 @@ class UsersTable:
|
|||
if result:
|
||||
# Delete User
|
||||
query = User.delete().where(User.id == id)
|
||||
query.execute() # Remove the rows, return number of rows removed.
|
||||
query.execute(
|
||||
) # Remove the rows, return number of rows removed.
|
||||
|
||||
return True
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue