diff --git a/primed/dbgap/tables.py b/primed/dbgap/tables.py index 622bbad2..13d4e363 100644 --- a/primed/dbgap/tables.py +++ b/primed/dbgap/tables.py @@ -184,21 +184,35 @@ def render_number_requested_dars(self, record): class dbGaPDataAccessRequestTable(tables.Table): """Class to render a table of dbGaPDataAccessRequest objects.""" + dbgap_dar_id = tables.columns.Column(verbose_name="DAR") + dbgap_dac = tables.columns.Column(verbose_name="DAC") dbgap_accession = tables.columns.Column( - verbose_name=" dbGaP accession", + verbose_name="Accession", accessor="get_dbgap_accession", ) + dbgap_consent_abbreviation = tables.columns.Column(verbose_name="Consent") + dbgap_current_status = tables.columns.Column(verbose_name="Current status") matching_workspaces = tables.columns.Column( accessor="get_dbgap_workspaces", orderable=False, default=" " ) + class Meta: + model = models.dbGaPDataAccessRequest + fields = ( + "dbgap_dar_id", + "dbgap_dac", + "dbgap_accession", + "dbgap_consent_abbreviation", + "dbgap_current_status", + ) + order_by = ("dbgap_dar_id",) + attrs = {"class": "table table-sm"} + def render_matching_workspaces(self, value, record): template_code = """ -
  • - {{workspace}} - -
  • + + {{workspace}} """ items = [] for dbgap_workspace in value: @@ -207,11 +221,11 @@ def render_matching_workspaces(self, value, record): ) this_context = { "has_access": has_access, - "workspace": dbgap_workspace, + "workspace": dbgap_workspace.workspace.name, } this = Template(template_code).render(Context(this_context)) items = items + [this] - html = format_html("") + html = format_html("" + "
    ".join(items)) return html def render_dbgap_phs(self, value): @@ -219,26 +233,14 @@ def render_dbgap_phs(self, value): def render_dbgap_accession(self, value, record): return format_html( - """ - {} - - + """{} """.format( record.get_dbgap_link(), value ) ) - class Meta: - model = models.dbGaPDataAccessRequest - fields = ( - "dbgap_dar_id", - "dbgap_dac", - "dbgap_accession", - "dbgap_consent_code", - "dbgap_consent_abbreviation", - "dbgap_current_status", - ) - order_by = ("dbgap_dar_id",) + # def render_consent(self, record): + # return "{} ({})".format(record.dbgap_consent_abbreviation, record.dbgap_consent_code) class dbGaPDataAccessRequestSummaryTable(tables.Table): diff --git a/primed/dbgap/tests/test_tables.py b/primed/dbgap/tests/test_tables.py index 01d8b538..5ca09a30 100644 --- a/primed/dbgap/tests/test_tables.py +++ b/primed/dbgap/tests/test_tables.py @@ -531,7 +531,8 @@ def test_one_matching_workspace_with_access(self): ) table = self.table_class([dar]) value = table.render_matching_workspaces(dar.get_dbgap_workspaces(), dar) - self.assertIn(str(workspace), value) + self.assertIn(workspace.workspace.name, value) + self.assertNotIn(workspace.workspace.billing_project.name, value) self.assertIn("circle-fill", value) def test_one_matching_workspace_without_access(self): @@ -542,7 +543,7 @@ def test_one_matching_workspace_without_access(self): ) table = self.table_class([dar]) value = table.render_matching_workspaces(dar.get_dbgap_workspaces(), dar) - self.assertIn(str(workspace), value) + self.assertIn(workspace.workspace.name, value) self.assertIn("square-fill", value) def test_two_matching_workspaces(self): @@ -568,8 +569,8 @@ def test_two_matching_workspaces(self): ) table = self.table_class([dar]) value = table.render_matching_workspaces(dar.get_dbgap_workspaces(), dar) - self.assertIn(str(workspace_1), value) - self.assertIn(str(workspace_2), value) + self.assertIn(workspace_1.workspace.name, value) + self.assertIn(workspace_2.workspace.name, value) def test_ordering(self): """Instances are ordered alphabetically by dbgap_dar_id.""" diff --git a/primed/templates/dbgap/dbgapdataaccesssnapshot_detail.html b/primed/templates/dbgap/dbgapdataaccesssnapshot_detail.html index 68c0ded1..a96a64ac 100644 --- a/primed/templates/dbgap/dbgapdataaccesssnapshot_detail.html +++ b/primed/templates/dbgap/dbgapdataaccesssnapshot_detail.html @@ -36,12 +36,12 @@

    -

    -
    +
    {% render_table data_access_request_table %}