Renamed requests to extensions
This commit is contained in:
parent
9e7acf727c
commit
d16418b5d5
@ -5,10 +5,11 @@ from typing import Union
|
||||
from modules.utils import configGet
|
||||
from modules.app import app, check_project_key, get_api_key
|
||||
from modules.database import col_photos, col_albums
|
||||
from modules.security import User, get_current_active_user
|
||||
from bson.objectid import ObjectId
|
||||
from bson.errors import InvalidId
|
||||
|
||||
from fastapi import HTTPException, Depends
|
||||
from fastapi import HTTPException, Depends, Security
|
||||
from fastapi.responses import UJSONResponse, Response
|
||||
from fastapi.openapi.models import APIKey
|
||||
from starlette.status import HTTP_204_NO_CONTENT, HTTP_401_UNAUTHORIZED, HTTP_404_NOT_FOUND, HTTP_406_NOT_ACCEPTABLE, HTTP_409_CONFLICT
|
||||
@ -45,22 +46,17 @@ async def album_create(name: str, title: str, apikey: APIKey = Depends(get_api_k
|
||||
else:
|
||||
raise HTTPException(status_code=HTTP_401_UNAUTHORIZED, detail=configGet("key_invalid", "messages"))
|
||||
|
||||
@app.get("/albums", response_class=UJSONResponse, description="Find album by name")
|
||||
async def album_find(q: str, apikey: APIKey = Depends(get_api_key)):
|
||||
|
||||
if (check_project_key("photos", apikey)):
|
||||
@app.get("/albums", description="Find album by name")
|
||||
async def album_find(q: str, current_user: User = Security(get_current_active_user, scopes=["list"])):
|
||||
|
||||
output = {"results": []}
|
||||
albums = list(col_albums.find( {"name": re.compile(q)} ))
|
||||
albums = list(col_albums.find( {"user": current_user.user, "name": re.compile(q)} ))
|
||||
|
||||
for album in albums:
|
||||
output["results"].append( {"id": album["_id"].__str__(), "name": album["name"]} )
|
||||
|
||||
return UJSONResponse(output)
|
||||
|
||||
else:
|
||||
raise HTTPException(status_code=HTTP_401_UNAUTHORIZED, detail=configGet("key_invalid", "messages"))
|
||||
|
||||
@app.patch("/albums/{id}", response_class=UJSONResponse, description="Modify album's name or title by id")
|
||||
async def album_patch(id: str, name: Union[str, None] = None, title: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
|
||||
|
@ -13,5 +13,5 @@ async def favicon():
|
||||
|
||||
|
||||
#=================================================================================
|
||||
dynamic_import_from_src("requests", star_import = True)
|
||||
dynamic_import_from_src("extensions", star_import = True)
|
||||
#=================================================================================
|
Loading…
Reference in New Issue
Block a user