Browse Source

Ampliación de api y nuevo dominio reymota.lab

politica
Celestino Rey 9 months ago
parent
commit
5c3016a8a1
8 changed files with 9 additions and 59 deletions
  1. +1
    -1
      JugarAlPadel/Dockerfile
  2. +1
    -1
      JugarAlPadel/K8S/Makefile
  3. +2
    -2
      JugarAlPadel/K8S/env-prod-configmap.yaml
  4. +1
    -1
      JugarAlPadel/K8S/jugaralpadel-ingress.yaml
  5. +1
    -3
      JugarAlPadel/gestion_reservas/gestion_reservas/urls.py
  6. +0
    -48
      JugarAlPadel/gestion_reservas/gestion_reservas/views.py
  7. +2
    -2
      ReyMotaAppsDj/K8S/env-prod-configmap.yaml
  8. +1
    -1
      ReyMotaAppsDj/K8S/reymota-ingress.yaml

+ 1
- 1
JugarAlPadel/Dockerfile View File

@ -46,7 +46,7 @@ RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME WORKDIR $APP_HOME
# install system dependencies # install system dependencies
RUN apt-get update && apt-get install -y sqlite3 netcat vim
RUN apt-get update && apt-get install -y sqlite3 netcat vim curl
COPY --from=builder /app/wheels /wheels COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt . COPY --from=builder /app/requirements.txt .


+ 1
- 1
JugarAlPadel/K8S/Makefile View File

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


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

@ -2,8 +2,8 @@ apiVersion: v1
data: data:
DEBUG: "False" DEBUG: "False"
ENTORNO: "Producción" ENTORNO: "Producción"
DJANGO_ALLOWED_HOSTS: "jugaralpadel.rancher.my.org jugaralpadel.es jugaralpadel.ddns.net vmcluster k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "http://jugaralpadel.rancher.my.org https://jugaralpadel.ddns.net https://jugaralpadel.es http://vmcluster"
DJANGO_ALLOWED_HOSTS: "jugaralpadel.rancher.reymota.lab jugaralpadel.es jugaralpadel.ddns.net vmcluster k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "http://jugaralpadel.rancher.reymota.lab https://jugaralpadel.ddns.net https://jugaralpadel.es http://vmcluster"
SECRET_KEY: change_me SECRET_KEY: change_me
SQL_DATABASE: jugaralpadel SQL_DATABASE: jugaralpadel
SQL_ENGINE: django.db.backends.postgresql SQL_ENGINE: django.db.backends.postgresql


+ 1
- 1
JugarAlPadel/K8S/jugaralpadel-ingress.yaml View File

@ -26,6 +26,6 @@ spec:
number: 1337 number: 1337
ingressClassName: nginx ingressClassName: nginx
rules: rules:
- host: jugaralpadel.rancher.my.org
- host: jugaralpadel.rancher.reymota.lab
status: status:
loadBalancer: {} loadBalancer: {}

+ 1
- 3
JugarAlPadel/gestion_reservas/gestion_reservas/urls.py View File

