Skip to content

Commit

Permalink
Update flask_jwt_extended decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaris committed Jun 27, 2024
1 parent a11723e commit a3f4af8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions src/indra_cogex/apps/curator/curator_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import flask
from flask import Response, abort, redirect, render_template, url_for
from flask_jwt_extended import jwt_optional
from flask_jwt_extended import jwt_required
from flask_wtf import FlaskForm
from indra.statements import Statement
from wtforms import BooleanField, StringField, SubmitField, TextAreaField
Expand Down Expand Up @@ -81,7 +81,7 @@ def gene_ontology():


@curator_blueprint.route("/go/<term>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def curate_go(term: str):
stmts = indra_subnetwork_go(
go_term=("GO", term),
Expand Down Expand Up @@ -163,7 +163,7 @@ def mesh():

@curator_blueprint.route("/mesh/<term>", methods=["GET"])
@curator_blueprint.route("/mesh/<term>/<subset>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def curate_mesh(term: str, subset: Optional[str] = None):
"""Curate all statements for papers with a given MeSH annotation."""
if subset is None:
Expand Down Expand Up @@ -311,7 +311,7 @@ def _render_evidence_counts(


@curator_blueprint.route("/ppi", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def ppi():
"""The PPI curator looks for the highest evidences for PPIs that don't appear in a database."""
return _render_func(
Expand All @@ -329,7 +329,7 @@ def ppi():


@curator_blueprint.route("/goa", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def goa():
"""The GO Annotation curator looks for the highest evidence gene-GO term relations that don't appear in GOA."""
return _render_func(
Expand All @@ -348,7 +348,7 @@ def goa():


@curator_blueprint.route("/conflicts", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def conflicts():
"""Curate statements with conflicting prior curations."""
return _render_func(
Expand All @@ -363,7 +363,7 @@ def conflicts():


@curator_blueprint.route("/tf", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def tf():
"""Curate transcription factors."""
return _render_func(
Expand All @@ -380,7 +380,7 @@ def tf():


@curator_blueprint.route("/kinase", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def kinase():
"""Curate kinases."""
return _render_func(
Expand All @@ -397,7 +397,7 @@ def kinase():


@curator_blueprint.route("/phosphatase", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def phosphatase():
"""Curate phosphatases."""
return _render_func(
Expand All @@ -414,7 +414,7 @@ def phosphatase():


@curator_blueprint.route("/dub", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def deubiquitinase():
"""Curate deubiquitinases."""
return _render_func(
Expand All @@ -431,7 +431,7 @@ def deubiquitinase():


@curator_blueprint.route("/mirna", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def mirna():
"""Curate miRNAs."""
return _render_func(
Expand All @@ -449,7 +449,7 @@ def mirna():

@curator_blueprint.route("/disprot", methods=["GET"])
@curator_blueprint.route("/disprot/<object_prefix>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def disprot(object_prefix: Optional[str] = None):
"""Curate intrensically disordered proteins."""
assert object_prefix in {None, "hgnc", "go", "chebi"}
Expand All @@ -466,14 +466,14 @@ def disprot(object_prefix: Optional[str] = None):


@curator_blueprint.route("/modulator/", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def modulator():
"""Get small molecule modulators for the given protein."""
raise NotImplementedError


@curator_blueprint.route("/entity/<prefix>:<identifier>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def entity(prefix: str, identifier: str):
"""Get all statements about the given entity."""
if prefix in {"pubmed", "pmc", "doi", "trid"}:
Expand Down Expand Up @@ -548,7 +548,7 @@ def get_term(self) -> Tuple[str, str]:


@curator_blueprint.route("/paper", methods=["GET", "POST"])
@jwt_optional
@jwt_required(optional=True)
def paper():
"""Get all statements for the given paper."""
form = PaperForm()
Expand Down Expand Up @@ -622,7 +622,7 @@ def get_nodes(self) -> List[Tuple[str, str]]:


@curator_blueprint.route("/subnetwork", methods=["GET", "POST"])
@jwt_optional
@jwt_required(optional=True)
def subnetwork():
"""Get all statements induced by the nodes."""
form = NodesForm()
Expand Down Expand Up @@ -659,7 +659,7 @@ def subnetwork():


@curator_blueprint.route("/statement/<int:stmt_hash>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def curate_statement(stmt_hash: int):
"""Curate all evidences for the statement."""
start_time = time.time()
Expand Down
8 changes: 4 additions & 4 deletions src/indra_cogex/apps/data_display/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import requests
from flask import Blueprint, Response, abort, jsonify, render_template, request
from flask_jwt_extended import jwt_optional
from flask_jwt_extended import jwt_required

from indra.assemblers.english import EnglishAssembler
from indra.sources.indra_db_rest import IndraDBRestAPIError
Expand Down Expand Up @@ -223,7 +223,7 @@ def biolookup(curie):

# Endpoint for getting evidence
@data_display_blueprint.route("/expand/<stmt_hash>", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def get_evidence(stmt_hash):
try:
# Todo:
Expand Down Expand Up @@ -297,7 +297,7 @@ def get_evidence(stmt_hash):

# Serve the statement display template
@data_display_blueprint.route("/statement_display", methods=["GET"])
@jwt_optional
@jwt_required(optional=True)
def statement_display():
user, roles = resolve_auth(dict(request.args))
email = user.email if user else ""
Expand Down Expand Up @@ -400,7 +400,7 @@ def _get_user():


@data_display_blueprint.route("/curate/<hash_val>", methods=["POST"])
@jwt_optional
@jwt_required(optional=True)
def submit_curation_endpoint(hash_val: str):
email = _get_user()
if not isinstance(email, str):
Expand Down

0 comments on commit a3f4af8

Please sign in to comment.