4141from google .oauth2 import id_token
4242from google_auth_oauthlib .flow import Flow
4343from application .utils .spreadsheet import write_csv
44+ from application .config import ENABLE_MYOPENCRE
4445import oauthlib
4546import google .auth .transport .requests
4647
@@ -106,6 +107,11 @@ def neo4j_not_running_rejection():
106107 )
107108
108109
110+ @app .route ("/api/capabilities" )
111+ def capabilities ():
112+ return jsonify ({"myopencre" : ENABLE_MYOPENCRE })
113+
114+
109115@app .route ("/rest/v1/id/<creid>" , methods = ["GET" ])
110116@app .route ("/rest/v1/name/<crename>" , methods = ["GET" ])
111117def find_cre (creid : str = None , crename : str = None ) -> Any : # refer
@@ -764,22 +770,21 @@ def all_cres() -> Any:
764770
765771@app .route ("/rest/v1/cre_csv" , methods = ["GET" ])
766772def get_cre_csv () -> Any :
773+ if not ENABLE_MYOPENCRE :
774+ abort (404 )
767775 if posthog :
768776 posthog .capture (f"get_cre_csv" , "" )
769-
770777 database = db .Node_collection ()
771778 root_cres = database .get_root_cres ()
772779 if root_cres :
773780 docs = sheet_utils .generate_mapping_template_file (
774781 database = database , docs = root_cres
775782 )
776783 csvVal = write_csv (docs = docs ).getvalue ().encode ("utf-8" )
777-
778784 # Creating the byteIO object from the StringIO Object
779785 mem = io .BytesIO ()
780786 mem .write (csvVal )
781787 mem .seek (0 )
782-
783788 return send_file (
784789 mem ,
785790 as_attachment = True ,
@@ -791,6 +796,9 @@ def get_cre_csv() -> Any:
791796
792797@app .route ("/rest/v1/cre_csv_import" , methods = ["POST" ])
793798def import_from_cre_csv () -> Any :
799+ if not ENABLE_MYOPENCRE :
800+ abort (404 )
801+
794802 if not os .environ .get ("CRE_ALLOW_IMPORT" ):
795803 abort (
796804 403 ,
0 commit comments