Feature/user photo storage (#877)

* add default assets for user profile

* add recipe avatar

* change user_id to UUID

* add profile image upload

* setup image cache keys

* cleanup tests and add image tests

* purge user data on delete

* new user repository tests

* add user_id validator for int -> UUID conversion

* delete depreciated route

* force set content type

* refactor tests to use temp directory

* validate parent exists before createing

* set user_id to correct type

* update instruction id

* reset primary key on migration
This commit is contained in:
Hayden
2021-12-18 19:04:36 -09:00
committed by GitHub
parent a2f8f27193
commit ea7c4771ee
64 changed files with 433 additions and 181 deletions

View File

@@ -32,7 +32,7 @@ class LongLiveTokenOut(LoingLiveTokenIn):
class CreateToken(LoingLiveTokenIn):
parent_id: int
user_id: UUID4
token: str
class Config:
@@ -88,10 +88,11 @@ class UserIn(UserBase):
class UserOut(UserBase):
id: int
id: UUID4
group: str
group_id: UUID4
tokens: Optional[list[LongLiveTokenOut]]
cache_key: str
favorite_recipes: Optional[list[str]] = []
class Config:
@@ -127,6 +128,15 @@ class PrivateUser(UserOut):
class Config:
orm_mode = True
@staticmethod
def get_directory(user_id: UUID4) -> Path:
user_dir = get_app_dirs().USER_DIR / str(user_id)
user_dir.mkdir(parents=True, exist_ok=True)
return user_dir
def directory(self) -> Path:
return PrivateUser.get_directory(self.id)
class UpdateGroup(GroupBase):
id: UUID4