mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-20 09:15:12 -05:00
Added validators for users and recipes (#1052)
* Added validators for users and recipes provide a simple get api, allowing to test for existence of - user by username - recipe by slug - group by name (not tested yet) * updated formatting * Use group_id+slug for recipes, use ValidationRespone * Fixed Flake8 errors and warnings * add missing field for TestUser init
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import random
|
||||
import shutil
|
||||
from typing import Optional
|
||||
|
||||
from mealie.assets import users as users_assets
|
||||
from mealie.schema.user.user import PrivateUser, User
|
||||
@@ -34,3 +35,9 @@ class RepositoryUsers(RepositoryGeneric[PrivateUser, User]):
|
||||
# Delete the user's directory
|
||||
shutil.rmtree(PrivateUser.get_directory(id))
|
||||
return entry
|
||||
|
||||
def get_by_username(self, username: str, limit=1) -> Optional[User]:
|
||||
dbuser = self.session.query(User).filter(User.username == username).one_or_none()
|
||||
if dbuser is None:
|
||||
return None
|
||||
return self.schema.from_orm(dbuser)
|
||||
|
||||
Reference in New Issue
Block a user