Skip to content

Commit

Permalink
issue #1216 - add links to VCF export
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Dec 19, 2024
1 parent 22d8431 commit e9e81b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion snpdb/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class VCFListGrid(JqGridUserRowConfig):
model = VCF
caption = 'VCFs'
fields = ["id", "name", "date", "import_status", "genome_build__name", "user__username", "source",
fields = ["id", "name", "vcf_url", "date", "import_status", "genome_build__name", "user__username", "source",
"uploadedvcf__uploaded_file__import_source", "genotype_samples", "project__name", "cohort__import_status",
"uploadedvcf__vcf_importer__name", 'uploadedvcf__vcf_importer__version']
colmodel_overrides = {
Expand All @@ -38,6 +38,7 @@ class VCFListGrid(JqGridUserRowConfig):
'formatter_kwargs': {"icon_css_class": "vcf-icon",
"url_name": "view_vcf",
"url_object_column": "id"}},
"vcf_url": {'name': 'vcf_url', 'label': 'VCF URL', "model_field": False, 'hidden': True},
'import_status': {'formatter': 'viewImportStatus'},
"genome_build__name": {"label": "Genome Build"},
'user__username': {'label': 'Uploaded by', 'width': 60},
Expand All @@ -62,6 +63,18 @@ def __init__(self, user, **kwargs):
genome_build = GenomeBuild.get_name_or_alias(genome_build_name)
queryset = queryset.filter(genome_build=genome_build)

fake_number = "1234567890"
view_vcf_url = reverse('view_vcf', kwargs={"vcf_id": fake_number}).rstrip(fake_number)
view_vcf_url_prefix = get_url_from_view_path(view_vcf_url)
annotation_kwargs = {
"vcf_url": Func(
Value(view_vcf_url_prefix),
F("pk"),
function="CONCAT",
output_field=CharField(),
),
}
queryset = queryset.annotate(**annotation_kwargs)
self.queryset = queryset.order_by("-pk").values(*self.get_field_names())
self.extra_config.update({'shrinkToFit': False,
'sortname': 'id',
Expand Down
2 changes: 1 addition & 1 deletion snpdb/templates/snpdb/data/vcfs.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@

<div>
{% user_data_grid_filter 'vcf' 'VCFs' %}
{% jqgrid 'vcfs_grid' 'vcf' search=False delete=True template_name='snpdb/grids/vcfs_grid.html' init_func='vcfInitFunc' %}
{% jqgrid 'vcfs_grid' 'vcf' search=False delete=True download_grid_json_as_csv=True template_name='snpdb/grids/vcfs_grid.html' init_func='vcfInitFunc' %}
</div>

0 comments on commit e9e81b6

Please sign in to comment.