From f29c2a7e091c5076f790b060efb5eec7247d69f8 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 31 Jan 2025 12:03:40 +0100 Subject: [PATCH] =?UTF-8?q?Pido=20confirmaci=C3=B3n=20para=20insertar=20js?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReyMotaAppsDj/K8S/reymota-ingress.yaml | 31 +++++++++++++++++++ .../commands/importar_repostajes.py | 8 +++++ .../management/commands/importar_vehiculos.py | 7 +++++ 3 files changed, 46 insertions(+) create mode 100644 ReyMotaAppsDj/K8S/reymota-ingress.yaml diff --git a/ReyMotaAppsDj/K8S/reymota-ingress.yaml b/ReyMotaAppsDj/K8S/reymota-ingress.yaml new file mode 100644 index 0000000..99b929b --- /dev/null +++ b/ReyMotaAppsDj/K8S/reymota-ingress.yaml @@ -0,0 +1,31 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + generation: 1 + managedFields: + - apiVersion: networking.k8s.io/v1 + fieldsType: FieldsV1 + fieldsV1: + f:spec: + f:defaultBackend: + .: {} + f:service: + .: {} + f:name: {} + f:port: {} + f:rules: {} + manager: rancher + operation: Update + name: reymota + namespace: reymota +spec: + defaultBackend: + service: + name: nginx + port: + number: 1337 + ingressClassName: nginx + rules: + - host: reymota.rancher.my.org +status: + loadBalancer: {} diff --git a/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_repostajes.py b/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_repostajes.py index fead61b..e7ed1ba 100644 --- a/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_repostajes.py +++ b/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_repostajes.py @@ -2,6 +2,7 @@ import json from django.core.management.base import BaseCommand from repostajes.models import Repostaje + class Command(BaseCommand): help = "Importa repostajes desde un archivo JSON" @@ -15,6 +16,13 @@ class Command(BaseCommand): with open(archivo_json, 'r', encoding='utf-8') as file: datos = json.load(file) + self.stdout.write(self.style.WARNING(f"\nSe encontraron {len(datos)} repostajes en el archivo '{archivo_json}'.")) + confirmar = input("¿Deseas continuar con la importación? (s/n): ").strip().lower() + + if confirmar != 's': + self.stdout.write(self.style.ERROR("Importación cancelada.")) + return + repostajes_creados = 0 for repostaje_data in datos: repostaje, creado = Repostaje.objects.get_or_create( diff --git a/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_vehiculos.py b/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_vehiculos.py index e8ef6ae..c80c97b 100644 --- a/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_vehiculos.py +++ b/ReyMotaAppsDj/reymota/repostajes/management/commands/importar_vehiculos.py @@ -16,6 +16,13 @@ class Command(BaseCommand): with open(archivo_json, 'r', encoding='utf-8') as file: datos = json.load(file) + self.stdout.write(self.style.WARNING(f"\nSe encontraron {len(datos)} vehiculos en el archivo '{archivo_json}'.")) + confirmar = input("¿Deseas continuar con la importación? (s/n): ").strip().lower() + + if confirmar != 's': + self.stdout.write(self.style.ERROR("Importación cancelada.")) + return + vehiculos_creados = 0 for vehiculo_data in datos: vehiculo, creado = Vehiculo.objects.get_or_create(