4242from google .oauth2 import id_token
4343from google_auth_oauthlib .flow import Flow
4444from application .utils .spreadsheet import write_csv
45+ from application .config import ENABLE_MYOPENCRE
4546import oauthlib
4647import google .auth .transport .requests
4748
@@ -127,6 +128,11 @@ def neo4j_not_running_rejection():
127128 )
128129
129130
131+ @app .route ("/api/capabilities" )
132+ def capabilities ():
133+ return jsonify ({"myopencre" : ENABLE_MYOPENCRE })
134+
135+
130136@app .route ("/rest/v1/id/<creid>" , methods = ["GET" ])
131137@app .route ("/rest/v1/name/<crename>" , methods = ["GET" ])
132138def find_cre (creid : str = None , crename : str = None ) -> Any : # refer
@@ -827,22 +833,21 @@ def all_cres() -> Any:
827833
828834@app .route ("/rest/v1/cre_csv" , methods = ["GET" ])
829835def get_cre_csv () -> Any :
836+ if not ENABLE_MYOPENCRE :
837+ abort (404 )
830838 if posthog :
831839 posthog .capture (f"get_cre_csv" , "" )
832-
833840 database = db .Node_collection ()
834841 root_cres = database .get_root_cres ()
835842 if root_cres :
836843 docs = sheet_utils .generate_mapping_template_file (
837844 database = database , docs = root_cres
838845 )
839846 csvVal = write_csv (docs = docs ).getvalue ().encode ("utf-8" )
840-
841847 # Creating the byteIO object from the StringIO Object
842848 mem = io .BytesIO ()
843849 mem .write (csvVal )
844850 mem .seek (0 )
845-
846851 return send_file (
847852 mem ,
848853 as_attachment = True ,
@@ -854,6 +859,9 @@ def get_cre_csv() -> Any:
854859
855860@app .route ("/rest/v1/cre_csv_import" , methods = ["POST" ])
856861def import_from_cre_csv () -> Any :
862+ if not ENABLE_MYOPENCRE :
863+ abort (404 )
864+
857865 if not os .environ .get ("CRE_ALLOW_IMPORT" ):
858866 abort (
859867 403 ,
0 commit comments