diff --git a/backend/python/app/__init__.py b/backend/python/app/__init__.py index a39314e..b534ae4 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 @@ -99,59 +94,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 20a4297..b8ce959 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 1b59575..8c46013 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 6c162d0..074cf7d 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") @@ -89,9 +84,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 +108,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 +172,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 +196,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 cfa5c1c..719ef2b 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")