Compare commits
22 Commits
04fb83447f
...
b60ecccad4
| Author | SHA1 | Date | |
|---|---|---|---|
| b60ecccad4 | |||
| 1752b88bc3 | |||
|
|
603df88419 | ||
| 9b447a21ce | |||
|
|
8ca0abc273 | ||
| 0af35ee5db | |||
|
|
5287863c91 | ||
| f77f05e105 | |||
|
|
508bc41b1c | ||
| c4e8675fe8 | |||
| 3fecd8c7fb | |||
|
|
199c0be297 | ||
| 7b0fcf26ff | |||
|
|
ef42701a92 | ||
| f5f53d03c9 | |||
|
|
f003137cd8 | ||
| e304a5c35f | |||
|
|
7e1755ded0 | ||
| 93164e4f2c | |||
|
|
781bb216a3 | ||
| ce7a1414a2 | |||
|
|
85246b6bbd |
@@ -1,6 +1,6 @@
|
|||||||
# django-core-base
|
# django-core-base
|
||||||
|
|
||||||
// V-Encore Lab: Sistema Automatizado v1.0.
|
// V-Encore Lab: Sistema Automatizado v1.0.3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def getData(params):
|
|||||||
# 2. Preparamos el diccionario de parámetros (tu estándar get_parameterized)
|
# 2. Preparamos el diccionario de parámetros (tu estándar get_parameterized)
|
||||||
# Limpiamos los datos antes de enviarlos a la base de datos
|
# Limpiamos los datos antes de enviarlos a la base de datos
|
||||||
id_promocion = clean_sql_int(params.get('id'))
|
id_promocion = clean_sql_int(params.get('id'))
|
||||||
is_active = 1 if params.get('activo') else 0
|
is_active = True if params.get('activo') else False
|
||||||
|
|
||||||
parameter_dict = [id_promocion, is_active]
|
parameter_dict = [id_promocion, is_active]
|
||||||
|
|
||||||
|
|||||||
20
apps/promociones/models.py
Normal file
20
apps/promociones/models.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class Promocion(models.Model):
|
||||||
|
# Campos detectados en tu getData y setData
|
||||||
|
nombre = models.CharField(max_length=255)
|
||||||
|
fecha_inicio = models.DateField(null=True, blank=True)
|
||||||
|
fecha_modificacion = models.DateField(null=True, blank=True)
|
||||||
|
descripcion = models.TextField(null=True, blank=True)
|
||||||
|
activo = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
# Campo usado en tu JOIN de setData
|
||||||
|
categoria_id = models.IntegerField(null=True, blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
# ¡CRÍTICO! Esto le dice a Django que la tabla se llame exactamente
|
||||||
|
# como la has escrito en tu SQL manual
|
||||||
|
db_table = 'promociones'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.nombre
|
||||||
4
core/asgi.py
Normal file
4
core/asgi.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import os
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||||
|
application = get_asgi_application()
|
||||||
@@ -11,7 +11,15 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-change-me-for-production')
|
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-change-me-for-production')
|
||||||
DEBUG = os.getenv('DEBUG', 'True').lower() == 'true'
|
DEBUG = os.getenv('DEBUG', 'True').lower() == 'true'
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
|
ALLOWED_HOSTS = [
|
||||||
|
'v-encore-lab.com',
|
||||||
|
'dev.v-encore-lab.com',
|
||||||
|
'185.187.169.109', # Añade la IP aquí
|
||||||
|
'localhost',
|
||||||
|
'127.0.0.1',
|
||||||
|
'django_app_dev',
|
||||||
|
'django_app_master'
|
||||||
|
]
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|||||||
7
core/wsgi.py
Normal file
7
core/wsgi.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import os
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
# Este es el enlace con tus configuraciones
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
||||||
28
deployments/Jenkinsfile
vendored
28
deployments/Jenkinsfile
vendored
@@ -5,14 +5,13 @@ pipeline {
|
|||||||
stage('Configurar Entorno') {
|
stage('Configurar Entorno') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Aquí asignamos las variables directamente al entorno global de la ejecución
|
|
||||||
if (env.BRANCH_NAME == 'master') {
|
if (env.BRANCH_NAME == 'master') {
|
||||||
echo "--- MODO PRODUCCIÓN DETECTADO ---"
|
env.PROJECT_NAME = "django_master" // <--- Nombre único
|
||||||
env.CONTAINER_NAME = "django_app_master"
|
env.CONTAINER_NAME = "django_app_master"
|
||||||
env.PORT = "8001"
|
env.PORT = "8001"
|
||||||
env.DEBUG_MODE = "0"
|
env.DEBUG_MODE = "0"
|
||||||
} else if (env.BRANCH_NAME == 'dev') {
|
} else {
|
||||||
echo "--- MODO DESARROLLO DETECTADO ---"
|
env.PROJECT_NAME = "django_dev" // <--- Nombre único
|
||||||
env.CONTAINER_NAME = "django_app_dev"
|
env.CONTAINER_NAME = "django_app_dev"
|
||||||
env.PORT = "8000"
|
env.PORT = "8000"
|
||||||
env.DEBUG_MODE = "1"
|
env.DEBUG_MODE = "1"
|
||||||
@@ -22,17 +21,22 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stage('Despliegue') {
|
stage('Despliegue') {
|
||||||
when {
|
when { anyOf { branch 'dev'; branch 'master' } }
|
||||||
anyOf { branch 'dev'; branch 'master' }
|
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
echo "EJECUTANDO DOCKER: ${env.CONTAINER_NAME} en el puerto ${env.PORT}"
|
echo "DESPLEGANDO: ${env.CONTAINER_NAME} en el puerto ${env.PORT}"
|
||||||
|
|
||||||
// Forzamos a Docker a leer las variables y usamos un nombre de proyecto fijo (-p)
|
// 1. Levantamos el contenedor con su nombre de proyecto único (-p)
|
||||||
// Busca esta línea en tu Jenkinsfile y añade el final:
|
sh """
|
||||||
sh "CONTAINER_NAME=${CONTAINER_NAME} PORT=${PORT} DEBUG_MODE=${DEBUG_MODE} docker compose -p django_bac -f deployments/docker-compose.yml up -d --build web"
|
CONTAINER_NAME=${env.CONTAINER_NAME} \
|
||||||
|
PORT=${env.PORT} \
|
||||||
|
DEBUG_MODE=${env.DEBUG_MODE} \
|
||||||
|
docker compose -p ${env.PROJECT_NAME} -f deployments/docker-compose.yml up -d --build web
|
||||||
|
"""
|
||||||
|
|
||||||
|
// 2. Ejecutamos migraciones automáticamente al terminar
|
||||||
|
echo "Ejecutando migraciones en ${env.CONTAINER_NAME}..."
|
||||||
|
sh "docker exec ${env.CONTAINER_NAME} python manage.py migrate --noinput"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Automatización activada
|
|
||||||
@@ -5,16 +5,21 @@ services:
|
|||||||
dockerfile: deployments/Dockerfile
|
dockerfile: deployments/Dockerfile
|
||||||
container_name: ${CONTAINER_NAME}
|
container_name: ${CONTAINER_NAME}
|
||||||
restart: always
|
restart: always
|
||||||
|
working_dir: /app # <--- Vital para que encuentre 'core'
|
||||||
environment:
|
environment:
|
||||||
- DEBUG=${DEBUG_MODE}
|
- DEBUG=${DEBUG_MODE}
|
||||||
# Usamos 'gitea-db-1' que es el nombre real y seguro
|
- PYTHONPATH=/app # <--- Asegura que Python vea las carpetas
|
||||||
- DATABASE_URL=postgres://gitea:gitea_password@gitea-db-1:5432/gitea
|
- DB_NAME=gitea
|
||||||
|
- DB_USER=gitea
|
||||||
|
- DB_PASSWORD=gitea
|
||||||
|
- DB_HOST=gitea-db-1
|
||||||
|
- DB_PORT=5432
|
||||||
networks:
|
networks:
|
||||||
- gitea_net # Nombre interno para este archivo
|
- gitea_net
|
||||||
ports:
|
ports:
|
||||||
- "${PORT}:8000"
|
- "${PORT}:8000"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
gitea_net:
|
gitea_net:
|
||||||
external: true
|
external: true
|
||||||
name: frontend # <--- Este es el nombre real que vimos en el JSON
|
name: frontend
|
||||||
Reference in New Issue
Block a user