Browse Source

Ver variables de entorno.

politica
Celestino Rey 1 year ago
parent
commit
2f075a4e3d
6 changed files with 67 additions and 4 deletions
  1. +1
    -1
      JugarAlPadel/K8S/Makefile.local
  2. +1
    -1
      JugarAlPadel/K8S/env-prod-configmap-local.yaml
  3. +3
    -0
      JugarAlPadel/gestion_reservas/eventos/urls.py
  4. +18
    -1
      JugarAlPadel/gestion_reservas/eventos/views.py
  5. +2
    -1
      JugarAlPadel/gestion_reservas/gestion_reservas/settings.py
  6. +42
    -0
      JugarAlPadel/gestion_reservas/templates/ver_entorno.html

+ 1
- 1
JugarAlPadel/K8S/Makefile.local View File

@ -2,7 +2,7 @@ export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export REGISTRY=localhost:30500
#export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.92
export IMG_VERSION = 0.95
export IMG_NGINX_VERSION = 2.4
# limpia todo


+ 1
- 1
JugarAlPadel/K8S/env-prod-configmap-local.yaml View File

@ -1,6 +1,6 @@
apiVersion: v1
data:
DEBUG: "True"
DEBUG: "False"
ENTORNO: "Pruebas"
DJANGO_ALLOWED_HOSTS: "jugaralpadel.ddns.net vmcluster reymota.es k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "https://jugaralpadel.ddns.net http://vmcluster"


+ 3
- 0
JugarAlPadel/gestion_reservas/eventos/urls.py View File

@ -15,4 +15,7 @@ urlpatterns = [
path('reservar/<int:evento_id>/',
views.reservar_evento, name='reservar_evento'),
path('entorno/', views.ver_variables_entorno, name='ver_variables_entorno'),
]

+ 18
- 1
JugarAlPadel/gestion_reservas/eventos/views.py View File

@ -1,14 +1,31 @@
import os
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib import messages
from django.core.mail import EmailMultiAlternatives
from django.conf import settings
from django.template.loader import render_to_string
from django.http import HttpResponseForbidden
from .models import Evento, Reserva, ListaEspera, ReyMotaUser
from .forms import ListaEsperaForm, EventoForm
# import random
@user_passes_test(lambda u: u.is_staff)
def ver_variables_entorno(request):
# Obtiene todas las variables de entorno
entorno = {key: os.getenv(key) for key in os.environ.keys()}
# Obtiene todas las variables de settings que no son métodos
configuracion = {key: getattr(settings, key) for key in dir(settings) if key.isupper()}
# Combina ambas en un solo diccionario
contexto = {
'entorno': entorno,
'configuracion': configuracion
}
return render(request, 'ver_entorno.html', contexto)
@login_required


+ 2
- 1
JugarAlPadel/gestion_reservas/gestion_reservas/settings.py View File

@ -167,7 +167,8 @@ EMAIL_HOST_PASSWORD = 'oxdkclbtggewxhqc' # Es mejor usar una contraseña de apl
DEFAULT_FROM_EMAIL = 'jugaralpadelentreamigos@gmail.com'
# Dirección del administrador
ADMIN_EMAIL = 'king.bernard.b@gmail.com'
# ADMIN_EMAIL = 'king.bernard.b@gmail.com'
ADMIN_EMAIL = ''
# El tiempo de validez del enlace para resetear la contraseña (por defecto es de 3 días)
PASSWORD_RESET_TIMEOUT = 86400 # 1 día en segundos

+ 42
- 0
JugarAlPadel/gestion_reservas/templates/ver_entorno.html View File

@ -0,0 +1,42 @@
{% extends 'base.html' %}
{% block content %}
<h2>Variables de Entorno y Configuración</h2>
<p><strong>Nota:</strong> Asegúrate de que esta página solo esté accesible para administradores, ya que contiene información sensible.</p>
<h3>Variables de Entorno</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Variable</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
{% for key, value in entorno.items %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h3>Variables de Configuración (settings.py)</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Variable</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
{% for key, value in configuracion.items %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

Loading…
Cancel
Save