1- from typing import List , Annotated
1+ from typing import List
22from uuid import UUID
33
4- from fastapi import APIRouter , Body , Depends , HTTPException , Path , Query , status , Request
4+ from fastapi import (
5+ APIRouter ,
6+ Body ,
7+ Depends ,
8+ HTTPException ,
9+ Path ,
10+ Query ,
11+ Request ,
12+ status ,
13+ )
514from fastapi .responses import JSONResponse
615from fastapi_pagination import Page
716from fastapi_pagination import Params as PaginationParams
3140 IProjectRead ,
3241 IRasterProjectRead ,
3342 ITableProjectRead ,
43+ ProjectPublicRead ,
3444)
3545from src .schemas .project import (
3646 request_examples as project_request_examples ,
@@ -549,7 +559,7 @@ async def get_statistic_aggregation(
549559 expression : str | None = Query (
550560 None ,
551561 description = "The QGIS expression to use for the statistic operation" ,
552- example = " sum(\ " population\" )" ,
562+ example = ' sum("population")' ,
553563 ),
554564 size : int = Query (
555565 100 , description = "The number of grouped values to return" , example = 5
@@ -570,14 +580,16 @@ async def get_statistic_aggregation(
570580 # Check authorization status
571581 try :
572582 await auth_z_lite (request , async_session )
573- except HTTPException as e :
583+ except HTTPException :
574584 # Check publication status if unauthorized
575585 public_project = await crud_project .get_public_project (
576586 async_session = async_session ,
577587 project_id = str (project_id ),
578588 )
579589 if not public_project :
580- raise HTTPException (status_code = status .HTTP_401_UNAUTHORIZED , detail = "Unauthorized" )
590+ raise HTTPException (
591+ status_code = status .HTTP_401_UNAUTHORIZED , detail = "Unauthorized"
592+ )
581593
582594 # Ensure an operation or expression is specified
583595 if operation is None and expression is None :
@@ -587,12 +599,16 @@ async def get_statistic_aggregation(
587599 )
588600
589601 # Ensure a column name is specified for all operations except count
590- if operation and operation != ColumnStatisticsOperation .count and column_name is None :
602+ if (
603+ operation
604+ and operation != ColumnStatisticsOperation .count
605+ and column_name is None
606+ ):
591607 raise HTTPException (
592608 status_code = status .HTTP_400_BAD_REQUEST ,
593609 detail = "A column name must be specified for all operations except count." ,
594610 )
595-
611+
596612 # If an operation is specified, a group-by column name must also be specified
597613 if operation and group_by_column_name is None :
598614 raise HTTPException (
@@ -670,14 +686,16 @@ async def get_statistic_histogram(
670686 # Check authorization status
671687 try :
672688 await auth_z_lite (request , async_session )
673- except HTTPException as e :
689+ except HTTPException :
674690 # Check publication status if unauthorized
675691 public_project = await crud_project .get_public_project (
676692 async_session = async_session ,
677693 project_id = str (project_id ),
678694 )
679695 if not public_project :
680- raise HTTPException (status_code = status .HTTP_401_UNAUTHORIZED , detail = "Unauthorized" )
696+ raise HTTPException (
697+ status_code = status .HTTP_401_UNAUTHORIZED , detail = "Unauthorized"
698+ )
681699
682700 # Ensure the number of bins is not excessively large
683701 if num_bins > 100 :
@@ -979,6 +997,8 @@ async def delete_scenario_features(
979997@router .get (
980998 "/{project_id}/public" ,
981999 summary = "Get public project" ,
1000+ response_model = ProjectPublicRead | None ,
1001+ response_model_exclude_none = True ,
9821002)
9831003async def get_public_project (
9841004 project_id : str ,
@@ -997,7 +1017,7 @@ async def get_public_project(
9971017@router .post (
9981018 "/{project_id}/publish" ,
9991019 summary = "Publish a project" ,
1000- # dependencies=[Depends(auth_z)],
1020+ dependencies = [Depends (auth_z )],
10011021)
10021022async def publish_project (
10031023 project_id : str ,
@@ -1016,7 +1036,7 @@ async def publish_project(
10161036@router .delete (
10171037 "/{project_id}/unpublish" ,
10181038 summary = "Unpublish a project" ,
1019- # dependencies=[Depends(auth_z)],
1039+ dependencies = [Depends (auth_z )],
10201040)
10211041async def unpublish_project (
10221042 project_id : str ,
0 commit comments