Skip to content

Commit

Permalink
remove SPECIAL_FILE_LINK_HEADERS hack, refactor (#817, #1641)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Apr 21, 2023
1 parent 49b0a38 commit d1afebf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@ Changelog for the SODAR project. Loosely follows the
Unreleased
==========

TODO
Added
-----

- **Samplesheets**
- ``ProjectIrodsFileListAPIView`` in REST API (#1619)
- ``SIMPLE_LINK_TEMPLATE`` helper for simple link creation

Changed
-------

- **General**
- Update URL patterns to use path (#1631)
- **Samplesheets**
- Refactor ``meta_ms`` to remove ``SPECIAL_FILE_LINK_HEADERS`` use (#1641)

Removed
-------

- **Samplesheets**
- ``SPECIAL_FILE_LINK_HEADERS`` hack (#817, #1641)


v0.13.2 (2023-04-18)
Expand Down
9 changes: 4 additions & 5 deletions samplesheets/assayapps/meta_ms/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# from samplesheets.models import GenericMaterial, Process
from samplesheets.plugins import SampleSheetAssayPluginPoint
from samplesheets.rendering import SIMPLE_LINK_TEMPLATE
from samplesheets.utils import get_top_header
from samplesheets.views import MISC_FILES_COLL, RESULTS_COLL

Expand Down Expand Up @@ -87,7 +88,6 @@ def update_row(self, row, table, assay):
if not top_header or i >= th_colspan:
top_header = get_top_header(table, i)
th_colspan += top_header['colspan']

# Data files
if (
header['obj_cls'] == 'GenericMaterial'
Expand All @@ -103,16 +103,15 @@ def update_row(self, row, table, assay):
row[i]['link'] = (
base_url + '/' + coll_name + '/' + row[i]['value']
)

# Report file links within processes
elif (
header['obj_cls'] == 'Process'
and header['value'].lower() == 'report file'
):
row[i]['link'] = (
base_url + '/' + RESULTS_COLL + '/' + row[i]['value']
row[i]['value'] = SIMPLE_LINK_TEMPLATE.format(
label=row[i]['value'],
url=base_url + '/' + RESULTS_COLL + '/' + row[i]['value'],
)

return row

def get_shortcuts(self, assay):
Expand Down
7 changes: 2 additions & 5 deletions samplesheets/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@
'factor_values',
'parameter_values',
]
# HACK: Special cases for inline file linking (see issue #817)
SPECIAL_FILE_LINK_HEADERS = ['report file']
STUDY_TABLE_CACHE_ITEM = 'sheet/tables/study/{study}'
SIMPLE_LINK_TEMPLATE = '{label} <{url}>'


# Table building ---------------------------------------------------------------
Expand Down Expand Up @@ -222,9 +221,7 @@ def _add_header(self, name, header_type=None, obj=None):
header['col_type'] = 'DATE'
elif name.lower() == 'external links':
header['col_type'] = 'EXTERNAL_LINKS'
elif (
name.lower() == 'name' and header['item_type'] == 'DATA'
) or name.lower() in SPECIAL_FILE_LINK_HEADERS: # HACK for issue #817
elif name.lower() == 'name' and header['item_type'] == 'DATA':
header['col_type'] = 'LINK_FILE'
# Recognize ONTOLOGY by headers
elif obj.is_ontology_field(name, header_type):
Expand Down

0 comments on commit d1afebf

Please sign in to comment.