Skip to content

Commit

Permalink
fix auth issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshuamjv2 committed Sep 13, 2024
1 parent 94f4d22 commit e0cfe3d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Binary file modified __pycache__/main.cpython-39.pyc
Binary file not shown.
Binary file modified block_lists/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified block_lists/__pycache__/routes.cpython-39.pyc
Binary file not shown.
8 changes: 4 additions & 4 deletions block_lists/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class ListType(str, Enum):

class Site(BaseModel):
site_url: str
comment: str = None
# comment: str = None
created: datetime = datetime.now(timezone.utc)


class BlockList(BaseModel):
name: str
comment: str = None
# comment: str = None
type: ListType = Field(default="black_list")
created: datetime = datetime.now(timezone.utc)
sites: List[Site] = []
Expand All @@ -26,7 +26,7 @@ class BlockList(BaseModel):
class SiteResponse(BaseModel):
id: str
site_url: str
comment: str = None
# comment: str = None
created: datetime
updated: Optional[datetime] = None

Expand All @@ -36,7 +36,7 @@ class BlockListResponse(BaseModel):
name: str
owner: str
type: ListType
comment: str = None
# comment: str = None
sites: List[SiteResponse] = []
created: datetime
updated: Optional[datetime] = None
12 changes: 9 additions & 3 deletions block_lists/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def create_block_list(block_list: BlockList, user=Depends(get_current_user
res = BlockListResponse(
id=id,
name=block_list.name,
comment=block_list.comment,
# comment=block_list.comment,
type=block_list.type,
created=block_list.created,
owner=owner,
Expand Down Expand Up @@ -70,7 +70,7 @@ async def get_user_block_lists(user=Depends(get_current_user)) -> List[BlockList
owner=owner,
name=block_list["name"],
type=block_list["type"],
comment=block_list["comment"],
# comment=block_list["comment"],
created=block_list["created"],
updated=block_list.get("updated"),
sites=[SiteResponse(
Expand Down Expand Up @@ -103,9 +103,15 @@ async def get_single_block_list(id: str) -> BlockListResponse:
sites=[SiteResponse(
id=site["id"],
site_url=site["site_url"],
comment=site["comment"],
# comment=site["comment"],
created=site["created"],
updated=site.get("updated")
) for site in block_list["sites"]]
)
return res


@router.delete("/{id}", status_code=200, description="Delete Blocklist", dependencies=[Depends(get_current_user)])
def delete_block_list(id: str):
db["block_lists"].delete_one({"_id": id})
return {"message": "List deleted successfully!"}

0 comments on commit e0cfe3d

Please sign in to comment.