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 {
width: 15em;
width: 20em;
}
.page .menu_left { margin-right: 0.5em; }

View File

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

View File

@ -8,7 +8,7 @@
{% for post in object_list %}
<a class="post_item"
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">
{% if 'date' in view.fields %}
<span class="post_date">

View File

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

View File

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

View File

@ -2,6 +2,7 @@
body {
background-color: #F2F2F2;
font-family: "Myriad Pro",Calibri,Helvetica,Arial,sans-serif;
margin: 0 3em;
}
@ -11,7 +12,7 @@ h1, h2, h3 {
time {
font-size: 0.9em;
color: #616161;
color: #818181;
}
a {
@ -24,15 +25,15 @@ a:hover {
}
nav.menu {
/** Menu **/
.menu {
padding: 0.5em;
}
nav.menu_top {
.menu_top {
background-color: #212121;
color: #007EDF;
font-size: 1.1em;
box-shadow: 0em 0.2em 0.5em 0.1em black
}
@ -54,6 +55,31 @@ nav.menu {
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 {
width: 100%;
padding: 1.5em 0em;
@ -66,28 +92,28 @@ nav.menu {
}
.post_list {
main .post_list {
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;
padding: 0.2em;
}
.post_list .post_item:hover {
main .post_list .post_item:hover {
}
.post_list h3 {
main .post_list h3 {
margin: 0.2em;
}
.post_list time {
main .post_list time {
float: right;
}
.post_list img {
main .post_list img {
float: left;
margin-right: 0.5em;
}

View File

@ -25,14 +25,15 @@ website = Website(
Menu(
position = 'top',
sections = [
Section(content = "Radio Campus le SITE")
Section(content = "Radio Campus le SITE"),
]
),
Menu(
position = 'left',
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 DetailView
from django.core import serializers
from django.utils import timezone as tz
from django.utils.translation import ugettext as _, ugettext_lazy
import aircox_programs.models as programs
@ -11,7 +12,6 @@ from aircox_cms.views import Sections
from website.models import *
class PlayListSection (Sections.List):
title = _('Playlist')
@ -22,7 +22,6 @@ class PlayListSection (Sections.List):
return [ Sections.List.Item(None, track.title, track.artist)
for track in tracks ]
class ScheduleSection (Sections.List):
title = _('Schedule')
@ -36,11 +35,34 @@ class ScheduleSection (Sections.List):
for sched in scheds
]
class EpisodesSection (Sections.Posts):
title = _('Episodes')
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