-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
298 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,47 @@ | ||
from typing import List | ||
from fastapi import APIRouter, Depends, Body | ||
from fastapi.responses import FileResponse | ||
from fastapi.datastructures import UploadFile | ||
from fastapi.param_functions import File | ||
from fastapi import APIRouter, Depends | ||
from fastapi.responses import Response | ||
from api.services.campaigns import CampaignsService | ||
from api.models.campaigns import Campaign | ||
from api.utils.file_size import size_checker | ||
from api.auth import require_admin, User | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/campaigns", response_model=List[Campaign]) | ||
async def get_study_drafts( | ||
async def get_campaigns( | ||
#user: User = Depends(require_admin), | ||
) -> List[Campaign]: | ||
"""Get all campaigns""" | ||
service = CampaignsService() | ||
return await service.list() | ||
|
||
|
||
@router.post("/campaigns", status_code=201, response_model=List[Campaign]) | ||
async def create_or_update_campaigns( | ||
campaigns: List[Campaign], | ||
user: User = Depends(require_admin), | ||
): | ||
"""Create or update campaigns, move temporary files to there final location""" | ||
service = CampaignsService() | ||
for campaign in campaigns: | ||
await service.createOrUpdate(campaign) | ||
return Response(status_code=201) | ||
|
||
@router.get("/campaign/{identifier}", response_model=Campaign) | ||
async def get_campaign( | ||
identifier: str, | ||
#user: User = Depends(require_admin), | ||
) -> Campaign: | ||
"""Get a campaign""" | ||
service = CampaignsService() | ||
return await service.get(identifier) | ||
|
||
@router.delete("/campaign/{identifier}", response_model=List[Campaign]) | ||
async def delete_campaign( | ||
identifier: str, | ||
user: User = Depends(require_admin), | ||
) -> List[Campaign]: | ||
"""Delete a campaign and associated files""" | ||
service = CampaignsService() | ||
return await service.delete(identifier) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.