@ -27,6 +27,7 @@ urlpatterns = [
path('obreros/', admin.site.urls), path('obreros/', admin.site.urls),
path("eventos/", include('eventos.urls')), path("eventos/", include('eventos.urls')),
path("usuarios/", include('reymotausers.urls')),
path("accounts/", include("accounts.urls")), # new path("accounts/", include("accounts.urls")), # new
path("accounts/", include("django.contrib.auth.urls")), path("accounts/", include("django.contrib.auth.urls")),
@ -35,8 +36,5 @@ urlpatterns = [
path('entorno/', views.ver_variables_entorno, name='ver_variables_entorno'), path('entorno/', views.ver_variables_entorno, name='ver_variables_entorno'),
path('ayuda/', views.ayuda, name='ayuda'), path('ayuda/', views.ayuda, name='ayuda'),
path('api/proximo-evento/', views.proximo_evento, name='proximo_evento'),
path('api/todos-los-eventos/', views.todos_los_eventos, name='todos_los_eventos'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

+ 0
- 48
JugarAlPadel/gestion_reservas/gestion_reservas/views.py View File

@ -1,5 +1,4 @@
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.decorators import api_view
from django.utils import timezone from django.utils import timezone
from rest_framework import status from rest_framework import status
@ -52,53 +51,6 @@ def principal(request):
return render(request, 'index.html', {'noticias': noticias}) return render(request, 'index.html', {'noticias': noticias})
@api_view(['GET'])
def proximo_evento(request):
# Obtiene y valida el parámetro `publicado`
publicado_param = request.GET.get('publicado', 'true').lower()
if publicado_param not in ['true', 'false', 'all']:
return Response(
{'detail': 'El parámetro "publicado" debe ser "true", "false" o "all".'},
status=status.HTTP_400_BAD_REQUEST
)
# Configura el filtro según el parámetro `publicado`
if publicado_param == 'all':
eventos = Evento.objects.filter(fecha__gte=timezone.now()).order_by('fecha')
else:
publicado = publicado_param == 'true'
eventos = Evento.objects.filter(publicado=publicado, fecha__gte=timezone.now()).order_by('fecha')
evento = eventos.first()
if evento:
serializer = EventoSerializer(evento)
return Response(serializer.data)
else:
return Response({'detail': 'No hay eventos próximos.'}, status=404)
@api_view(['GET'])
def todos_los_eventos(request):
# Obtiene y valida el parámetro `publicado`
publicado_param = request.GET.get('publicado', 'true').lower()
if publicado_param not in ['true', 'false', 'all']:
return Response(
{'detail': 'El parámetro "publicado" debe ser "true", "false" o "all".'},
status=status.HTTP_400_BAD_REQUEST
)
# Configura el filtro según el parámetro `publicado`
if publicado_param == 'all':
eventos = Evento.objects.all().order_by('fecha')
else:
publicado = publicado_param == 'true'
eventos = Evento.objects.filter(publicado=publicado).order_by('fecha')
serializer = EventoSerializer(eventos, many=True) # `many=True` para serializar una lista de eventos
return Response(serializer.data)
def ayuda(request): def ayuda(request):
elementos_ayuda = Ayuda.objects.all().order_by('apartado') elementos_ayuda = Ayuda.objects.all().order_by('apartado')
apartados = Ayuda.APARTADOS apartados = Ayuda.APARTADOS


+ 2
- 2
ReyMotaAppsDj/K8S/env-prod-configmap.yaml View File

@ -2,8 +2,8 @@ apiVersion: v1
data: data:
DEBUG: "False" DEBUG: "False"
ENTORNO: "Producción" ENTORNO: "Producción"
DJANGO_ALLOWED_HOSTS: "reymota.rancher.my.org reymota.es vmcluster k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "https://reymota.es http://vmcluster http://reymota.rancher.my.org/ http://localhost http://127.0.0.1"
DJANGO_ALLOWED_HOSTS: "reymota.rancher.reymota.lab reymota.es vmcluster k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "https://reymota.es http://vmcluster http://reymota.rancher.reymota.lab/ http://localhost http://127.0.0.1"
SECRET_KEY: change_me SECRET_KEY: change_me
SQL_DATABASE: reymota SQL_DATABASE: reymota
SQL_ENGINE: django.db.backends.postgresql SQL_ENGINE: django.db.backends.postgresql


+ 1
- 1
ReyMotaAppsDj/K8S/reymota-ingress.yaml View File

@ -26,6 +26,6 @@ spec:
number: 1337 number: 1337
ingressClassName: nginx ingressClassName: nginx
rules: rules:
- host: reymota.rancher.my.org
- host: reymota.rancher.reymota.lab
status: status:
loadBalancer: {} loadBalancer: {}

Loading…
Cancel
Save