Skip to content

Commit

Permalink
Merge pull request #3157 from antgonza/wet-lab-admin
Browse files Browse the repository at this point in the history
[WIP] adding a new wet-lab admin user
  • Loading branch information
charles-cowart authored Nov 1, 2021
2 parents 22b0f4f + 9cb2c42 commit df4ad9a
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 11 deletions.
20 changes: 20 additions & 0 deletions qiita_db/handlers/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,26 @@ def post(self):


class ArtifactTypeHandler(OauthBaseHandler):
@authenticate_oauth
def get(self):
"""Returns the artifact types and their local mountpoint location
Returns
-------
dict
'artifact_type': local mountpoint
"""
atypes = dict()
for atype in qdb.util.get_artifact_types():
mountpoints = qdb.util.get_mountpoint(atype)
if mountpoints:
# [0][1]: get latest/active and the actual location
atypes[atype] = mountpoints[0][1]
# add the upload location
atypes['uploads'] = qdb.util.get_mountpoint('uploads')[0][1]

self.write(atypes)

@authenticate_oauth
def post(self):
"""Creates a new artifact type
Expand Down
16 changes: 16 additions & 0 deletions qiita_db/handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ def test_post(self):
data=data)
self.assertEqual(obs.code, 200)

def test_get(self):
obs = self.get('/qiita_db/artifacts/types/', headers=self.header)
self.assertEqual(obs.code, 200)

basedir = qdb.util.get_db_files_base_dir()
exp = {
"SFF": f"{basedir}/SFF",
"FASTA": f"{basedir}/FASTA",
"FASTA_Sanger": f"{basedir}/FASTA_Sanger",
"Demultiplexed": f"{basedir}/Demultiplexed",
"FASTQ": f"{basedir}/FASTQ",
"per_sample_FASTQ": f"{basedir}/per_sample_FASTQ",
"BIOM": f"{basedir}/BIOM",
"uploads": f"{basedir}/uploads"}
self.assertDictEqual(loads(obs.body), exp)


class APIArtifactHandlerTests(OauthTestingBase):
def setUp(self):
Expand Down
3 changes: 3 additions & 0 deletions qiita_db/support_files/patches/84.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- October 21, 2021
-- adding a new user level: wet-lab admin
INSERT INTO qiita.user_level (name, description) VALUES ('wet-lab admin', 'Can access the private jobs');
8 changes: 6 additions & 2 deletions qiita_pet/handlers/admin_processing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class AdminProcessingJobBaseClass(BaseHandler):
def _check_access(self):
if self.current_user.level not in {'admin', 'dev'}:
if self.current_user.level not in {'admin', 'wet-lab admin'}:
raise HTTPError(403, reason="User %s doesn't have sufficient "
"privileges to view error page" %
self.current_user.email)
Expand Down Expand Up @@ -62,7 +62,11 @@ def get(self):
for job in cmd.processing_jobs:
if job.hidden:
continue
msg = '' if job.status != 'error' else job.log.msg
msg = ''
if job.status == 'error':
msg = job.log.msg
elif job.status == 'running':
msg = job.step
msg = msg.replace('\n', '</br>')
outputs = []
if job.status == 'success':
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/handlers/artifact_handlers/base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def check_artifact_access(user, artifact):
QiitaHTTPError
If the user doesn't have access to the given artifact
"""
if user.level == 'admin':
if user.level in ('admin', 'wet-lab admin'):
return
if artifact.visibility != 'public':
study = artifact.study
Expand Down
3 changes: 3 additions & 0 deletions qiita_pet/support_files/doc/source/dev/rest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ the important parts of the values are described in the Parameters column.
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
|GET | ``/qiita_db/jobs/<job_id>`` | | Get the job information | JobHandler |
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
|GET | ``/qiita_db/artifacts/types/`` | | Retrieves the available artifact types and their | ArtifactTypeHandler |
| | | | local mount point | |
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
|POST | ``/qiita_db/artifacts/types/`` | ``name: str``, ``description: str``, | Creates a new artifact type | ArtifactTypeHandler |
| | | ``can_be_submitted_to_ebi: bool``, | | |
| | | ``can_be_submitted_to_vamps: bool``, | | |
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/templates/admin_processing_job.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'</b>: ');

if (status === 'running' || status === 'queued') {
out.push(row[0] + ' <i>' + row[3] + '</i>')
out.push(row[0] + '</br> <i>' + row[3] + '</i>')
}
else {
// We write a callback attribute on the link to be able to display a
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/templates/artifact_ajax/artifact_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h4 style="color: #FF2222;">This artifact is being deleted</h4>

{% if artifact_type == 'BIOM' and not is_from_analysis %}
<input type="button" class="btn btn-default btn-sm" value="Add to Analysis" onclick="send_samples_to_analysis(this, [{{artifact_id}}]);">
{% else %}
{% elif artifact_type != 'job-output-folder' %}
<a class="btn btn-default btn-sm" id="process-btn"><span class="glyphicon glyphicon-play"></span> Process</a>
{% end %}

Expand Down Expand Up @@ -182,7 +182,7 @@ <h4 style="color: #FF2222;">This artifact is being deleted</h4>
</div>
</div>

{% if files %}
{% if files and artifact_type != 'job-output-folder' %}
<div class='row'>
<div class='col-md-12'>
<b>Available files:</b>
Expand Down
12 changes: 7 additions & 5 deletions qiita_pet/templates/sitebase.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,17 @@
</ul>
</li>
{% set user_level = user.level %}
{% if user_level == 'admin' %}
{% if user_level in ('admin', 'wet-lab admin') %}
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Admin<b class="caret"></b></a>
<ul class="dropdown-menu">
{% if qiita_config.portal == "QIITA" %}
<li><a href="{% raw qiita_config.portal_dir %}/admin/error/">View Errors</a></li>
<li><a href="{% raw qiita_config.portal_dir %}/admin/approval/">View Studies awaiting approval</a></li>
<li><a href="{% raw qiita_config.portal_dir %}/admin/portals/studies/">Edit study portal connections</a></li>
<li><a href="{% raw qiita_config.portal_dir %}/admin/processing_jobs/">Processing Jobs</a></li>
{% if user_level == 'admin' %}
<li><a href="{% raw qiita_config.portal_dir %}/admin/error/">View Errors</a></li>
<li><a href="{% raw qiita_config.portal_dir %}/admin/approval/">View Studies awaiting approval</a></li>
<li><a href="{% raw qiita_config.portal_dir %}/admin/portals/studies/">Edit study portal connections</a></li>
{% end %}
<li><a href="{% raw qiita_config.portal_dir %}/admin/processing_jobs/">Processing Jobs</a></li>
{% else %}
<li><a href="/">Admin tasks can only be done in the main Qiita portal</a></li>
{% end %}
Expand Down

0 comments on commit df4ad9a

Please sign in to comment.