forked from rc/aircox
		
	update home page + sidebar items sizing
This commit is contained in:
		@ -10883,9 +10883,6 @@ main .cover.is-tiny {
 | 
			
		||||
aside > section {
 | 
			
		||||
  margin-bottom: 2em;
 | 
			
		||||
}
 | 
			
		||||
aside .cover {
 | 
			
		||||
  margin-bottom: 2em;
 | 
			
		||||
}
 | 
			
		||||
aside .cover.is-small {
 | 
			
		||||
  width: 10em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -132,10 +132,11 @@ Usefull context:
 | 
			
		||||
                        {# FIXME: block cover into sidebar one #}
 | 
			
		||||
                        {% block cover %}
 | 
			
		||||
                        {% if page and page.cover %}
 | 
			
		||||
                        <img class="cover" src="{{ page.cover.url }}" class="cover"/>
 | 
			
		||||
                        <img class="cover mb-4" src="{{ page.cover.url }}" class="cover"/>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                        {% endblock %}
 | 
			
		||||
 | 
			
		||||
                        {% with is_thin=True %}
 | 
			
		||||
                        {% block sidebar %}
 | 
			
		||||
                        {% if sidebar_object_list %}
 | 
			
		||||
                        {% with object_list=sidebar_object_list %}
 | 
			
		||||
@ -152,6 +153,7 @@ Usefull context:
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                        </section>
 | 
			
		||||
                        {% endblock %}
 | 
			
		||||
                        {% endwith %}
 | 
			
		||||
                    </aside>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
@ -23,22 +23,7 @@
 | 
			
		||||
{% block pages_list %}
 | 
			
		||||
{% with hide_schedule=True %}
 | 
			
		||||
<section role="list">
 | 
			
		||||
    <div id="timetable-{{ date|date:"Y-m-d" }}">
 | 
			
		||||
        {% for diffusion in object_list %}
 | 
			
		||||
        <div class="columns {% if diffusion.is_now %}has-background-primary{% endif %}">
 | 
			
		||||
            <div class="column is-one-fifth has-text-right">
 | 
			
		||||
                <time datetime="{{ diffusion.start|date:"c" }}">
 | 
			
		||||
                {{ diffusion.start|date:"H:i" }} - {{ diffusion.end|date:"H:i" }}
 | 
			
		||||
                </time>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="column">
 | 
			
		||||
                {% with diffusion.episode as object %}
 | 
			
		||||
                {% include "aircox/widgets/episode_item.html" %}
 | 
			
		||||
                {% endwith %}
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
    </div>
 | 
			
		||||
    {% include 'aircox/widgets/diffusion_list.html' %}
 | 
			
		||||
</section>
 | 
			
		||||
{% endwith %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
@ -14,10 +14,10 @@
 | 
			
		||||
 | 
			
		||||
{% block pages_list %}
 | 
			
		||||
{% if page and page.content %}<hr/>{% endif %}
 | 
			
		||||
{% if top_diffs %}
 | 
			
		||||
{% if next_diffs %}
 | 
			
		||||
<div class="columns">
 | 
			
		||||
    {% with render_card=True %}
 | 
			
		||||
    {% for object in top_diffs %}
 | 
			
		||||
    {% for object in next_diffs %}
 | 
			
		||||
    {% with is_primary=object.is_now %}
 | 
			
		||||
    <div class="column is-relative">
 | 
			
		||||
        <h4 class="card-super-title" title="{{ object.start }}">
 | 
			
		||||
@ -40,16 +40,16 @@
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
</div>
 | 
			
		||||
<hr>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
<h4 class="title is-4">{% translate "Last publications" %}</h4>
 | 
			
		||||
{% with has_headline=True %}
 | 
			
		||||
{{ block.super }}
 | 
			
		||||
{% endwith %}
 | 
			
		||||
{% if object_list %}
 | 
			
		||||
<h4 class="title is-4">{% translate "Today" %}</h4>
 | 
			
		||||
<section role="list">
 | 
			
		||||
    {% include 'aircox/widgets/diffusion_list.html' %}
 | 
			
		||||
</section>
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{% block pagination %}
 | 
			
		||||
<ul class="pagination-list">
 | 
			
		||||
    <li>
 | 
			
		||||
@ -65,25 +65,20 @@
 | 
			
		||||
{% block sidebar %}
 | 
			
		||||
<section>
 | 
			
		||||
    <h4 class="title is-4">{% translate "Previously on air" %}</h4>
 | 
			
		||||
    {% with has_cover=False %}
 | 
			
		||||
    {% with logs as object_list %}
 | 
			
		||||
    {% include "aircox/widgets/log_list.html" %}
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
<section>
 | 
			
		||||
    <h4 class="title is-4">{% translate "Today" %}</h4>
 | 
			
		||||
    {% with is_thin=True %}
 | 
			
		||||
    <h4 class="title is-4">{% translate "Last publications" %}</h4>
 | 
			
		||||
    {% with hide_schedule=True %}
 | 
			
		||||
    {% with has_headline=False %}
 | 
			
		||||
    <table class="table is-fullwidth has-background-transparent">
 | 
			
		||||
    {% for object in sidebar_object_list %}
 | 
			
		||||
    <tr {% if object.is_now %}class="is-selected"{% endif %}>
 | 
			
		||||
        <td>{{ object.start|date:"H:i" }}</td>
 | 
			
		||||
        <td>{% include "aircox/widgets/diffusion_item.html" %}</td>
 | 
			
		||||
    </tr>
 | 
			
		||||
    {% for object in last_publications %}
 | 
			
		||||
    {% include object.item_template_name|default:'aircox/widgets/page_item.html' %}
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
    </table>
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
    {% endwith %}
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ Context variables:
 | 
			
		||||
- is-primary: render as primary
 | 
			
		||||
- has_headline (=False): if True, display headline
 | 
			
		||||
- has_cover (=True): hide page cover
 | 
			
		||||
- is_thin (=False): if True, smaller cover and display less info
 | 
			
		||||
{% endcomment %}
 | 
			
		||||
 | 
			
		||||
{% if render_card %}
 | 
			
		||||
@ -31,8 +32,13 @@ Context variables:
 | 
			
		||||
<article class="media item {% block css %}{% endblock%}">
 | 
			
		||||
    {% if has_cover|default_if_none:True %}
 | 
			
		||||
    <div class="media-left">
 | 
			
		||||
        {% if is_thin %}
 | 
			
		||||
        <img src="{% thumbnail object.cover|default:station.default_cover 64x64 crop=scale %}"
 | 
			
		||||
            class="cover is-tiny">
 | 
			
		||||
        {% else %}
 | 
			
		||||
        <img src="{% thumbnail object.cover|default:station.default_cover 128x128 crop=scale %}"
 | 
			
		||||
            class="cover is-small">
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
    <div class="media-content">
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								aircox/templates/aircox/widgets/diffusion_list.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								aircox/templates/aircox/widgets/diffusion_list.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
{% comment %}
 | 
			
		||||
Context:
 | 
			
		||||
- object_list: object list
 | 
			
		||||
- date: date for list
 | 
			
		||||
{% endcomment %}
 | 
			
		||||
<table id="timetable{% if date %}-{{ date|date:"Y-m-d" }}{% endif %}" style="border:none;">
 | 
			
		||||
    {% for diffusion in object_list %}
 | 
			
		||||
    <tr class="{% if diffusion.is_now %}has-background-primary{% endif %}">
 | 
			
		||||
        <td class="pr-2 pb-2">
 | 
			
		||||
            <time datetime="{{ diffusion.start|date:"c" }}">
 | 
			
		||||
            {{ diffusion.start|date:"H:i" }} - {{ diffusion.end|date:"H:i" }}
 | 
			
		||||
            </time>
 | 
			
		||||
        </td>
 | 
			
		||||
        <td class="pb-2">
 | 
			
		||||
            {% with diffusion.episode as object %}
 | 
			
		||||
            {% include "aircox/widgets/episode_item.html" %}
 | 
			
		||||
            {% endwith %}
 | 
			
		||||
        </td>
 | 
			
		||||
    </tr>
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
@ -1,33 +1,32 @@
 | 
			
		||||
import datetime
 | 
			
		||||
from datetime import date
 | 
			
		||||
 | 
			
		||||
from django.utils.translation import gettext as _
 | 
			
		||||
from django.utils import timezone as tz
 | 
			
		||||
from django.views.generic import ListView
 | 
			
		||||
 | 
			
		||||
from ..models import Diffusion, Log, Page, StaticPage
 | 
			
		||||
from .base import BaseView
 | 
			
		||||
from .page import PageListView
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class HomeView(PageListView):
 | 
			
		||||
class HomeView(BaseView, ListView):
 | 
			
		||||
    template_name = 'aircox/home.html'
 | 
			
		||||
    model = Page
 | 
			
		||||
    queryset = Page.objects.select_subclasses()
 | 
			
		||||
    paginate_by = 10
 | 
			
		||||
    list_count = 40
 | 
			
		||||
    model = Diffusion
 | 
			
		||||
    attach_to_value = StaticPage.ATTACH_TO_HOME
 | 
			
		||||
    queryset = Diffusion.objects.on_air().select_related('episode')
 | 
			
		||||
    logs_count = 5
 | 
			
		||||
    has_filters = False
 | 
			
		||||
    attach_to_value = StaticPage.ATTACH_TO_HOME
 | 
			
		||||
 | 
			
		||||
    def get_logs(self):
 | 
			
		||||
        today = datetime.date.today()
 | 
			
		||||
    def get_queryset(self):
 | 
			
		||||
        return super().get_queryset().date(date.today())
 | 
			
		||||
 | 
			
		||||
    def get_logs(self, diffusions):
 | 
			
		||||
        today = date.today()
 | 
			
		||||
        logs = Log.objects.on_air().date(today).filter(track__isnull=False)
 | 
			
		||||
        diffs = Diffusion.objects.on_air().date(today)
 | 
			
		||||
        return Log.merge_diffusions(logs, diffs, self.logs_count)
 | 
			
		||||
        # diffs = Diffusion.objects.on_air().date(today)
 | 
			
		||||
        return Log.merge_diffusions(logs, diffusions, self.logs_count)
 | 
			
		||||
 | 
			
		||||
    def get_sidebar_queryset(self):
 | 
			
		||||
        today = datetime.date.today()
 | 
			
		||||
        return Diffusion.objects.on_air().date(today)
 | 
			
		||||
 | 
			
		||||
    def get_top_diffs(self):
 | 
			
		||||
    def get_next_diffs(self):
 | 
			
		||||
        now = tz.now()
 | 
			
		||||
        current_diff = Diffusion.objects.on_air().now(now).first()
 | 
			
		||||
        next_diffs = Diffusion.objects.on_air().after(now)
 | 
			
		||||
@ -37,10 +36,14 @@ class HomeView(PageListView):
 | 
			
		||||
            diffs = next_diffs[:3]
 | 
			
		||||
        return diffs
 | 
			
		||||
 | 
			
		||||
    def get_last_publications(self):
 | 
			
		||||
        return Page.objects.select_subclasses().published() \
 | 
			
		||||
                   .order_by('-pub_date')
 | 
			
		||||
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        kwargs['logs'] = self.get_logs()
 | 
			
		||||
        kwargs['top_diffs'] = self.get_top_diffs()
 | 
			
		||||
        return super().get_context_data(**kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        context = super().get_context_data(**kwargs)
 | 
			
		||||
        context['logs'] = self.get_logs(context['object_list'])
 | 
			
		||||
        context['next_diffs'] = self.get_next_diffs()
 | 
			
		||||
        context['last_publications'] = self.get_last_publications()[:5]
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user