Browse Source

Página con noticias

politica
Celestino Rey 1 year ago
parent
commit
79c0a14d76
13 changed files with 72 additions and 28 deletions
  1. +1
    -1
      JugarAlPadel/K8S/Makefile.local
  2. +1
    -1
      JugarAlPadel/gestion_reservas/entornoPruebas.sh
  3. +8
    -1
      JugarAlPadel/gestion_reservas/eventos/admin.py
  4. +14
    -0
      JugarAlPadel/gestion_reservas/eventos/models.py
  5. +2
    -0
      JugarAlPadel/gestion_reservas/eventos/urls.py
  6. +4
    -5
      JugarAlPadel/gestion_reservas/eventos/views.py
  7. +1
    -0
      JugarAlPadel/gestion_reservas/gestion_reservas/settings.py
  8. +1
    -2
      JugarAlPadel/gestion_reservas/gestion_reservas/urls.py
  9. +12
    -1
      JugarAlPadel/gestion_reservas/gestion_reservas/views.py
  10. +1
    -1
      JugarAlPadel/gestion_reservas/templates/_branding.html
  11. +0
    -13
      JugarAlPadel/gestion_reservas/templates/base.html
  12. +14
    -0
      JugarAlPadel/gestion_reservas/templates/detalle_noticia.html
  13. +13
    -3
      JugarAlPadel/gestion_reservas/templates/index.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 = 1.0
export IMG_VERSION = 1.19
export IMG_NGINX_VERSION = 2.4
# limpia todo


+ 1
- 1
JugarAlPadel/gestion_reservas/entornoPruebas.sh View File

@ -1,6 +1,6 @@
export CSRF_TRUSTED_ORIGINS="http://localhost"
export DEBUG="True"
export SECRET_KEY="hola"
export DJANGO_ALLOWED_HOSTS="localhost"
export DJANGO_ALLOWED_HOSTS="vmcluster localhost"

+ 8
- 1
JugarAlPadel/gestion_reservas/eventos/admin.py View File

@ -1,5 +1,12 @@
from django.contrib import admin
from .models import Evento, Reserva, ListaEspera
from .models import Evento, Reserva, ListaEspera, Noticia
class NoticiaAdmin(admin.ModelAdmin):
list_display = ['titulo', 'fecha_publicacion', 'autor']
admin.site.register(Noticia, NoticiaAdmin)
class EventoAdmin(admin.ModelAdmin):


+ 14
- 0
JugarAlPadel/gestion_reservas/eventos/models.py View File

@ -36,3 +36,17 @@ class ListaEspera(models.Model):
def __str__(self):
return f'{self.usuario.nombre} en lista de espera para {self.evento.nombre}. Solicitada plaza el: {self.fecha_apuntado}'
class Noticia(models.Model):
titulo = models.CharField(max_length=200)
contenido = models.TextField()
fecha_publicacion = models.DateTimeField(auto_now_add=True)
autor = models.ForeignKey(ReyMotaUser, on_delete=models.SET_NULL, null=True)
publicado = models.BooleanField(default=False)
class Meta:
ordering = ['-fecha_publicacion'] # Ordena por fecha de publicación, de la más reciente a la más antigua
def __str__(self):
return self.titulo

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

