work on it
This commit is contained in:
@ -28,7 +28,12 @@ $body-background-color: $light;
|
||||
|
||||
/** page **/
|
||||
.page {
|
||||
.header {
|
||||
& > .cover {
|
||||
float: right;
|
||||
max-width: 45%;
|
||||
}
|
||||
|
||||
& > .header {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,10 @@ class Page(StatusModel):
|
||||
|
||||
objects = PageQueryset.as_manager()
|
||||
|
||||
@property
|
||||
def is_published(self):
|
||||
return self.status == self.STATUS.published
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return reverse(self.detail_url_name, kwargs={'slug': self.slug})
|
||||
|
@ -7165,7 +7165,11 @@ label.panel-block {
|
||||
}
|
||||
*/
|
||||
/** page **/
|
||||
.page .header {
|
||||
.page > .cover {
|
||||
float: right;
|
||||
max-width: 45%; }
|
||||
|
||||
.page > .header {
|
||||
margin-bottom: 1.5em; }
|
||||
|
||||
.page .headline {
|
||||
|
@ -41,25 +41,35 @@ Context:
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="columns is-desktop">
|
||||
<main class="column page">
|
||||
<header class="header">
|
||||
{% block header %}
|
||||
<h1 class="title is-1">{% block title %}{% endblock %}</h1>
|
||||
|
||||
{% if parent %}
|
||||
<h4 class="subtitle is-size-3">
|
||||
<a href="{{ parent.path }}">
|
||||
❬ {{ parent.title }}</a></li>
|
||||
</h4>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
|
||||
{% block main %}{% endblock main %}
|
||||
</main>
|
||||
<aside class="column is-one-third">
|
||||
{% block side_nav %}
|
||||
{% if nav_side %}
|
||||
<aside class="column is-one-third-desktop">
|
||||
{% block cover %}
|
||||
{% if cover is not None %}
|
||||
<img class="cover" src="{{ cover.url }}" class="cover"/>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block side_nav %}
|
||||
{% endblock %}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -18,27 +18,27 @@ Context variables:
|
||||
class="small-cover">
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<div>
|
||||
<h5 class="subtitle is-size-5 is-inline-block">
|
||||
{% if d_page %}
|
||||
<a href="{{ d_page.path }}">{{ d_page.title }}</a>
|
||||
{% endif %}
|
||||
<h5 class="subtitle is-size-5">
|
||||
{% if d_page %}
|
||||
<a href="{{ d_page.path }}">{{ d_page.title }}</a>
|
||||
{% endif %}
|
||||
</h5>
|
||||
|
||||
{% if not page or p_page != page %}
|
||||
{% if d_page %} — {% endif %}
|
||||
{% if p_page %}
|
||||
<a href="{{ p_page.path }}" class="has-text-grey-dark">
|
||||
{{ p_page.title }}</a>
|
||||
{% else %}
|
||||
{{ program.name }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</h5>
|
||||
<div class="">
|
||||
{% if not page or p_page != page %}
|
||||
{% if p_page %}
|
||||
<a href="{{ p_page.path }}" class="has-text-grey-dark">
|
||||
{{ p_page.title }}</a>
|
||||
{% else %}
|
||||
{{ program.name }}
|
||||
{% endif %}
|
||||
{% if not hide_schedule %} — {% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not hide_schedule %}
|
||||
<time datetime="{{ object.start|date:"c" }}" title="{{ object.start }}"
|
||||
class="has-text-weight-light is-size-6">
|
||||
— {{ object.start|date:"d M, H:i" }}
|
||||
{{ object.start|date:"d M, H:i" }}
|
||||
</time>
|
||||
{% endif %}
|
||||
|
||||
|
14
aircox_web/templates/aircox_web/diffusion_page.html
Normal file
14
aircox_web/templates/aircox_web/diffusion_page.html
Normal file
@ -0,0 +1,14 @@
|
||||
{% extends "aircox_web/program_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block main %}
|
||||
{{ block.super }}
|
||||
|
||||
{% if podcasts %}
|
||||
{% for object in podcasts %}
|
||||
{% include "aircox_web/podcast_item.html" %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endwith %}
|
||||
|
@ -12,18 +12,8 @@
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block header %}
|
||||
{{ block.super }}
|
||||
{% if program %}
|
||||
<h4 class="subtitle is-size-3">
|
||||
<a href="{% url "program-page" slug=program.slug %}">❬ {{ program.name }}</a></li>
|
||||
</h4>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<section class="section">
|
||||
<section>
|
||||
{% for object in object_list %}
|
||||
{% include "aircox_web/diffusion_item.html" %}
|
||||
{% endfor %}
|
||||
|
@ -27,10 +27,4 @@ Context:
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block side_nav %}
|
||||
{% if cover is not None %}
|
||||
<img class="cover" src="{{ cover.url }}" class="cover"/>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
8
aircox_web/templates/aircox_web/podcast_item.html
Normal file
8
aircox_web/templates/aircox_web/podcast_item.html
Normal file
@ -0,0 +1,8 @@
|
||||
<div class="podcast">
|
||||
{% if object.embed %}
|
||||
{{ object.embed }}
|
||||
{% else %}
|
||||
<audio src="{{ object.url }}" controls>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
29
aircox_web/templates/aircox_web/program_base.html
Normal file
29
aircox_web/templates/aircox_web/program_base.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "aircox_web/page.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block side_nav %}
|
||||
{{ block.super }}
|
||||
|
||||
{% if diffusions %}
|
||||
<section>
|
||||
<h4 class="subtitle is-size-4">{% trans "Last shows" %}</h4>
|
||||
|
||||
{% for object in diffusions %}
|
||||
{% include "aircox_web/diffusion_item.html" %}
|
||||
{% endfor %}
|
||||
|
||||
<br>
|
||||
<nav class="pagination is-centered">
|
||||
<ul class="pagination-list">
|
||||
<li>
|
||||
<a href="{% url "diffusion-list" program_slug=page.slug %}"
|
||||
class="pagination-link"
|
||||
aria-label="{% trans "Show all diffusions" %}">
|
||||
{% trans "All diffusions" %}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
@ -1,38 +1,8 @@
|
||||
{% extends "aircox_web/page.html" %}
|
||||
{% extends "aircox_web/program_base.html" %}
|
||||
{% load i18n %}
|
||||
{% with page.program as program %}
|
||||
|
||||
{% block header %}
|
||||
{{ block.super }}
|
||||
{% include "aircox_web/program_header.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block side_nav %}
|
||||
{{ block.super }}
|
||||
|
||||
{% if diffusions %}
|
||||
<section>
|
||||
<h4 class="subtitle is-size-4">{% trans "Last shows" %}</h4>
|
||||
|
||||
{% for object in diffusions %}
|
||||
{% include "aircox_web/diffusion_item.html" %}
|
||||
{% endfor %}
|
||||
|
||||
<br>
|
||||
<nav class="pagination is-centered">
|
||||
<ul class="pagination-list">
|
||||
<li>
|
||||
<a href="{% url "diffusion-list" program_slug=page.slug %}"
|
||||
class="pagination-link"
|
||||
aria-label="{% trans "Show all diffusions" %}">
|
||||
{% trans "All diffusions" %}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% endwith %}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
from collections import OrderedDict, deque
|
||||
import datetime
|
||||
|
||||
from django.db.models import Q
|
||||
from django.core.paginator import Paginator
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import TemplateView, DetailView, ListView
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.views.generic.base import TemplateResponseMixin, ContextMixin
|
||||
|
||||
from content_editor.contents import contents_for_item
|
||||
@ -36,9 +35,14 @@ def route_page(request, path=None, *args, model=None, site=None, **kwargs):
|
||||
|
||||
|
||||
class BaseView(TemplateResponseMixin, ContextMixin):
|
||||
title = None
|
||||
cover = None
|
||||
site = None
|
||||
""" Current website """
|
||||
nav_side = False
|
||||
""" Show side navigation """
|
||||
title = None
|
||||
""" Page title """
|
||||
cover = None
|
||||
""" Page cover """
|
||||
|
||||
def dispatch(self, request, *args, site=None, **kwargs):
|
||||
self.site = site if site is not None else \
|
||||
@ -53,6 +57,7 @@ class BaseView(TemplateResponseMixin, ContextMixin):
|
||||
|
||||
kwargs.setdefault('site', self.site)
|
||||
kwargs.setdefault('cover', self.cover)
|
||||
kwargs.setdefault('nav_side', self.nav_side)
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
@ -79,31 +84,52 @@ class PageView(BaseView, DetailView):
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
class ProgramPageView(PageView):
|
||||
""" Base view class for pages. """
|
||||
class BaseProgramView(PageView):
|
||||
""" Base view class for programs and their sub-pages. """
|
||||
nav_side = True
|
||||
list_count=5
|
||||
|
||||
def get_diffusions_queryset(self, program, queryset=None):
|
||||
qs = get_diffusions_with_page() if queryset is None else queryset
|
||||
return qs.before().filter(program=program).order_by('-start')
|
||||
|
||||
def get_context_data(self, program, **kwargs):
|
||||
if not hasattr(program, 'page') or not program.page.is_published:
|
||||
raise Http404
|
||||
|
||||
if 'diffusions' not in kwargs:
|
||||
diffs = self.get_diffusions_queryset(program)[:self.list_count]
|
||||
kwargs['diffusions'] = diffs
|
||||
return super().get_context_data(program=program, **kwargs)
|
||||
|
||||
|
||||
class ProgramPageView(BaseProgramView):
|
||||
template_name = 'aircox_web/program_page.html'
|
||||
model = ProgramPage
|
||||
|
||||
list_count=10
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().select_related('program')
|
||||
|
||||
def get_context_data(self, program=None, diffusions=None, **kwargs):
|
||||
program = program or self.object.program
|
||||
diffusions = diffusions or \
|
||||
get_diffusions_with_page().filter(program=program)
|
||||
return super().get_context_data(
|
||||
program=program,
|
||||
diffusions=diffusions.order_by('-start')[:self.list_count],
|
||||
**kwargs
|
||||
)
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs.setdefault('program', self.object.program)
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
class DiffusionPageView(PageView):
|
||||
# template_name = 'aircox_web/diffusion.html'
|
||||
class DiffusionPageView(BaseProgramView):
|
||||
template_name = 'aircox_web/program_base.html'
|
||||
model = DiffusionPage
|
||||
|
||||
def get_podcasts(self, diffusion):
|
||||
return aircox.Sound.objects.diffusion(diffusion).podcasts()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
diffusion = self.object.diffusion
|
||||
kwargs.setdefault('program', diffusion.program)
|
||||
kwargs.setdefault('parent', getattr(kwargs['program'], 'page', None))
|
||||
if not 'podcasts' in kwargs:
|
||||
kwargs['podcasts'] = self.get_podcasts(diffusion)
|
||||
print('get prodcasts...', kwargs['podcasts'], diffusion)
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
# TODO: pagination: in template, only a limited number of pages displayed
|
||||
@ -133,7 +159,7 @@ class DiffusionsView(BaseView, ListView):
|
||||
program = kwargs.setdefault('program', self.program)
|
||||
if program is not None and hasattr(program, 'page'):
|
||||
kwargs.setdefault('cover', program.page.cover)
|
||||
kwargs.setdefault('page', program.page)
|
||||
kwargs.setdefault('parent', program.page)
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user