diff --git a/analysis/tasks/analysis_grid_export_tasks.py b/analysis/tasks/analysis_grid_export_tasks.py index ee473c037..910eab253 100644 --- a/analysis/tasks/analysis_grid_export_tasks.py +++ b/analysis/tasks/analysis_grid_export_tasks.py @@ -1,6 +1,7 @@ import logging import os import uuid +from typing import Optional import celery @@ -16,6 +17,24 @@ from snpdb.models import Cohort, Sample, CachedGeneratedFile +def get_annotated_download_files_cgf(generator, pk) -> dict[str, Optional[CachedGeneratedFile]]: + annotated_download_files = {} + try: + AnalysisTemplate.get_template_from_setting("ANALYSIS_TEMPLATES_AUTO_COHORT_EXPORT") + params_hash_vcf = get_grid_downloadable_file_params_hash(pk, "vcf") + cgf_vcf = CachedGeneratedFile.objects.filter(generator=generator, + params_hash=params_hash_vcf).first() + params_hash_csv = get_grid_downloadable_file_params_hash(pk, "csv") + cgf_csv = CachedGeneratedFile.objects.filter(generator=generator, + params_hash=params_hash_csv).first() + + annotated_download_files = {"vcf": cgf_vcf, "csv": cgf_csv} + except ValueError: + pass + + return annotated_download_files + + def get_grid_downloadable_file_params_hash(pk, export_type): return sha256sum_str(f"{pk}-{export_type}") diff --git a/analysis/templates/analysis/node_data/node_data_graph.html b/analysis/templates/analysis/node_data/node_data_graph.html index 34e47ad17..8a36fe466 100644 --- a/analysis/templates/analysis/node_data/node_data_graph.html +++ b/analysis/templates/analysis/node_data/node_data_graph.html @@ -2,7 +2,7 @@ {% load static %} {% block top %} - + {% endblock top %} {% block css %} diff --git a/analysis/views/views_grid.py b/analysis/views/views_grid.py index 186119081..ba1561138 100644 --- a/analysis/views/views_grid.py +++ b/analysis/views/views_grid.py @@ -133,7 +133,9 @@ def sample_grid_export(request, sample_id, export_type): params_hash = get_grid_downloadable_file_params_hash(sample_id, export_type) task = export_sample_to_downloadable_file.si(sample_id, export_type) cgf = CachedGeneratedFile.get_or_create_and_launch("export_sample_to_downloadable_file", params_hash, task) - return JsonResponse({"celery_task": cgf.task_id}) + if cgf.exception: + raise ValueError(cgf.exception) + return redirect(cgf) def node_grid_export(request, analysis_id): diff --git a/genes/templates/genes/view_gene_symbol.html b/genes/templates/genes/view_gene_symbol.html index 572aacffe..cef225d4c 100644 --- a/genes/templates/genes/view_gene_symbol.html +++ b/genes/templates/genes/view_gene_symbol.html @@ -23,7 +23,7 @@ - + - + + + + @@ -122,14 +141,13 @@

Sample: {{ sample.name }}

{% csrf_token %} {% crispy form form_helper.horizontal %} - {% if can_download_vcf %} + {% if annotated_download_files %}
- {% if can_download_annotated_vcf %} - - - {% endif %} + {% for file_type in annotated_download_files %} +
+ {% endfor %}
{% endif %} diff --git a/snpdb/templates/snpdb/data/view_vcf.html b/snpdb/templates/snpdb/data/view_vcf.html index 7cea6fd25..e233c16b5 100644 --- a/snpdb/templates/snpdb/data/view_vcf.html +++ b/snpdb/templates/snpdb/data/view_vcf.html @@ -10,7 +10,7 @@ {% block title %}{{ vcf.name }}{% endblock %} {% block head %} - +