@ -11,6 +11,8 @@ urlpatterns = [
path('eventos/crear/', views.crear_evento, name='crear_evento'), # URL para crear un evento
path('eventos/editar/', views.editar_evento, name='editar_evento'), # URL para crear un evento
path('noticias/<int:noticia_id>/', views.detalle_noticia, name='detalle_noticia'),
path('publicar/<int:evento_id>/', views.publicar_evento, name='publicar_evento'),
path('reservar/<int:evento_id>/',


+ 4
- 5
JugarAlPadel/gestion_reservas/eventos/views.py View File

@ -5,7 +5,7 @@ from django.core.mail import EmailMultiAlternatives
from django.conf import settings
from django.template.loader import render_to_string
from .models import Evento, Reserva, ListaEspera
from .models import Evento, Reserva, ListaEspera, Noticia
from .forms import ListaEsperaForm, EventoForm
@ -106,10 +106,9 @@ def lista_eventos(request):
return render(request, 'eventos/lista_eventos.html', {'eventos_con_reserva': eventos_con_reserva})
def principal(request):
eventos = Evento.objects.all()
return render(request, 'eventos/lista_eventos.html', {'eventos': eventos})
def detalle_noticia(request, noticia_id):
noticia = get_object_or_404(Noticia, id=noticia_id, publicado=True)
return render(request, 'detalle_noticia.html', {'noticia': noticia})
def ayuda(request):


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

@ -28,6 +28,7 @@ DEBUG = os.environ["DEBUG"] == 'True'
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
print("ALLOWD_HOSTS: ", ALLOWED_HOSTS)
# Application definition


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

@ -31,8 +31,7 @@ urlpatterns = [
path("accounts/", include("accounts.urls")), # new
path("accounts/", include("django.contrib.auth.urls")),
path("", TemplateView.as_view(template_name="index.html"),
name="principal"), # new
path('', views.principal, name='principal'),
path('entorno/', views.ver_variables_entorno, name='ver_variables_entorno'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


+ 12
- 1
JugarAlPadel/gestion_reservas/gestion_reservas/views.py View File

@ -1,9 +1,10 @@
import os
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseForbidden
from eventos.models import Noticia
@user_passes_test(lambda u: u.is_staff)
def ver_variables_entorno(request):
@ -29,3 +30,13 @@ def ver_variables_entorno(request):
}
return render(request, 'ver_entorno.html', contexto)
def principal(request):
# Filtra solo las noticias publicadas
noticias = Noticia.objects.filter(publicado=True)
for noticia in noticias:
print("Principal en gestion_reservas: ", noticia.titulo)
return render(request, 'index.html', {'noticias': noticias})

+ 1
- 1
JugarAlPadel/gestion_reservas/templates/_branding.html View File

@ -3,7 +3,7 @@
{% load filtros_de_entorno %}
<div class="app-branding">
<a class="app-logo" href="{% url 'eventos:lista_eventos' %}"><img class="logo-icon me-2" src="{% static 'images/palapadel.svg' %}" alt="logo"><span class="logo-text">JUGAR AL PADEL</span><span style="color: blue; font-size: 14px;">
<a class="app-logo" href="{% url 'principal' %}"><img class="logo-icon me-2" src="{% static 'images/palapadel.svg' %}" alt="logo"><span class="logo-text">JUGAR AL PADEL</span><span style="color: blue; font-size: 14px;">
{% if 'ENVIRONMENT'|muestra_version == 'Pruebas' %}
p
{% else %}


+ 0
- 13
JugarAlPadel/gestion_reservas/templates/base.html View File

@ -89,19 +89,6 @@
<nav id="app-nav-main" class="app-nav app-nav-main flex-grow-1">
<ul class="app-menu list-unstyled accordion" id="menu-accordion">
<li class="nav-item">
<!--//Bootstrap Icons: https://icons.getbootstrap.com/ -->
<a class="nav-link active" href="{% url 'eventos:lista_eventos' %}">
<span class="nav-icon">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-house-door" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M7.646 1.146a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 .146.354v7a.5.5 0 0 1-.5.5H9.5a.5.5 0 0 1-.5-.5v-4H7v4a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-7a.5.5 0 0 1 .146-.354l6-6zM2.5 7.707V14H6v-4a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4h3.5V7.707L8 2.207l-5.5 5.5z"/>
<path fill-rule="evenodd" d="M13 2.5V6l-2-2V2.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5z"/>
</svg>
</span>
<span class="nav-link-text">Principal</span>
</a><!--//nav-link-->
</li><!--//nav-item-->
{% if user.is_authenticated %}
<li class="nav-item"></li>


+ 14
- 0
JugarAlPadel/gestion_reservas/templates/detalle_noticia.html View File

@ -0,0 +1,14 @@
{% extends 'base.html' %}
{% block content %}
<div class="container-xl">
<div class="app-card-body p-3 p-lg-4">
<h2>{{ noticia.titulo }}</h2>
<div class="row gx-5 gy-3">
<p>{{ noticia.contenido }}</p>
<p><small>Publicado el {{ noticia.fecha_publicacion|date:"d M Y" }} por {{ noticia.autor }}</small></p>
</div>
<a class="btn btn-primary" href="{% url 'principal' %}">Volver a noticias</a>
</div>
</div>
{% endblock %}

+ 13
- 3
JugarAlPadel/gestion_reservas/templates/index.html View File

@ -15,9 +15,19 @@
<div class="app-card-body p-3 p-lg-4">
<h3 class="mb-3">¡Bienvenido a Jugar al Pádel entre amigos!</h3>
<div class="row gx-5 gy-3">
<div class="col-12 col-lg-9">
<div>Aquí podrás encontrar los pozos abiertos y apuntarte a los mismos</div>
</div><!--//col-->
<h2>Noticias Recientes</h2>
<div class="news-container">
{% for noticia in noticias %}
<div class="news-item">
<h3>{{ noticia.titulo }}</h3>
<p>{{ noticia.contenido|truncatewords:20 }}</p> <!-- Muestra solo 20 palabras del contenido -->
<p><small>Publicado el {{ noticia.fecha_publicacion|date:"d M Y" }} por {{ noticia.autor }}</small></p>
<a href="{% url 'eventos:detalle_noticia' noticia.id %}">Leer más</a>
</div>
{% empty %}
<p>No hay noticias disponibles.</p>
{% endfor %}
</div>
</div><!--//row-->
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div><!--//app-card-body-->


Loading…
Cancel
Save