From a322e972b6b58236b358b17e6ea7e3586f634ea2 Mon Sep 17 00:00:00 2001 From: matthewgeng Date: Sat, 5 Mar 2022 16:06:50 -0500 Subject: [PATCH 1/3] remove all no-auth and no-file-storage tags --- backend/python/app/__init__.py | 52 ------------------- backend/python/app/middlewares/validate.py | 3 -- backend/python/app/rest/__init__.py | 3 -- backend/python/app/rest/entity_routes.py | 12 ----- .../implementations/entity_service.py | 18 ------- 5 files changed, 88 deletions(-) diff --git a/backend/python/app/__init__.py b/backend/python/app/__init__.py index a39314e9..3689b98f 100644 --- a/backend/python/app/__init__.py +++ b/backend/python/app/__init__.py @@ -99,59 +99,7 @@ def create_app(config_name): {"storageBucket": os.getenv("FIREBASE_STORAGE_DEFAULT_BUCKET")}, ) # } file-storage - # no-file-storage { - firebase_admin.initialize_app( - firebase_admin.credentials.Certificate( - { - "type": "service_account", - "project_id": os.getenv("FIREBASE_PROJECT_ID"), - "private_key_id": os.getenv("FIREBASE_SVC_ACCOUNT_PRIVATE_KEY_ID"), - "private_key": os.getenv("FIREBASE_SVC_ACCOUNT_PRIVATE_KEY").replace( - "\\n", "\n" - ), - "client_email": os.getenv("FIREBASE_SVC_ACCOUNT_CLIENT_EMAIL"), - "client_id": os.getenv("FIREBASE_SVC_ACCOUNT_CLIENT_ID"), - "auth_uri": os.getenv("FIREBASE_SVC_ACCOUNT_AUTH_URI"), - "token_uri": os.getenv("FIREBASE_SVC_ACCOUNT_TOKEN_URI"), - "auth_provider_x509_cert_url": os.getenv( - "FIREBASE_SVC_ACCOUNT_AUTH_PROVIDER_X509_CERT_URL" - ), - "client_x509_cert_url": os.getenv( - "FIREBASE_SVC_ACCOUNT_CLIENT_X509_CERT_URL" - ), - } - ), - ) - # } no-file-storage - # } auth - # no-auth { - # file-storage { - firebase_admin.initialize_app( - firebase_admin.credentials.Certificate( - { - "type": "service_account", - "project_id": os.getenv("FIREBASE_PROJECT_ID"), - "private_key_id": os.getenv("FIREBASE_SVC_ACCOUNT_PRIVATE_KEY_ID"), - "private_key": os.getenv("FIREBASE_SVC_ACCOUNT_PRIVATE_KEY").replace( - "\\n", "\n" - ), - "client_email": os.getenv("FIREBASE_SVC_ACCOUNT_CLIENT_EMAIL"), - "client_id": os.getenv("FIREBASE_SVC_ACCOUNT_CLIENT_ID"), - "auth_uri": os.getenv("FIREBASE_SVC_ACCOUNT_AUTH_URI"), - "token_uri": os.getenv("FIREBASE_SVC_ACCOUNT_TOKEN_URI"), - "auth_provider_x509_cert_url": os.getenv( - "FIREBASE_SVC_ACCOUNT_AUTH_PROVIDER_X509_CERT_URL" - ), - "client_x509_cert_url": os.getenv( - "FIREBASE_SVC_ACCOUNT_CLIENT_X509_CERT_URL" - ), - } - ), - {"storageBucket": os.getenv("FIREBASE_STORAGE_DEFAULT_BUCKET")}, - ) - # } file-storage - # } no-auth from . import models, rest models.init_app(app) diff --git a/backend/python/app/middlewares/validate.py b/backend/python/app/middlewares/validate.py index 20a4297e..b8ce9598 100644 --- a/backend/python/app/middlewares/validate.py +++ b/backend/python/app/middlewares/validate.py @@ -51,9 +51,6 @@ def wrapper(*args, **kwargs): req["file"] = request.files.get("file", default=None) dto = dtos[dto_class_name](**req) # } file-storage - # no-file-storage { - dto = dtos[dto_class_name](**request.json) - # } no-file-storage error_message = dto.validate() if error_message: return ( diff --git a/backend/python/app/rest/__init__.py b/backend/python/app/rest/__init__.py index 1b59575d..8c460137 100644 --- a/backend/python/app/rest/__init__.py +++ b/backend/python/app/rest/__init__.py @@ -2,9 +2,6 @@ def init_app(app): # auth { from . import user_routes, auth_routes, entity_routes, documentation_routes # } auth - # no-auth { - from . import entity_routes, documentation_routes - # } no-auth # auth { app.register_blueprint(user_routes.blueprint) diff --git a/backend/python/app/rest/entity_routes.py b/backend/python/app/rest/entity_routes.py index 6c162d0b..904c265b 100644 --- a/backend/python/app/rest/entity_routes.py +++ b/backend/python/app/rest/entity_routes.py @@ -89,9 +89,6 @@ def create_entity(): req["file"] = request.files.get("file", default=None) body = EntityDTO(**req) # } file-storage - # no-file-storage { - body = EntityDTO(**request.json) - # } no-file-storage except Exception as e: error_message = getattr(e, "message", None) return jsonify({"error": (error_message if error_message else str(e))}), 500 @@ -116,9 +113,6 @@ def update_entity(id): req_file = request.files.get("file", default=None) body = EntityDTO(**req, file=req_file) # } file-storage - # no-file-storage { - body = EntityDTO(**request.json) - # } no-file-storage except Exception as e: error_message = getattr(e, "message", None) return jsonify({"error": (error_message if error_message else str(e))}), 500 @@ -183,9 +177,6 @@ def create_entity(): req["file"] = request.files.get("file", default=None) body = EntityDTO(**req) # } file-storage - # no-file-storage { - body = EntityDTO(**request.json) - # } no-file-storage except Exception as e: error_message = getattr(e, "message", None) return jsonify({"error": (error_message if error_message else str(e))}), 500 @@ -210,9 +201,6 @@ def update_entity(id): req["file"] = request.files.get("file", default=None) body = EntityDTO(**req) # } file-storage - # no-file-storage { - body = EntityDTO(**request.json) - # } no-file-storage except Exception as e: error_message = getattr(e, "message", None) return jsonify({"error": (error_message if error_message else str(e))}), 500 diff --git a/backend/python/app/services/implementations/entity_service.py b/backend/python/app/services/implementations/entity_service.py index cfa5c1c9..719ef2ba 100644 --- a/backend/python/app/services/implementations/entity_service.py +++ b/backend/python/app/services/implementations/entity_service.py @@ -12,9 +12,6 @@ class EntityService(IEntityService): # file-storage { def __init__(self, logger, file_storage_service: IFileStorageService): # } file-storage - # no-file-storage { - def __init__(self, logger): - # } no-file-storage self.logger = logger # file-storage { self.file_storage_service = file_storage_service @@ -45,9 +42,6 @@ def create_entity(self, entity): entity.__dict__.pop("file", None) new_entity = Entity(**entity.__dict__, file_name=file_name) # } file-storage - # no-file-storage { - new_entity = Entity(**entity.__dict__) - # } no-file-storage except Exception as error: self.logger.error(str(error)) raise error @@ -87,9 +81,6 @@ def update_entity(self, id, entity): Entity.query.filter_by(id=id).update(entity_dict) # } file-storage - # no-file-storage { - Entity.query.filter_by(id=id).update(entity.__dict__) - # } no-file-storage updated_entity = Entity.query.get(id) db.session.commit() @@ -132,9 +123,6 @@ class EntityService(IEntityService): # file-storage { def __init__(self, logger, file_storage_service: IFileStorageService): # } file-storage - # no-file-storage { - def __init__(self, logger): - # } no-file-storage self.logger = logger # file-storage { self.file_storage_service = file_storage_service @@ -170,9 +158,6 @@ def create_entity(self, entity): entity.__dict__.pop("file", None) new_entity = Entity(**entity.__dict__, file_name=file_name) # } file-storage - # no-file-storage { - new_entity = Entity(**entity.__dict__) - # } no-file-storage new_entity.save() except Exception as error: self.logger.error(str(error)) @@ -206,9 +191,6 @@ def update_entity(self, id, entity): new=True, **entity.__dict__, file_name=file_name ) # } file-storage - # no-file-storage { - updated_entity = Entity.objects(id=id).modify(new=True, **entity.__dict__) - # } no-file-storage if updated_entity is None: self.logger.error("Invalid id") From f7b08b7baaf4b4bbe2707c5ee340625158921bb0 Mon Sep 17 00:00:00 2001 From: matthewgeng Date: Sat, 12 Mar 2022 15:18:21 -0500 Subject: [PATCH 2/3] remove extra tag --- backend/python/app/rest/entity_routes.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/python/app/rest/entity_routes.py b/backend/python/app/rest/entity_routes.py index 904c265b..074cf7d2 100644 --- a/backend/python/app/rest/entity_routes.py +++ b/backend/python/app/rest/entity_routes.py @@ -30,11 +30,6 @@ entity_service = EntityService(current_app.logger, file_storage_service) # } file-storage -# no-file-storage { -# define instance of EntityService -entity_service = EntityService(current_app.logger) - -# } no-file-storage # defines a shared URL prefix for all routes blueprint = Blueprint("entity", __name__, url_prefix="/entities") From a2e7b37fa64adb3efc828e0d89aa05778bca025f Mon Sep 17 00:00:00 2001 From: matthewgeng Date: Sat, 12 Mar 2022 15:18:43 -0500 Subject: [PATCH 3/3] remove another tag --- backend/python/app/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/python/app/__init__.py b/backend/python/app/__init__.py index 3689b98f..b534ae43 100644 --- a/backend/python/app/__init__.py +++ b/backend/python/app/__init__.py @@ -3,11 +3,6 @@ # auth { import firebase_admin # } auth -# no-auth { -# file-storage { -import firebase_admin -# } file-storage -# } no-auth from flask import Flask from flask.cli import ScriptInfo