40
40
41
41
@bp .route ("/" , methods = ["GET" ])
42
42
@bp .route ("/index" , methods = ["GET" ])
43
- @cache .cached (unless = lambda : "user" in session ,
44
- key_prefix = "/index"
45
- )
43
+ @cache .cached (unless = lambda : "user" in session , key_prefix = "/index" )
46
44
def index ():
47
45
return render_template (
48
46
"index.html" ,
@@ -84,10 +82,14 @@ def update_incident(
84
82
def form_submission (form , incident ):
85
83
new_impact = form .update_impact .data
86
84
new_status = form .update_status .data
87
- update_date = naive_from_dttz (
88
- form .update_date .data ,
89
- form .timezone .data ,
90
- ) if form .update_date .data else None
85
+ update_date = (
86
+ naive_from_dttz (
87
+ form .update_date .data ,
88
+ form .timezone .data ,
89
+ )
90
+ if form .update_date .data
91
+ else None
92
+ )
91
93
92
94
redirect_path_map = {
93
95
"completed" : "/history" ,
@@ -181,7 +183,6 @@ def new_incident(current_user):
181
183
incident_components = [
182
184
comp for comp in all_components if comp .id in selected_components
183
185
]
184
-
185
186
new_incident = Incident (
186
187
text = form .incident_text .data ,
187
188
impact = form .incident_impact .data ,
@@ -225,21 +226,15 @@ def new_incident(current_user):
225
226
comp_name = comp .name
226
227
comp_attributes = comp .attributes
227
228
comp_attributes_str = ", " .join (
228
- [
229
- f"{ attr .value } " for attr in comp_attributes
230
- ]
229
+ [f"{ attr .value } " for attr in comp_attributes ]
231
230
)
232
231
comp_with_attrs = (
233
- f"{ comp_name } "
234
- f"({ comp_attributes_str } )" )
235
- url_s = url_for (
236
- 'web.incident' ,
237
- incident_id = inc .id
232
+ f"{ comp_name } " f"({ comp_attributes_str } )"
238
233
)
234
+ url_s = url_for ("web.incident" , incident_id = inc .id )
239
235
link_s = f"<a href='{ url_s } '>{ inc .text } </a>"
240
236
url_d = url_for (
241
- 'web.incident' ,
242
- incident_id = new_incident .id
237
+ "web.incident" , incident_id = new_incident .id
243
238
)
244
239
link_d = f"<a href='{ url_d } '>{ new_incident .text } </a>"
245
240
update_s = f"{ comp_with_attrs } moved to { link_d } "
@@ -253,13 +248,16 @@ def new_incident(current_user):
253
248
messages_to .append ("Incident closed by system" )
254
249
inc .end_date = naive_utcnow ()
255
250
if messages_to :
256
- update_incident (inc , ', ' .join (messages_to ))
251
+ update_incident (inc , ", " .join (messages_to ))
257
252
if messages_from :
258
- update_incident (new_incident , ', ' .join (messages_from ))
253
+ update_incident (new_incident , ", " .join (messages_from ))
259
254
db .session .commit ()
260
255
261
- return (redirect ("/" ) if new_incident .impact != 0
262
- else redirect ("/incidents/" + str (new_incident .id )))
256
+ return (
257
+ redirect ("/" )
258
+ if new_incident .impact != 0
259
+ else redirect ("/incidents/" + str (new_incident .id ))
260
+ )
263
261
264
262
return render_template (
265
263
"create_incident.html" ,
@@ -287,7 +285,10 @@ def incident(incident_id):
287
285
end_date = None
288
286
updates = incident .updates
289
287
updates_ts = [
290
- u .timestamp for u in updates if u .status not in [
288
+ u .timestamp
289
+ for u in updates
290
+ if u .status
291
+ not in [
291
292
"resolved" ,
292
293
"description" ,
293
294
"changed" ,
@@ -317,11 +318,14 @@ def incident(incident_id):
317
318
form .update_status .choices = [
318
319
(k , v )
319
320
for (k , v ) in current_app .config .get (
320
- "INCIDENT_ACTIONS"
321
- if incident .end_date and incident .impact != 0 else (
322
- "MAINTENANCE_STATUSES"
323
- if incident .impact == 0
324
- else "INCIDENT_STATUSES"
321
+ (
322
+ "INCIDENT_ACTIONS"
323
+ if incident .end_date and incident .impact != 0
324
+ else (
325
+ "MAINTENANCE_STATUSES"
326
+ if incident .impact == 0
327
+ else "INCIDENT_STATUSES"
328
+ )
325
329
),
326
330
{},
327
331
).items ()
@@ -367,34 +371,20 @@ def separate_incident(current_user, incident_id, component_id):
367
371
comp_name = component .name
368
372
comp_attributes = component .attributes
369
373
comp_attributes_str = ", " .join (
370
- [
371
- f"{ attr .value } " for attr in comp_attributes
372
- ]
374
+ [f"{ attr .value } " for attr in comp_attributes ]
373
375
)
374
376
comp_with_attrs = f"{ comp_name } ({ comp_attributes_str } )"
375
377
376
- url_s = url_for (
377
- 'web.incident' ,
378
- incident_id = incident .id
379
- )
378
+ url_s = url_for ("web.incident" , incident_id = incident .id )
380
379
link_s = f"<a href='{ url_s } '>{ incident .text } </a>"
381
- url_d = url_for (
382
- 'web.incident' ,
383
- incident_id = new_incident .id
384
- )
380
+ url_d = url_for ("web.incident" , incident_id = new_incident .id )
385
381
link_d = f"<a href='{ url_d } '>{ new_incident .text } </a>"
386
382
387
383
update_s = f"{ comp_with_attrs } moved to { link_d } "
388
384
update_n = f"{ comp_with_attrs } moved from { link_s } "
389
385
390
- update_incident (
391
- incident ,
392
- update_s
393
- )
394
- update_incident (
395
- new_incident ,
396
- update_n
397
- )
386
+ update_incident (incident , update_s )
387
+ update_incident (new_incident , update_n )
398
388
db .session .commit ()
399
389
return redirect ("/" )
400
390
0 commit comments