10
10
from sqlalchemy import select
11
11
12
12
from app .api import crud
13
- from app .api .crud .authorizations import check_group_read , check_group_update , is_admin_access
13
+ from app .api .crud .authorizations import check_group_read , is_admin_access
14
14
from app .api .crud .groups import get_entity_group_id
15
15
from app .api .deps import get_current_access , get_current_device
16
16
from app .api .external import post_request
17
- from app .api .schemas import AccessType , AlertBase , AlertIn , AlertMediaId , AlertOut , DeviceOut
17
+ from app .api .schemas import AlertBase , AlertIn , AlertOut , DeviceOut
18
18
from app .db import alerts , events , get_session , media , models
19
+ from app .db .models import AccessType
19
20
20
21
router = APIRouter ()
21
22
@@ -110,20 +111,6 @@ async def fetch_alerts(
110
111
return retrieved_alerts
111
112
112
113
113
- @router .put ("/{alert_id}/" , response_model = AlertOut , summary = "Update information about a specific alert" )
114
- async def update_alert (
115
- payload : AlertIn ,
116
- alert_id : int = Path (..., gt = 0 ),
117
- requester = Security (get_current_access , scopes = [AccessType .admin , AccessType .user ]),
118
- ):
119
- """
120
- Based on a alert_id, updates information about the specified alert
121
- """
122
- requested_group_id = await get_entity_group_id (alerts , alert_id )
123
- await check_group_update (requester .id , requested_group_id )
124
- return await crud .update_entry (alerts , payload , alert_id )
125
-
126
-
127
114
@router .delete ("/{alert_id}/" , response_model = AlertOut , summary = "Delete a specific alert" )
128
115
async def delete_alert (alert_id : int = Path (..., gt = 0 ), _ = Security (get_current_access , scopes = [AccessType .admin ])):
129
116
"""
@@ -132,29 +119,6 @@ async def delete_alert(alert_id: int = Path(..., gt=0), _=Security(get_current_a
132
119
return await crud .delete_entry (alerts , alert_id )
133
120
134
121
135
- @router .put ("/{alert_id}/link-media" , response_model = AlertOut , summary = "Link an alert to a media" )
136
- async def link_media (
137
- payload : AlertMediaId ,
138
- alert_id : int = Path (..., gt = 0 ),
139
- current_device : DeviceOut = Security (get_current_device , scopes = [AccessType .device ]),
140
- ):
141
- """
142
- Based on a alert_id, and media information as arguments, link the specified alert to a media
143
- """
144
- # Check that alert is linked to this device
145
- existing_alert = await crud .fetch_one (alerts , {"id" : alert_id , "device_id" : current_device .id })
146
- if existing_alert is None :
147
- raise HTTPException (
148
- status_code = status .HTTP_404_NOT_FOUND ,
149
- detail = f"Unable to find alert with id={ alert_id } & device_id={ current_device .id } ." ,
150
- )
151
-
152
- await check_media_existence (payload .media_id )
153
- existing_alert = dict (** existing_alert )
154
- existing_alert ["media_id" ] = payload .media_id
155
- return await crud .update_entry (alerts , AlertIn (** existing_alert ), alert_id )
156
-
157
-
158
122
@router .get ("/ongoing" , response_model = List [AlertOut ], summary = "Get the list of ongoing alerts" )
159
123
async def fetch_ongoing_alerts (
160
124
requester = Security (get_current_access , scopes = [AccessType .admin , AccessType .user ]), session = Depends (get_session )
0 commit comments