pc responsive issues
Browse files- app/main.py +38 -10
- app/static/css/style.css +33 -0
- app/templates/prestamos.html +2 -4
app/main.py
CHANGED
|
@@ -52,22 +52,50 @@ def get_db_connection():
|
|
| 52 |
database=os.getenv("MYSQL_DB", "makerpage")
|
| 53 |
)
|
| 54 |
return conn
|
| 55 |
-
except
|
| 56 |
-
print(f"
|
| 57 |
return None
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
@login_manager.user_loader
|
| 60 |
def load_user(user_id):
|
| 61 |
-
"""Recupera un usuario de la base de datos por su ID."""
|
| 62 |
conn = get_db_connection()
|
| 63 |
if not conn: return None
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
# --- GESTOR DE PRÉSTAMOS (Persistencia JSON) ---
|
| 73 |
class LoanManager:
|
|
|
|
| 52 |
database=os.getenv("MYSQL_DB", "makerpage")
|
| 53 |
)
|
| 54 |
return conn
|
| 55 |
+
except mysql.connector.Error as err:
|
| 56 |
+
print(f"ERROR CRÍTICO MYSQL: {err}")
|
| 57 |
return None
|
| 58 |
|
| 59 |
+
def init_db():
|
| 60 |
+
"""Inicializa la base de datos y crea las tablas necesarias si no existen."""
|
| 61 |
+
conn = get_db_connection()
|
| 62 |
+
if conn:
|
| 63 |
+
try:
|
| 64 |
+
cursor = conn.cursor()
|
| 65 |
+
# Crear tabla de usuarios con soporte para hashing de contraseñas
|
| 66 |
+
cursor.execute("""
|
| 67 |
+
CREATE TABLE IF NOT EXISTS users (
|
| 68 |
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
| 69 |
+
username VARCHAR(50) UNIQUE NOT NULL,
|
| 70 |
+
password VARCHAR(255) NOT NULL
|
| 71 |
+
)
|
| 72 |
+
""")
|
| 73 |
+
conn.commit()
|
| 74 |
+
print("INFO: Base de datos verificada/inicializada correctamente.")
|
| 75 |
+
except mysql.connector.Error as err:
|
| 76 |
+
print(f"ERROR al inicializar tablas: {err}")
|
| 77 |
+
finally:
|
| 78 |
+
conn.close()
|
| 79 |
+
else:
|
| 80 |
+
print("ADVERTENCIA: No se pudo conectar a MySQL para inicializar. Verifica las credenciales.")
|
| 81 |
+
|
| 82 |
+
# Llamar a la inicialización al arrancar
|
| 83 |
+
init_db()
|
| 84 |
+
|
| 85 |
@login_manager.user_loader
|
| 86 |
def load_user(user_id):
|
| 87 |
+
"""Recupera un usuario de la base de datos por su ID para Flask-Login."""
|
| 88 |
conn = get_db_connection()
|
| 89 |
if not conn: return None
|
| 90 |
+
try:
|
| 91 |
+
cursor = conn.cursor(dictionary=True)
|
| 92 |
+
cursor.execute("SELECT id, username FROM users WHERE id = %s", (user_id,))
|
| 93 |
+
user_data = cursor.fetchone()
|
| 94 |
+
return User(str(user_data['id']), user_data['username']) if user_data else None
|
| 95 |
+
except:
|
| 96 |
+
return None
|
| 97 |
+
finally:
|
| 98 |
+
conn.close()
|
| 99 |
|
| 100 |
# --- GESTOR DE PRÉSTAMOS (Persistencia JSON) ---
|
| 101 |
class LoanManager:
|
app/static/css/style.css
CHANGED
|
@@ -252,6 +252,7 @@ input:focus {
|
|
| 252 |
|
| 253 |
.repo-item:hover {
|
| 254 |
background: rgba(255, 255, 255, 0.05);
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
/* ESTILOS PARA EL CONTENIDO RENDERIZADO (README) */
|
|
@@ -270,8 +271,40 @@ input:focus {
|
|
| 270 |
}
|
| 271 |
|
| 272 |
/* Adaptabilidad para móviles */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
@media (max-width: 768px) {
|
| 274 |
.item-row {
|
| 275 |
grid-template-columns: 1fr;
|
| 276 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
}
|
|
|
|
| 252 |
|
| 253 |
.repo-item:hover {
|
| 254 |
background: rgba(255, 255, 255, 0.05);
|
| 255 |
+
cursor: pointer;
|
| 256 |
}
|
| 257 |
|
| 258 |
/* ESTILOS PARA EL CONTENIDO RENDERIZADO (README) */
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
/* Adaptabilidad para móviles */
|
| 274 |
+
/* MODALES */
|
| 275 |
+
.receipt-modal {
|
| 276 |
+
position: fixed;
|
| 277 |
+
top: 50%;
|
| 278 |
+
left: 50%;
|
| 279 |
+
transform: translate(-50%, -50%);
|
| 280 |
+
width: 95%;
|
| 281 |
+
max-width: 450px;
|
| 282 |
+
max-height: 90vh;
|
| 283 |
+
overflow-y: auto;
|
| 284 |
+
z-index: 1001;
|
| 285 |
+
padding: 2.5rem;
|
| 286 |
+
border-radius: 24px;
|
| 287 |
+
display: none;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
#modal-overlay {
|
| 291 |
+
display: none;
|
| 292 |
+
position: fixed;
|
| 293 |
+
top: 0;
|
| 294 |
+
left: 0;
|
| 295 |
+
width: 100%;
|
| 296 |
+
height: 100%;
|
| 297 |
+
background: rgba(0, 0, 0, 0.8);
|
| 298 |
+
backdrop-filter: blur(4px);
|
| 299 |
+
z-index: 1000;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
@media (max-width: 768px) {
|
| 303 |
.item-row {
|
| 304 |
grid-template-columns: 1fr;
|
| 305 |
}
|
| 306 |
+
|
| 307 |
+
.receipt-modal {
|
| 308 |
+
padding: 1.5rem;
|
| 309 |
+
}
|
| 310 |
}
|
app/templates/prestamos.html
CHANGED
|
@@ -104,10 +104,8 @@
|
|
| 104 |
</div>
|
| 105 |
|
| 106 |
<!-- Modal para el Recibo/Handover -->
|
| 107 |
-
<div id="modal-overlay"
|
| 108 |
-
|
| 109 |
-
onclick="closeModal()"></div>
|
| 110 |
-
<div id="modal-content" class="receipt-modal glass" style="display:none;"></div>
|
| 111 |
|
| 112 |
<script>
|
| 113 |
/* LÓGICA DINÁMICA DEL FORMULARIO */
|
|
|
|
| 104 |
</div>
|
| 105 |
|
| 106 |
<!-- Modal para el Recibo/Handover -->
|
| 107 |
+
<div id="modal-overlay" onclick="closeModal()"></div>
|
| 108 |
+
<div id="modal-content" class="receipt-modal glass"></div>
|
|
|
|
|
|
|
| 109 |
|
| 110 |
<script>
|
| 111 |
/* LÓGICA DINÁMICA DEL FORMULARIO */
|