@@ -226,6 +226,7 @@ def route_v2_project_project_id_patches(project_id):
226
226
page = int (request .args .get ('page' , 1 ))
227
227
patch_state = request .args .get ('patch_state' )
228
228
confirmation_state = request .args .get ('confirmation_state' )
229
+ run_state = request .args .get ('run_state' )
229
230
230
231
# initial patch query
231
232
patches = Patch .query .filter (Patch .project_id == project_id )
@@ -235,23 +236,33 @@ def route_v2_project_project_id_patches(project_id):
235
236
patches = patches .filter (Patch .state == patch_state )
236
237
if confirmation_state :
237
238
patches = patches .filter (Patch .confirmation == confirmation_state )
239
+ if run_state :
240
+ patches = patches .join (Run ).filter (Run .log == run_state )
238
241
239
242
# add pagination
240
243
patches = patches .paginate (page , app .config ['ITEMS_PER_PAGE' ], False )
241
244
242
- return render_template ('v2_patches.html' , project = project , patches = patches )
245
+ return render_template ('v2_patches.html' , project = project , patches = patches , filter_patch_state = patch_state ,
246
+ filter_confirmation_state = confirmation_state , filter_run_state = run_state )
243
247
244
248
245
249
@app .route ('/projects/<int:project_id>/patches/<int:patch_id>' , methods = ['GET' , 'POST' ])
246
250
def route_v2_project_project_id_patches_patch_id (project_id , patch_id ):
251
+ # retrieve project
247
252
project = Project .query .get (project_id )
248
253
if project is None :
249
254
abort (404 )
250
255
256
+ # retrieve patch
251
257
patch = Patch .query .get (patch_id )
252
258
if patch is None :
253
259
abort (404 )
254
260
261
+ # retrieve parameters
262
+ filter_patch_state = request .args .get ('filter_patch_state' )
263
+ filter_confirmation_state = request .args .get ('filter_confirmation_state' )
264
+ filter_run_state = request .args .get ('filter_run_state' )
265
+
255
266
form = SetConfirmationForm ()
256
267
257
268
if request .method == 'GET' :
@@ -260,7 +271,22 @@ def route_v2_project_project_id_patches_patch_id(project_id, patch_id):
260
271
patch .confirmation = form .confirmation .data
261
272
db .session .commit ()
262
273
263
- return render_template ('v2_patch.html' , project = project , patch = patch , form = form )
274
+ # retrieve previous and next patch id
275
+ filtered_patches = Patch .query
276
+ if filter_patch_state :
277
+ filtered_patches = filtered_patches .where (Patch .state == filter_patch_state )
278
+ if filter_confirmation_state :
279
+ filtered_patches = filtered_patches .where (Patch .confirmation == filter_confirmation_state )
280
+ if filter_run_state :
281
+ filtered_patches = filtered_patches .join (Run ).filter (Run .log == filter_run_state )
282
+
283
+ previous_patch = filtered_patches .where (Patch .id < patch .id ).order_by (Patch .id .desc ()).first ()
284
+
285
+ next_patch = filtered_patches .where (Patch .id > patch .id ).order_by (Patch .id ).first ()
286
+
287
+ return render_template ('v2_patch.html' , project = project , patch = patch , form = form ,
288
+ filter_patch_state = filter_patch_state , filter_confirmation_state = filter_confirmation_state ,
289
+ filter_run_state = filter_run_state , previous_patch = previous_patch , next_patch = next_patch )
264
290
265
291
266
292
@app .route ('/projects/<int:project_id>/files/<int:file_id>/generate' , methods = ['GET' , 'POST' ])
@@ -332,4 +358,3 @@ def route_v2_mutators_mutator_id(mutator_id):
332
358
abort (404 )
333
359
334
360
return render_template ('v2_mutator.html' , mutator = mutator , patches = patches )
335
-
0 commit comments