def cowbat_processing(request, sequencing_run_pk): sequencing_run = get_object_or_404(SequencingRun, pk=sequencing_run_pk) if sequencing_run.status == 'Unprocessed': SequencingRun.objects.filter(pk=sequencing_run.pk).update( status='Processing') run_cowbat_batch.apply_async(queue='cowbat', args=(sequencing_run.pk, )) # Find percent complete (approximately). Not sure that having calls to azure batch API in views is a good thing. # Will have to see if performance is terrible because of it. if sequencing_run.status == 'Processing': progress = find_percent_complete(sequencing_run) else: progress = 1 form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): Email = form.cleaned_data.get('email') if Email not in sequencing_run.emails_array: sequencing_run.emails_array.append(Email) sequencing_run.save() form = EmailForm() messages.success(request, _('Email saved')) return render(request, 'cowbat/cowbat_processing.html', { 'sequencing_run': sequencing_run, 'form': form, 'progress': str(progress) })
def neighbor_result(request, neighbor_request_pk): neighbor_request_object = get_object_or_404(NearestNeighbors, pk=neighbor_request_pk) result_dict = dict() if neighbor_request_object.status == 'Complete': neighbor_details = NearNeighborDetail.objects.filter( near_neighbor_request=neighbor_request_object) for neighbor_detail in neighbor_details: result_dict[neighbor_detail.seqid] = neighbor_detail.distance id_dict = id_sync(result_dict.keys()) form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') if email not in neighbor_request_object.emails_array: neighbor_request_object.emails_array.append(email) neighbor_request_object.save() form = EmailForm() messages.success(request, _('Email saved')) return render( request, 'geneseekr/neighbor_result.html', { 'neighbor_request': neighbor_request_object, 'results': result_dict, 'idDict': id_dict, 'form': form })
def amr_result(request, amr_request_pk): amr_request_object = get_object_or_404(AMRSummary, pk=amr_request_pk) form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') if email not in amr_request.emails_array: amr_request_object.emails_array.append(email) amr_request_object.save() form = EmailForm() messages.success(request, _('Email saved')) return render(request, 'geneseekr/amr_result.html', { 'amr_request': amr_request_object, 'form': form, })
def geneseekr_processing(request, geneseekr_request_pk): geneseekr_request = get_object_or_404(GeneSeekrRequest, pk=geneseekr_request_pk) form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') if email not in geneseekr_request.emails_array: geneseekr_request.emails_array.append(email) geneseekr_request.save() form = EmailForm() messages.success(request, _('Email saved')) return render(request, 'geneseekr/geneseekr_processing.html', { 'geneseekr_request': geneseekr_request, 'form': form })
def prokka_result(request, prokka_request_pk): prokka_request_object = get_object_or_404(ProkkaRequest, pk=prokka_request_pk) form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') if email not in prokka_request.emails_array: prokka_request_object.emails_array.append(email) prokka_request_object.save() form = EmailForm() messages.success(request, _('Email saved')) return render(request, 'geneseekr/prokka_result.html', { 'prokka_request': prokka_request_object, 'form': form, })
def tree_result(request, tree_request_pk): tree_request = get_object_or_404(Tree, pk=tree_request_pk) id_dict = id_sync(tree_request.seqids) form = EmailForm() if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') if email not in tree_request.emails_array: tree_request.emails_array.append(email) tree_request.save() form = EmailForm() messages.success(request, _('Email saved')) return render(request, 'geneseekr/tree_result.html', { 'tree_request': tree_request, 'form': form, 'idDict': id_dict, })
def test_email_form_bad(self): form = EmailForm({ 'email': 'not_an_email_at_all' }) self.assertFalse(form.is_valid())
def test_email_form_good(self): form = EmailForm({ 'email': '*****@*****.**' }) self.assertTrue(form.is_valid())