aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-10-01 13:28:49 -0500
committerFrederick Muriuki Muriithi2024-10-01 13:28:49 -0500
commit94513310831875a72d21b3e17af9541a328cabd6 (patch)
tree8097f74a322c67439a5c4f867d2e362dfd8b9ca0
parent6ca2c1520b1fc6e1472fbc74994e3e136cacdc71 (diff)
downloadgn-uploader-94513310831875a72d21b3e17af9541a328cabd6.tar.gz
Extract privileges and use them for access control
-rw-r--r--uploader/phenotypes/views.py8
-rw-r--r--uploader/templates/phenotypes/view-dataset.html5
-rw-r--r--uploader/templates/phenotypes/view-phenotype.html63
3 files changed, 64 insertions, 12 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 7fc3b08..63e0b84 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -200,7 +200,11 @@ def view_phenotype(# pylint: disable=[unused-argument]
"xref_id": xref_id
}
).then(
- lambda resource: render_template(
+ lambda resource: tuple(
+ privilege["privilege_id"] for role in resource["roles"]
+ for privilege in role["privileges"])
+ ).then(
+ lambda privileges: render_template(
"phenotypes/view-phenotype.html",
species=species,
population=population,
@@ -210,7 +214,7 @@ def view_phenotype(# pylint: disable=[unused-argument]
population["Id"],
dataset["Id"],
xref_id),
- resource=resource,
+ privileges=privileges,
activelink="view-phenotype")
).either(
make_either_error_handler(
diff --git a/uploader/templates/phenotypes/view-dataset.html b/uploader/templates/phenotypes/view-dataset.html
index 959b02a..e2ccb60 100644
--- a/uploader/templates/phenotypes/view-dataset.html
+++ b/uploader/templates/phenotypes/view-dataset.html
@@ -51,10 +51,9 @@
<h2>Phenotype Data</h2>
<p>This dataset has a total of {{phenotype_count}} phenotypes.</p>
- <p class="text-danger">
+ <p class="text-warning">
<span class="glyphicon glyphicon-exclamation-sign"></span>
- Limit access here, according to the authorisation privileges the user has on
- this dataset!</p>
+ Display pagination controls here &hellip;</p>
<table class="table">
<thead>
diff --git a/uploader/templates/phenotypes/view-phenotype.html b/uploader/templates/phenotypes/view-phenotype.html
index 5aef6c1..03935f5 100644
--- a/uploader/templates/phenotypes/view-phenotype.html
+++ b/uploader/templates/phenotypes/view-phenotype.html
@@ -24,18 +24,67 @@
{{flash_all_messages()}}
<div class="row">
- {{resource}}
-</div>
+ <div class="panel panel-default">
+ <div class="panel-heading"><strong>Basic Phenotype Details</strong></div>
-<div class="row">
- <h2>Dataset</h2>
- {{dataset}}
+ <table class="table">
+ <tbody>
+ <tr>
+ <td><strong>Phenotype</strong></td>
+ <td>{{phenotype.Post_publication_description or phenotype.Pre_publication_abbreviation or phenotype.Original_description}}
+ </tr>
+ <tr>
+ <td><strong>Cross-Reference ID</strong></td>
+ <td>{{phenotype.xref_id}}</td>
+ </tr>
+ <tr>
+ <td><strong>Collation</strong></td>
+ <td>{{dataset.FullName}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
</div>
<div class="row">
- <h2>Phenotype</h2>
- {{phenotype}}
+ <div class="panel panel-default">
+ <div class="panel-heading"><strong>Phenotype Data</strong></div>
+ {%if "group:resource:view-resource" in privileges%}
+ <table class="table">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>Sample</th>
+ <th>Value</th>
+ <th>Symbol</th>
+ <th>SE</th>
+ <th>N</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {%for item in phenotype.data%}
+ <tr>
+ <td>{{loop.index}}</td>
+ <td>{{item.StrainName}}</td>
+ <td>{{item.value}}</td>
+ <td>{{item.Symbol or "-"}}</td>
+ <td>{{item.error or "-"}}</td>
+ <td>{{item.count or "-"}}</td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+ {%else%}
+ <p class="text-danger">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
+ You do not currently have privileges to view this phenotype in greater
+ detail.
+ </p>
+ {%endif%}
+ </div>
</div>
+
{%endblock%}
{%block sidebarcontents%}