|
a |
|
b/qiita_pet/handlers/prep_template.py |
|
|
1 |
# ----------------------------------------------------------------------------- |
|
|
2 |
# Copyright (c) 2014--, The Qiita Development Team. |
|
|
3 |
# |
|
|
4 |
# Distributed under the terms of the BSD 3-clause License. |
|
|
5 |
# |
|
|
6 |
# The full license is in the file LICENSE, distributed with this software. |
|
|
7 |
# ----------------------------------------------------------------------------- |
|
|
8 |
|
|
|
9 |
from tornado.web import authenticated |
|
|
10 |
|
|
|
11 |
from qiita_pet.handlers.base_handlers import BaseHandler |
|
|
12 |
from qiita_pet.handlers.api_proxy import ( |
|
|
13 |
prep_template_post_req, prep_template_patch_req, prep_template_delete_req, |
|
|
14 |
prep_template_graph_get_req, prep_template_jobs_get_req) |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
class PrepTemplateHandler(BaseHandler): |
|
|
18 |
@authenticated |
|
|
19 |
def post(self): |
|
|
20 |
"""Creates a prep template""" |
|
|
21 |
study_id = self.get_argument('study_id') |
|
|
22 |
data_type = self.get_argument('data-type') |
|
|
23 |
ena_ontology = self.get_argument('ena-ontology', None) |
|
|
24 |
user_ontology = self.get_argument('user-ontology', None) |
|
|
25 |
new_ontology = self.get_argument('new-ontology', None) |
|
|
26 |
prep_fp = self.get_argument('prep-file') |
|
|
27 |
name = self.get_argument('name', None) |
|
|
28 |
|
|
|
29 |
response = prep_template_post_req( |
|
|
30 |
study_id, self.get_current_user().id, prep_fp, data_type, |
|
|
31 |
ena_ontology, user_ontology, new_ontology, name=name) |
|
|
32 |
|
|
|
33 |
self.write(response) |
|
|
34 |
|
|
|
35 |
@authenticated |
|
|
36 |
def patch(self): |
|
|
37 |
"""Patches a prep template in the system |
|
|
38 |
|
|
|
39 |
Follows the JSON PATCH specification: |
|
|
40 |
https://tools.ietf.org/html/rfc6902 |
|
|
41 |
""" |
|
|
42 |
req_op = self.get_argument('op') |
|
|
43 |
req_path = self.get_argument('path') |
|
|
44 |
req_value = self.get_argument('value', None) |
|
|
45 |
req_from = self.get_argument('from', None) |
|
|
46 |
|
|
|
47 |
response = prep_template_patch_req( |
|
|
48 |
self.current_user.id, req_op, req_path, req_value, req_from) |
|
|
49 |
|
|
|
50 |
self.write(response) |
|
|
51 |
|
|
|
52 |
@authenticated |
|
|
53 |
def delete(self): |
|
|
54 |
"""Deletes a prep template from the system""" |
|
|
55 |
prep_id = self.get_argument('prep-template-id') |
|
|
56 |
self.write(prep_template_delete_req(prep_id, self.current_user.id)) |
|
|
57 |
|
|
|
58 |
|
|
|
59 |
class PrepTemplateGraphHandler(BaseHandler): |
|
|
60 |
@authenticated |
|
|
61 |
def get(self, prep_id): |
|
|
62 |
self.write( |
|
|
63 |
prep_template_graph_get_req(prep_id, self.current_user.id)) |
|
|
64 |
|
|
|
65 |
|
|
|
66 |
class PrepTemplateJobHandler(BaseHandler): |
|
|
67 |
@authenticated |
|
|
68 |
def get(self, prep_id): |
|
|
69 |
self.write(prep_template_jobs_get_req(prep_id, self.current_user.id)) |