@@ -332,12 +332,10 @@ def officer_profile(officer_id: int):
332332 .all ()
333333 )
334334 assignments = Assignment .query .filter_by (officer_id = officer_id ).all ()
335- face_paths = []
336- for face in faces :
337- face_paths .append (serve_image (face .image .filepath ))
335+ face_paths = [(face , serve_image (face .image .filepath )) for face in faces ]
338336 if not face_paths :
339337 # Add in the placeholder image if no faces are found
340- face_paths = [url_for ("static" , filename = "images/placeholder.png" )]
338+ face_paths = [( None , url_for ("static" , filename = "images/placeholder.png" ) )]
341339 except : # noqa: E722
342340 exception_type , value , full_traceback = sys .exc_info ()
343341 error_str = " " .join ([str (exception_type ), str (value ), format_exc ()])
@@ -355,8 +353,7 @@ def officer_profile(officer_id: int):
355353 return render_template (
356354 "officer.html" ,
357355 officer = officer ,
358- paths = face_paths ,
359- faces = faces ,
356+ face_paths = face_paths ,
360357 assignments = assignments ,
361358 form = form ,
362359 )
@@ -2085,24 +2082,31 @@ def populate_obj(self, form: FlaskForm, obj: Incident):
20852082main .add_url_rule (
20862083 "/incidents/" ,
20872084 defaults = {"obj_id" : None },
2085+ endpoint = "incident_api" ,
20882086 view_func = incident_view ,
20892087 methods = [HTTPMethod .GET ],
20902088)
20912089main .add_url_rule (
20922090 "/incidents/new" ,
2091+ endpoint = "incident_api_new" ,
20932092 view_func = incident_view ,
20942093 methods = [HTTPMethod .GET , HTTPMethod .POST ],
20952094)
20962095main .add_url_rule (
2097- "/incidents/<int:obj_id>" , view_func = incident_view , methods = [HTTPMethod .GET ]
2096+ "/incidents/<int:obj_id>" ,
2097+ endpoint = "incident_api" ,
2098+ view_func = incident_view ,
2099+ methods = [HTTPMethod .GET ],
20982100)
20992101main .add_url_rule (
21002102 "/incidents/<int:obj_id>/edit" ,
2103+ endpoint = "incident_api_edit" ,
21012104 view_func = incident_view ,
21022105 methods = [HTTPMethod .GET , HTTPMethod .POST ],
21032106)
21042107main .add_url_rule (
21052108 "/incidents/<int:obj_id>/delete" ,
2109+ endpoint = "incident_api_delete" ,
21062110 view_func = incident_view ,
21072111 methods = [HTTPMethod .GET , HTTPMethod .POST ],
21082112)
@@ -2189,7 +2193,7 @@ def redirect_get_notes(officer_id: int, obj_id=None):
21892193def redirect_edit_note (officer_id : int , obj_id = None ):
21902194 flash (FLASH_MSG_PERMANENT_REDIRECT )
21912195 return redirect (
2192- f" { url_for (' main.note_api' , officer_id = officer_id , obj_id = obj_id )} /edit" ,
2196+ url_for (" main.note_api_edit" , officer_id = officer_id , obj_id = obj_id ),
21932197 code = HTTPStatus .PERMANENT_REDIRECT ,
21942198 )
21952199
@@ -2199,14 +2203,15 @@ def redirect_edit_note(officer_id: int, obj_id=None):
21992203def redirect_delete_note (officer_id : int , obj_id = None ):
22002204 flash (FLASH_MSG_PERMANENT_REDIRECT )
22012205 return redirect (
2202- f" { url_for (' main.note_api' , officer_id = officer_id , obj_id = obj_id )} /delete" ,
2206+ url_for (" main.note_api_delete" , officer_id = officer_id , obj_id = obj_id ),
22032207 code = HTTPStatus .PERMANENT_REDIRECT ,
22042208 )
22052209
22062210
22072211note_view = NoteApi .as_view ("note_api" )
22082212main .add_url_rule (
22092213 "/officers/<int:officer_id>/notes/new" ,
2214+ endpoint = "note_api" ,
22102215 view_func = note_view ,
22112216 methods = [HTTPMethod .GET , HTTPMethod .POST ],
22122217)
@@ -2217,6 +2222,7 @@ def redirect_delete_note(officer_id: int, obj_id=None):
22172222)
22182223main .add_url_rule (
22192224 "/officers/<int:officer_id>/notes/<int:obj_id>" ,
2225+ endpoint = "note_api" ,
22202226 view_func = note_view ,
22212227 methods = [HTTPMethod .GET ],
22222228)
@@ -2227,6 +2233,7 @@ def redirect_delete_note(officer_id: int, obj_id=None):
22272233)
22282234main .add_url_rule (
22292235 "/officers/<int:officer_id>/notes/<int:obj_id>/edit" ,
2236+ endpoint = "note_api_edit" ,
22302237 view_func = note_view ,
22312238 methods = [HTTPMethod .GET , HTTPMethod .POST ],
22322239)
@@ -2237,6 +2244,7 @@ def redirect_delete_note(officer_id: int, obj_id=None):
22372244)
22382245main .add_url_rule (
22392246 "/officers/<int:officer_id>/notes/<int:obj_id>/delete" ,
2247+ endpoint = "note_api_delete" ,
22402248 view_func = note_view ,
22412249 methods = [HTTPMethod .GET , HTTPMethod .POST ],
22422250)
@@ -2252,7 +2260,7 @@ def redirect_delete_note(officer_id: int, obj_id=None):
22522260def redirect_new_description (officer_id : int ):
22532261 flash (FLASH_MSG_PERMANENT_REDIRECT )
22542262 return redirect (
2255- url_for ("main.description_api " , officer_id = officer_id ),
2263+ url_for ("main.description_api_new " , officer_id = officer_id ),
22562264 code = HTTPStatus .PERMANENT_REDIRECT ,
22572265 )
22582266
@@ -2270,7 +2278,7 @@ def redirect_get_description(officer_id: int, obj_id=None):
22702278def redirect_edit_description (officer_id : int , obj_id = None ):
22712279 flash (FLASH_MSG_PERMANENT_REDIRECT )
22722280 return redirect (
2273- f" { url_for (' main.description_api' , officer_id = officer_id , obj_id = obj_id )} /edit" ,
2281+ url_for (" main.description_api_edit" , officer_id = officer_id , obj_id = obj_id ),
22742282 code = HTTPStatus .PERMANENT_REDIRECT ,
22752283 )
22762284
@@ -2280,14 +2288,15 @@ def redirect_edit_description(officer_id: int, obj_id=None):
22802288def redirect_delete_description (officer_id : int , obj_id = None ):
22812289 flash (FLASH_MSG_PERMANENT_REDIRECT )
22822290 return redirect (
2283- f" { url_for (' main.description_api' , officer_id = officer_id , obj_id = obj_id )} /delete" ,
2291+ url_for (" main.description_api_delete" , officer_id = officer_id , obj_id = obj_id ),
22842292 code = HTTPStatus .PERMANENT_REDIRECT ,
22852293 )
22862294
22872295
22882296description_view = DescriptionApi .as_view ("description_api" )
22892297main .add_url_rule (
22902298 "/officers/<int:officer_id>/descriptions/new" ,
2299+ endpoint = "description_api_new" ,
22912300 view_func = description_view ,
22922301 methods = [HTTPMethod .GET , HTTPMethod .POST ],
22932302)
@@ -2298,6 +2307,7 @@ def redirect_delete_description(officer_id: int, obj_id=None):
22982307)
22992308main .add_url_rule (
23002309 "/officers/<int:officer_id>/descriptions/<int:obj_id>" ,
2310+ endpoint = "description_api" ,
23012311 view_func = description_view ,
23022312 methods = [HTTPMethod .GET ],
23032313)
@@ -2308,6 +2318,7 @@ def redirect_delete_description(officer_id: int, obj_id=None):
23082318)
23092319main .add_url_rule (
23102320 "/officers/<int:officer_id>/descriptions/<int:obj_id>/edit" ,
2321+ endpoint = "description_api_edit" ,
23112322 view_func = description_view ,
23122323 methods = [HTTPMethod .GET , HTTPMethod .POST ],
23132324)
@@ -2318,6 +2329,7 @@ def redirect_delete_description(officer_id: int, obj_id=None):
23182329)
23192330main .add_url_rule (
23202331 "/officers/<int:officer_id>/descriptions/<int:obj_id>/delete" ,
2332+ endpoint = "description_api_delete" ,
23212333 view_func = description_view ,
23222334 methods = [HTTPMethod .GET , HTTPMethod .POST ],
23232335)
0 commit comments