@@ -316,6 +316,30 @@ def perform_create(self, serializer):
316
316
"""Create a new recipe."""
317
317
serializer .save (user = self .request .user )
318
318
319
+ @action (detail = False , methods = ['POST' ])
320
+ def bulk_submit_test (self , request ):
321
+ if isinstance (request .data , dict ) and request .data ['update' ]:
322
+ for entry in request .data ['data' ]:
323
+ submission_entry = SubmissionEntry .objects .filter (pk = entry ['id' ])
324
+ for id in entry ['curation_reviews' ]:
325
+ curation_review = CurationReview .objects .get (pk = id )
326
+ print (entry ['effect' ], curation_review .annotated_effect , entry ['tier' ], curation_review .annotated_tier )
327
+ print (entry ['effect' ] == curation_review .annotated_effect and entry ['tier' ] == curation_review .annotated_tier )
328
+ print ('\n ' * 5 )
329
+ submission_entry = submission_entry [0 ]
330
+ print ([review .acceptance for review in submission_entry .curation_reviews .all ()])
331
+ print (all (review .acceptance for review in submission_entry .curation_reviews .all ()))
332
+ return JsonResponse ({
333
+ "message" : "pi pa po" ,
334
+ })
335
+
336
+ return JsonResponse ({
337
+ "message" : "pi pa po" ,
338
+ })
339
+
340
+
341
+
342
+
319
343
@action (detail = False , methods = ['POST' ])
320
344
def bulk_submit (self , request ):
321
345
@@ -326,8 +350,25 @@ def bulk_submit(self, request):
326
350
review_cycle = submission_entry [0 ].review_cycle + 1 )
327
351
for id in entry ['curation_entries' ]:
328
352
CurationEntry .objects .filter (pk = id ).update (status = 'resubmitted' )
353
+
354
+ for id in entry ['curation_reviews' ]:
355
+ curation_review = CurationReview .objects .get (pk = id )
356
+ if entry ['effect' ] == curation_review .annotated_effect and entry ['tier' ] == curation_review .annotated_tier :
357
+ curation_review .acceptance = True
358
+ else :
359
+ curation_review .acceptance = False
360
+ curation_review .save ()
361
+
362
+ submission_entry = submission_entry [0 ]
363
+ if not all (review .acceptance for review in submission_entry .curation_reviews .all ()):
364
+ submission_entry .if_conflicting_reviews = True
365
+ else :
366
+ submission_entry .if_conflicting_reviews = False
367
+ submission_entry .save ()
368
+
329
369
for id in entry ['curation_reviews' ]:
330
370
CurationReview .objects .get (pk = id ).delete ()
371
+
331
372
return JsonResponse ({
332
373
"message" : "Your annotation was successfully saved!" ,
333
374
@@ -367,7 +408,8 @@ def __save_review_obj(self, obj):
367
408
review = CurationReview .objects .get (id = obj ['id' ])
368
409
else :
369
410
review = CurationReview ()
370
- review .submission_entry = SubmissionEntry .objects .get (id = obj ['submission_entry' ])
411
+ submission_entry = SubmissionEntry .objects .get (id = obj ['submission_entry' ])
412
+ review .submission_entry = submission_entry
371
413
review .annotated_effect = obj ['effect' ]
372
414
review .annotated_tier = obj ['tier' ]
373
415
review .comment = obj ['comment' ]
0 commit comments