Last active
October 14, 2019 00:17
-
-
Save ivan-vilches/9d3e1b3874eb43e6932699b7ea4b13c6 to your computer and use it in GitHub Desktop.
order by fecha_inicio_evento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import datetime | |
from wagtail.core.models import Page | |
from wagtail.core.fields import RichTextField | |
from wagtail.admin.edit_handlers import FieldPanel | |
from wagtail.search import index | |
from wagtail.images.edit_handlers import ImageChooserPanel | |
class TallerIndexPage(Page): | |
template = "talleres/talleres_page.html" | |
is_creatable = False | |
intro = RichTextField(blank=True) | |
content_panels = Page.content_panels + [ | |
FieldPanel('intro', classname="full") | |
] | |
def get_context(self, request): | |
# Update context to include only published posts, ordered by reverse-chron | |
context = super().get_context(request) | |
talleres = self.get_children().live().order_by('-fecha_inicio_evento') | |
context['talleres'] = talleres | |
return context | |
class Taller(Page): | |
template = "talleres/taller_single_page.html" | |
fecha_inicio_evento = models.DateField("Fecha Inicio Evento, Taller, etc...", null=True, blank=True) | |
lugar_evento = models.CharField(max_length=150, null=True, blank=True, verbose_name="Lugar donde se realizará el Evento, Taller, etc...") | |
descripcion = RichTextField(blank=False, null = False, verbose_name="Descripción del Evento, Taller, etc..") | |
contenido = RichTextField(blank=True, null = True, verbose_name="Todo el contenido extra del Evento", default=""" | |
<p><b>OBJETIVOS:</b></p> | |
<p> | |
Elaborar moldes de yeso de cerámicas originarias con la finalidad de | |
producir una cantidad de piezas en poco tiempo y acercarse a una producción | |
artesanal a futuro. | |
</p> | |
<p> | |
Elaborar moldes de yeso de cerámicas originarias con la finalidad de | |
producir una cantidad de piezas en poco tiempo y acercarse a una producción | |
artesanal a futuro. | |
</p> | |
<p><b>CONTENIDOS y METODOLOGÍA:</b></p> | |
<ol> | |
<li> | |
Iniciación breve presentación de la instructora e introducción de de la | |
materia a tratar. | |
</li> | |
<li>Entrega de materiales.</li> | |
<li> | |
Información sobre las matrices, forma ,función y formación de equipos | |
</li> | |
<li>Aplicación de los materiales., yeso, micas, aislantes, etc.</li> | |
<li>Fabricación de moldes de i pieza a partir de una cama de arcilla.</li> | |
<li>Fabricación de moldes de dos piezas.</li> | |
</ol> | |
<p><b>DURACION:</b> 2 horas.</p> | |
<p><b>CUPOS:</b> Máximo 10 alumnos</p> | |
<p><b>JORNADA:</b> viernes en la mañana de 10:00 a 12:00 horas.</p> | |
<p></p> | |
""") | |
imagen_evento = models.ForeignKey( | |
"wagtailimages.Image", | |
null=True, | |
blank=True, | |
on_delete=models.SET_NULL, | |
related_name="+", | |
) | |
search_fields = Page.search_fields + [ | |
index.SearchField( | |
'descripcion'), | |
] | |
content_panels = Page.content_panels + [ | |
FieldPanel('fecha_inicio_evento'), | |
FieldPanel('lugar_evento'), | |
FieldPanel('descripcion'), | |
FieldPanel('contenido'), | |
ImageChooserPanel('imagen_evento'), | |
] | |
def get_context(self, request): | |
# Update context to include only published posts, ordered by reverse-chron | |
context = super().get_context(request) | |
listapost = Taller.objects.live().exclude(fecha_inicio_evento__lt=datetime.date.today()).order_by('fecha_inicio_evento') | |
context['listapost'] = listapost | |
return context | |
parent_page_types = ['talleres.TallerIndexPage'] | |
class Meta: | |
verbose_name = 'Evento' | |
verbose_name_plural = 'Eventos' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block content %} | |
{% load static %} | |
{% load wagtailcore_tags wagtailimages_tags %} | |
<div class="container titulo-talleres"> | |
<h2>{{ page.title }}</h2> | |
</div> | |
<ul class="gridt"> | |
{% for post in talleres %} | |
<li class="grid-item exposiciones"> | |
<article class="post-blogpage"> | |
<div class="image-blogpage"> | |
{% image post.specific.imagen_evento original class="img-fluid" %} | |
</div> | |
<h2> | |
{{ post.title }} | |
</h2> | |
{% comment %} <div class="date">{{ post.specific.first_published_at|date:"j F | Y" }}</div> {% endcomment %} | |
<div class="date">Fecha: {{ post.specific.fecha_inicio_evento|date:"j F | Y" }}</div> | |
<div class="rich-text"> | |
{{ post.specific.descripcion|richtext }} | |
</div> | |
<div class="bottom-post"> | |
<div class="datos-post"> | |
<h3>Lugar:{{ post.specific.lugar_evento }}</h3> | |
</div> | |
<div class="leer-mas-blogpage"> | |
<a href="{% pageurl post %}">leer más</a> | |
</div> | |
</div> | |
</article> | |
</li> | |
{% endfor %} | |
</ul> | |
{% endblock %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment