forked from DGNum/gestioCOF
Archives beta
This commit is contained in:
parent
adf43889e1
commit
ea495e8f29
2 changed files with 30 additions and 0 deletions
|
@ -62,6 +62,22 @@ class COFActuIndexPage(Page, COFActuIndexMixin):
|
||||||
verbose_name = "Index des actualités"
|
verbose_name = "Index des actualités"
|
||||||
verbose_name_plural = "Indexs des actualités"
|
verbose_name_plural = "Indexs des actualités"
|
||||||
|
|
||||||
|
def get_context(self, request):
|
||||||
|
context = super(COFActuIndexPage, self).get_context(request)
|
||||||
|
actus = COFActuPage.objects.live().descendant_of(self).order_by('-date')
|
||||||
|
|
||||||
|
page = request.GET.get('page')
|
||||||
|
paginator = Paginator(actus, 5)
|
||||||
|
try:
|
||||||
|
actus = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
actus = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
actus = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
|
context['actus'] = actus
|
||||||
|
return context
|
||||||
|
|
||||||
class COFActuPage(Page):
|
class COFActuPage(Page):
|
||||||
body = RichTextField("Contenu")
|
body = RichTextField("Contenu")
|
||||||
date = models.DateField("Date du post")
|
date = models.DateField("Date du post")
|
||||||
|
|
|
@ -12,6 +12,13 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="actulist">
|
<section class="actulist">
|
||||||
|
{% if actus.has_previous %}
|
||||||
|
<a class="block prev-actus" href="?page={{ actus.previous_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">Actualités plus récentes</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if actus.has_next %}
|
||||||
|
<a class="block next-actus" href="?page={{ actus.next_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">Actualités plus anciennes</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for actu in page.actus %}
|
{% for actu in page.actus %}
|
||||||
<article class="actu">
|
<article class="actu">
|
||||||
<div class="actu-image" {% if actu.image %}{% image actu.image fill-400x200 as img %}style="background-image:url('{{ img.url }}');"{% endif %}></div>
|
<div class="actu-image" {% if actu.image %}{% image actu.image fill-400x200 as img %}style="background-image:url('{{ img.url }}');"{% endif %}></div>
|
||||||
|
@ -26,5 +33,12 @@
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if actus.has_previous %}
|
||||||
|
<a class="block prev-actus" href="?page={{ actus.previous_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">Actualités plus récentes</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if actus.has_next %}
|
||||||
|
<a class="block next-actus" href="?page={{ actus.next_page_number }}{% for key,value in request.GET.items %}{% ifnotequal key 'page' %}&{{ key }}={{ value }}{% endifnotequal %}{% endfor %}">Actualités plus anciennes</a>
|
||||||
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue