Previous diffusions; website styles; small templates change; VerboseFrequency

This commit is contained in:
bkfox 2015-10-13 16:04:36 +02:00
parent 0032e216b8
commit c69ef73a94
8 changed files with 117 additions and 63 deletions

View File

@ -9,7 +9,7 @@ body {
} }
.page .menu { .page .menu {
width: 15em; width: 20em;
} }
.page .menu_left { margin-right: 0.5em; } .page .menu_left { margin-right: 0.5em; }

View File

@ -21,40 +21,42 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% if menus.top %} <div class="page-container">
{{ menus.top|safe }} {% if menus.top %}
{% endif %} {{ menus.top|safe }}
<div class="page">
{% if menus.left %}
{{ menus.left|safe }}
{% endif %} {% endif %}
<main> <div class="page">
{% block pre_title %} {% if menus.left %}
{% endblock %} {{ menus.left|safe }}
<h1> {% endif %}
{% block title %}
{{ title }}
{% endblock %}
</h1>
{% block post_title %}
{% endblock %}
<div class="content">
{% block content %}
{% endblock %}
</div>
</main>
{% if menus.right %} <main>
{{ menus.right|safe }} {% block pre_title %}
{% endblock %}
<h1>
{% block title %}
{{ title }}
{% endblock %}
</h1>
{% block post_title %}
{% endblock %}
<div class="content">
{% block content %}
{% endblock %}
</div>
</main>
{% if menus.right %}
{{ menus.right|safe }}
{% endif %}
</div>
{% if menus.page_bottom %}
{{ menus.page_bottom|safe }}
{% endif %} {% endif %}
</div> </div>
{% if menus.page_bottom %}
{{ menus.page_bottom|safe }}
{% endif %}
{% block footer %} {% block footer %}
{% if menus.footer %} {% if menus.footer %}
{{ menus.footer|safe }} {{ menus.footer|safe }}

View File

@ -8,7 +8,7 @@
{% for post in object_list %} {% for post in object_list %}
<a class="post_item" <a class="post_item"
href="{{ post.detail_url }}"> href="{{ post.detail_url }}">
{% if 'date' in view.fields or 'time' in list.fields %} {% if 'date' in view.fields or 'time' in view.fields %}
<time datetime="{{ post.date }}" class="post_datetime"> <time datetime="{{ post.date }}" class="post_datetime">
{% if 'date' in view.fields %} {% if 'date' in view.fields %}
<span class="post_date"> <span class="post_date">

View File

@ -320,6 +320,7 @@ class Sections:
hide_empty = False # hides the section if the list is empty hide_empty = False # hides the section if the list is empty
use_icons = True # print icons use_icons = True # print icons
paginate_by = 0 # number of items
icon_size = '32x32' # icons size icon_size = '32x32' # icons size
template_name = 'aircox_cms/section_list.html' template_name = 'aircox_cms/section_list.html'
@ -337,6 +338,7 @@ class Sections:
'classes': context.get('classes') + ' section_list', 'classes': context.get('classes') + ' section_list',
'icon_size': self.icon_size, 'icon_size': self.icon_size,
'object_list': object_list, 'object_list': object_list,
'paginate_by': self.paginate_by,
}) })
return context return context
@ -363,6 +365,7 @@ class Sections:
Render a list using PostListView's template. Render a list using PostListView's template.
""" """
embed = True embed = True
paginate_by = 5
icon_size = '64x64' icon_size = '64x64'
fields = [ 'date', 'time', 'image', 'title', 'content' ] fields = [ 'date', 'time', 'image', 'title', 'content' ]
@ -375,8 +378,8 @@ class Sections:
context.update({ context.update({
'object_list': self.get_object_list(), 'object_list': self.get_object_list(),
'embed': True, 'embed': True,
'paginate_by': self.paginate_by,
}) })
print(context['object_list'][0].image)
return render_to_string(PostListView.template_name, context) return render_to_string(PostListView.template_name, context)
def get_context_data (self, **kwargs): def get_context_data (self, **kwargs):

View File

@ -146,18 +146,18 @@ class Schedule (models.Model):
# the schedule is present. # the schedule is present.
# For ponctual programs, there is no need for a schedule, only a diffusion # For ponctual programs, there is no need for a schedule, only a diffusion
Frequency = { Frequency = {
'first': 0b000001, 'first': (0b000001, _('first week of the month')),
'second': 0b000010, 'second': (0b000010, _('second week of the month')),
'third': 0b000100, 'third': (0b000100, _('third week of the month')),
'fourth': 0b001000, 'fourth': (0b001000, _('fourth week of the month')),
'last': 0b010000, 'last': (0b010000, _('last week of the month')),
'first and third': 0b000101, 'first and third': (0b000101, _('first and third weeks of the month')),
'second and fourth': 0b001010, 'second and fourth': (0b001010, _('second and fourth weeks of the month')),
'every': 0b011111, 'every': (0b011111, _('once a week')),
'one on two': 0b100000, 'one on two': (0b100000, _('one week on two')),
} }
for key, value in Frequency.items(): VerboseFrequency = { value[0]: value[1] for key, value in Frequency.items() }
ugettext_lazy(key) Frequency = { key: value[0] for key, value in Frequency.items() }
program = models.ForeignKey( program = models.ForeignKey(
'Program', 'Program',
@ -169,7 +169,7 @@ class Schedule (models.Model):
) )
frequency = models.SmallIntegerField( frequency = models.SmallIntegerField(
_('frequency'), _('frequency'),
choices = [ (y, x) for x,y in Frequency.items() ], choices = VerboseFrequency.items(),
) )
rerun = models.ForeignKey( rerun = models.ForeignKey(
'self', 'self',
@ -277,9 +277,9 @@ class Schedule (models.Model):
if self.rerun: if self.rerun:
first_date -= self.date - self.rerun.date first_date -= self.date - self.rerun.date
episode = Episode.objects.filter(date = first_date, diffusion = Diffusion.objects.filter(date = first_date,
program = self.program) program = self.program)
episode = episode[0] if episode.count() else None episode = diffusion[0].episode if diffusion.count() else None
diffusions.append(Diffusion( diffusions.append(Diffusion(
episode = episode, episode = episode,

View File

@ -2,6 +2,7 @@
body { body {
background-color: #F2F2F2; background-color: #F2F2F2;
font-family: "Myriad Pro",Calibri,Helvetica,Arial,sans-serif; font-family: "Myriad Pro",Calibri,Helvetica,Arial,sans-serif;
margin: 0 3em;
} }
@ -11,7 +12,7 @@ h1, h2, h3 {
time { time {
font-size: 0.9em; font-size: 0.9em;
color: #616161; color: #818181;
} }
a { a {
@ -24,15 +25,15 @@ a:hover {
} }
nav.menu { /** Menu **/
.menu {
padding: 0.5em; padding: 0.5em;
} }
nav.menu_top { .menu_top {
background-color: #212121; background-color: #212121;
color: #007EDF; color: #007EDF;
font-size: 1.1em; font-size: 1.1em;
box-shadow: 0em 0.2em 0.5em 0.1em black
} }
@ -54,6 +55,31 @@ nav.menu {
z-index: -1; z-index: -1;
} }
.menu h1 {
font-size: 1.1em;
}
.menu .post_list {
font-size: 0.9em;
}
.menu .post_list h3 {
font-size: 1.0em;
display: inline;
}
.menu .post_list time {
margin: 0.2em;
}
/** Page **/
.page-container {
box-shadow: 0em 0.2em 0.5em 0.1em black;
margin-bottom: 2em;
}
.page { .page {
width: 100%; width: 100%;
padding: 1.5em 0em; padding: 1.5em 0em;
@ -66,28 +92,28 @@ nav.menu {
} }
.post_list { main .post_list {
background-color: #F2F2F2; background-color: #F2F2F2;
box-shadow: inset 0.2em 0.2em 0.2em 0.01em black; border: 1px #818181 dotted;
} }
.post_list .post_item { main .post_list .post_item {
min-height: 64px; min-height: 64px;
padding: 0.2em; padding: 0.2em;
} }
.post_list .post_item:hover { main .post_list .post_item:hover {
} }
.post_list h3 { main .post_list h3 {
margin: 0.2em; margin: 0.2em;
} }
.post_list time { main .post_list time {
float: right; float: right;
} }
.post_list img { main .post_list img {
float: left; float: left;
margin-right: 0.5em; margin-right: 0.5em;
} }

View File

@ -25,14 +25,15 @@ website = Website(
Menu( Menu(
position = 'top', position = 'top',
sections = [ sections = [
Section(content = "Radio Campus le SITE") Section(content = "Radio Campus le SITE"),
] ]
), ),
Menu( Menu(
position = 'left', position = 'left',
sections = [ sections = [
Section(content = 'loool<br>blob') Section(content = 'loool<br>blob'),
PreviousDiffusions(),
], ],
), ),
], ],

View File

@ -3,6 +3,7 @@ from django.template.loader import render_to_string
from django.views.generic import ListView from django.views.generic import ListView
from django.views.generic import DetailView from django.views.generic import DetailView
from django.core import serializers from django.core import serializers
from django.utils import timezone as tz
from django.utils.translation import ugettext as _, ugettext_lazy from django.utils.translation import ugettext as _, ugettext_lazy
import aircox_programs.models as programs import aircox_programs.models as programs
@ -11,7 +12,6 @@ from aircox_cms.views import Sections
from website.models import * from website.models import *
class PlayListSection (Sections.List): class PlayListSection (Sections.List):
title = _('Playlist') title = _('Playlist')
@ -22,7 +22,6 @@ class PlayListSection (Sections.List):
return [ Sections.List.Item(None, track.title, track.artist) return [ Sections.List.Item(None, track.title, track.artist)
for track in tracks ] for track in tracks ]
class ScheduleSection (Sections.List): class ScheduleSection (Sections.List):
title = _('Schedule') title = _('Schedule')
@ -36,11 +35,34 @@ class ScheduleSection (Sections.List):
for sched in scheds for sched in scheds
] ]
class EpisodesSection (Sections.Posts): class EpisodesSection (Sections.Posts):
title = _('Episodes') title = _('Episodes')
def get_object_list (self): def get_object_list (self):
return Episode.objects.filter(related__program = self.object.pk) return Episode.objects.filter(related__program = self.object.related.pk)
class PreviousDiffusions (Sections.Posts):
title = _('Previous Diffusions')
fields = ['title', 'time']
def get_object_list (self):
diffusions = programs.Diffusion.objects\
.filter(date__lt = tz.datetime.now())
episodes = []
for diffusion in diffusions:
if not diffusion.episode:
continue
post = Episode.objects.filter(related = diffusion.episode.pk)
if not post:
continue
post = post[0]
post.date = diffusion.date
episodes.append(post)
if len(episodes) == self.paginate_by:
break
return episodes