Skip to content

Commit df4ad9a

Browse files
Merge pull request #3157 from antgonza/wet-lab-admin
[WIP] adding a new wet-lab admin user
2 parents 22b0f4f + 9cb2c42 commit df4ad9a

File tree

9 files changed

+59
-11
lines changed

9 files changed

+59
-11
lines changed

qiita_db/handlers/artifact.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,26 @@ def post(self):
199199

200200

201201
class ArtifactTypeHandler(OauthBaseHandler):
202+
@authenticate_oauth
203+
def get(self):
204+
"""Returns the artifact types and their local mountpoint location
205+
206+
Returns
207+
-------
208+
dict
209+
'artifact_type': local mountpoint
210+
"""
211+
atypes = dict()
212+
for atype in qdb.util.get_artifact_types():
213+
mountpoints = qdb.util.get_mountpoint(atype)
214+
if mountpoints:
215+
# [0][1]: get latest/active and the actual location
216+
atypes[atype] = mountpoints[0][1]
217+
# add the upload location
218+
atypes['uploads'] = qdb.util.get_mountpoint('uploads')[0][1]
219+
220+
self.write(atypes)
221+
202222
@authenticate_oauth
203223
def post(self):
204224
"""Creates a new artifact type

qiita_db/handlers/tests/test_artifact.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ def test_post(self):
287287
data=data)
288288
self.assertEqual(obs.code, 200)
289289

290+
def test_get(self):
291+
obs = self.get('/qiita_db/artifacts/types/', headers=self.header)
292+
self.assertEqual(obs.code, 200)
293+
294+
basedir = qdb.util.get_db_files_base_dir()
295+
exp = {
296+
"SFF": f"{basedir}/SFF",
297+
"FASTA": f"{basedir}/FASTA",
298+
"FASTA_Sanger": f"{basedir}/FASTA_Sanger",
299+
"Demultiplexed": f"{basedir}/Demultiplexed",
300+
"FASTQ": f"{basedir}/FASTQ",
301+
"per_sample_FASTQ": f"{basedir}/per_sample_FASTQ",
302+
"BIOM": f"{basedir}/BIOM",
303+
"uploads": f"{basedir}/uploads"}
304+
self.assertDictEqual(loads(obs.body), exp)
305+
290306

291307
class APIArtifactHandlerTests(OauthTestingBase):
292308
def setUp(self):

qiita_db/support_files/patches/84.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- October 21, 2021
2+
-- adding a new user level: wet-lab admin
3+
INSERT INTO qiita.user_level (name, description) VALUES ('wet-lab admin', 'Can access the private jobs');

qiita_pet/handlers/admin_processing_job.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class AdminProcessingJobBaseClass(BaseHandler):
2121
def _check_access(self):
22-
if self.current_user.level not in {'admin', 'dev'}:
22+
if self.current_user.level not in {'admin', 'wet-lab admin'}:
2323
raise HTTPError(403, reason="User %s doesn't have sufficient "
2424
"privileges to view error page" %
2525
self.current_user.email)
@@ -62,7 +62,11 @@ def get(self):
6262
for job in cmd.processing_jobs:
6363
if job.hidden:
6464
continue
65-
msg = '' if job.status != 'error' else job.log.msg
65+
msg = ''
66+
if job.status == 'error':
67+
msg = job.log.msg
68+
elif job.status == 'running':
69+
msg = job.step
6670
msg = msg.replace('\n', '</br>')
6771
outputs = []
6872
if job.status == 'success':

qiita_pet/handlers/artifact_handlers/base_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def check_artifact_access(user, artifact):
4141
QiitaHTTPError
4242
If the user doesn't have access to the given artifact
4343
"""
44-
if user.level == 'admin':
44+
if user.level in ('admin', 'wet-lab admin'):
4545
return
4646
if artifact.visibility != 'public':
4747
study = artifact.study

qiita_pet/support_files/doc/source/dev/rest.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ the important parts of the values are described in the Parameters column.
3232
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
3333
|GET | ``/qiita_db/jobs/<job_id>`` | | Get the job information | JobHandler |
3434
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
35+
|GET | ``/qiita_db/artifacts/types/`` | | Retrieves the available artifact types and their | ArtifactTypeHandler |
36+
| | | | local mount point | |
37+
+--------+-----------------------------------------------------------------------------------+-----------------------------------------+-----------------------------------------------------+----------------------------+
3538
|POST | ``/qiita_db/artifacts/types/`` | ``name: str``, ``description: str``, | Creates a new artifact type | ArtifactTypeHandler |
3639
| | | ``can_be_submitted_to_ebi: bool``, | | |
3740
| | | ``can_be_submitted_to_vamps: bool``, | | |

qiita_pet/templates/admin_processing_job.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
'</b>: ');
7575

7676
if (status === 'running' || status === 'queued') {
77-
out.push(row[0] + ' <i>' + row[3] + '</i>')
77+
out.push(row[0] + '</br> <i>' + row[3] + '</i>')
7878
}
7979
else {
8080
// We write a callback attribute on the link to be able to display a

qiita_pet/templates/artifact_ajax/artifact_summary.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ <h4 style="color: #FF2222;">This artifact is being deleted</h4>
143143

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

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

185-
{% if files %}
185+
{% if files and artifact_type != 'job-output-folder' %}
186186
<div class='row'>
187187
<div class='col-md-12'>
188188
<b>Available files:</b>

qiita_pet/templates/sitebase.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,17 @@
374374
</ul>
375375
</li>
376376
{% set user_level = user.level %}
377-
{% if user_level == 'admin' %}
377+
{% if user_level in ('admin', 'wet-lab admin') %}
378378
<li class="dropdown">
379379
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Admin<b class="caret"></b></a>
380380
<ul class="dropdown-menu">
381381
{% if qiita_config.portal == "QIITA" %}
382-
<li><a href="{% raw qiita_config.portal_dir %}/admin/error/">View Errors</a></li>
383-
<li><a href="{% raw qiita_config.portal_dir %}/admin/approval/">View Studies awaiting approval</a></li>
384-
<li><a href="{% raw qiita_config.portal_dir %}/admin/portals/studies/">Edit study portal connections</a></li>
385-
<li><a href="{% raw qiita_config.portal_dir %}/admin/processing_jobs/">Processing Jobs</a></li>
382+
{% if user_level == 'admin' %}
383+
<li><a href="{% raw qiita_config.portal_dir %}/admin/error/">View Errors</a></li>
384+
<li><a href="{% raw qiita_config.portal_dir %}/admin/approval/">View Studies awaiting approval</a></li>
385+
<li><a href="{% raw qiita_config.portal_dir %}/admin/portals/studies/">Edit study portal connections</a></li>
386+
{% end %}
387+
<li><a href="{% raw qiita_config.portal_dir %}/admin/processing_jobs/">Processing Jobs</a></li>
386388
{% else %}
387389
<li><a href="/">Admin tasks can only be done in the main Qiita portal</a></li>
388390
{% end %}

0 commit comments

Comments
 (0)