Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
2cec8070
Commit
2cec8070
authored
Aug 27, 2013
by
Simon Daron
Browse files
Use templatetag for week view
parent
38b5d7b2
Changes
7
Hide whitespace changes
Inline
Side-by-side
panikweb/paniktags/templatetags/paniktags.py
View file @
2cec8070
...
...
@@ -5,6 +5,10 @@ import uuid
from
django
import
template
from
django.db.models.query
import
QuerySet
from
django.utils
import
simplejson
from
datetime
import
datetime
,
timedelta
from
django.views.generic.dates
import
_date_from_string
from
emissions.utils
import
period_program
register
=
template
.
Library
()
...
...
@@ -43,6 +47,25 @@ def player():
def
metanav
():
return
{}
@
register
.
inclusion_tag
(
'includes/week.html'
,
takes_context
=
True
)
def
weekview
(
context
,
year
=
None
,
week
=
None
,
fragment
=
None
):
year
=
year
if
year
else
str
(
datetime
.
today
().
year
)
week
=
week
if
week
else
str
(
datetime
.
today
().
isocalendar
()[
1
])
date
=
_date_from_string
(
year
,
'%Y'
,
'1'
,
'%w'
,
week
,
'%W'
)
date
=
datetime
(
*
date
.
timetuple
()[:
3
])
program
=
period_program
(
date
,
date
+
timedelta
(
days
=
7
))
days
=
[]
for
day
in
range
(
7
):
days
.
append
({
'cells'
:
[
x
for
x
in
program
if
x
.
is_on_weekday
(
day
+
1
)],
'datetime'
:
date
+
timedelta
(
days
=
day
)})
return
{
'fragment'
:
fragment
,
'days'
:
days
,
'week'
:
week
,
'year'
:
year
,
}
@
register
.
inclusion_tag
(
'news/inline.html'
,
takes_context
=
False
)
def
news_inline
(
content
=
None
,
klass
=
None
,
logo
=
None
):
return
{
...
...
panikweb/views.py
View file @
2cec8070
...
...
@@ -34,16 +34,8 @@ class ProgramWeekView(TemplateView):
def
get_context_data
(
self
,
year
,
week
,
**
kwargs
):
context
=
super
(
ProgramWeekView
,
self
).
get_context_data
(
**
kwargs
)
date
=
_date_from_string
(
year
,
'%Y'
,
'1'
,
'%w'
,
week
,
'%W'
)
date
=
datetime
(
*
date
.
timetuple
()[:
3
])
program
=
period_program
(
date
,
date
+
timedelta
(
days
=
7
))
days
=
[]
for
day
in
range
(
7
):
days
.
append
({
'cells'
:
[
x
for
x
in
program
if
x
.
is_on_weekday
(
day
+
1
)],
'datetime'
:
date
+
timedelta
(
days
=
day
)})
context
[
'days'
]
=
days
context
[
'week'
]
=
week
context
[
'year'
]
=
year
return
context
week
=
ProgramWeekView
.
as_view
()
...
...
panikweb_templates/templates/home.html
View file @
2cec8070
...
...
@@ -57,36 +57,8 @@
<div
class=
"program padded"
>
<div
class=
"wrapper"
>
<h2>
Cette semaine sur Panik
</h2>
<div
class=
"program tabs"
data-tab-about=
"#ProgramContent"
>
<nav
class=
""
>
<ul
class=
"days custom distributed"
>
{% for day in days %}
<li
class=
""
><button
data-tab=
"#Program-tabs-{{ day.datetime|date:"
w
"
}}"
>
{{ day.datetime|date:"D d" }}
</button></li>
{% endfor %}
</ul>
</nav>
</div>
<div
id=
"ProgramContent"
class=
"program"
>
{% for day in days %}
<div
data-tabbed=
"true"
class=
"content padded"
id=
"Program-tabs-{{ day.datetime|date:"
w
"
}}"
>
<ul
class=
"custom emission-list list"
>
{% if day.schedules %}
{% for schedule in day.schedules %}
<li>
<div
class=
"date dateBloc"
>
<div
class=
"time"
>
{{ schedule.datetime|date:"H:i" }}
</div>
</div>
<div
class=
"schedule"
>
{% include "emissions/inline.html" with emission=schedule.emission %}
</div>
</li>
{% endfor %}
{% else %}
<li>
Non stop
</li>
{% endif %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% weekview %}
</div>
</div>
{% endblock %}
...
...
panikweb_templates/templates/includes/metaNav.html
View file @
2cec8070
...
...
@@ -14,10 +14,12 @@
<span
class=
"icon-bullhorn"
></span>
<span
class=
"iconLabel"
>
News
</span>
</a></li>
<!--
<li><a href="{% url 'program' %}">
<span class="icon-calendar" ></span>
<span class="iconLabel">Program</span>
</a></li>
-->
<li><a
href=
"{% url 'grid' %}"
>
<span
class=
"icon-th-large"
></span>
<span
class=
"iconLabel"
>
Grid
</span>
...
...
panikweb_templates/templates/includes/week.html
0 → 100644
View file @
2cec8070
{% if not fragment or fragment = "nav" %}
<div
class=
"program tabs"
data-tab-about=
"#weekProgramContent-{{ week|slugify }}"
>
<nav
class=
""
>
<ul
class=
"days custom distributed"
>
{% for day in days %}
<li
class=
""
><button
data-tab=
"#Program-week-{{ day.datetime|slugify }}"
>
{{ day.datetime|date:"D d" }}
</button></li>
{% endfor %}
</ul>
</nav>
</div>
{% endif %}
{% if not fragment or fragment = "program" %}
<div
id=
"weekProgramContent-{{ week|slugify }}"
class=
"program wrapper"
>
{% for day in days %}
<div
data-tabbed=
"true"
class=
"content padded"
id=
"Program-week-{{ day.datetime|slugify }}"
>
<ul
class=
"custom emission-list list"
>
{% if day.cells %}
{% for cell in day.cells %}
<li>
<strong>
{{ cell.datetime|date:"H:i" }}
</strong>
{% if cell.episode %}
<a
href=
"{% url 'episode-view' emission_slug=cell.episode.emission.slug slug=cell.episode.slug %}"
>
{{ cell.episode.emission.title }} - {{ cell.episode.title }}
</a>
{% elif cell.emission %}
<a
href=
"{% url 'emission-view' slug=cell.emission.slug %}"
>
{{ cell.emission.title }}
</a>
{% endif %}
</li>
{% endfor %}
{% else %}
<li><div
class=
"info"
>
Non stop only!
</div></li>
{% endif %}
</ul>
</div>
{% endfor %}
</div>
{% endif %}
panikweb_templates/templates/news/search_result.html
deleted
100644 → 0
View file @
38b5d7b2
<a
href=
"{% url 'news-view' slug=result.object.slug %}"
>
{{ result.object.title }}
</a>
panikweb_templates/templates/week.html
View file @
2cec8070
{% extends "base.html" %}
{% load paniktags %}
{% block bodyID %}Program{% endblock %}
{% block title %}Programme{% endblock %}
{% block nav %}
<div
class=
"program"
>
<nav
class=
"center"
>
<ul
class=
"custom distributed"
>
<li>
<a
href=
"{% url 'program_week' year=year week=week|add:"
-1
"
%}"
class=
"icon-chevron-sign-left"
></a>
</li>
<li>
Semaine {{ week }}
</li>
<li>
<a
href=
"{% url 'program_week' year=year week=week|add:"
1"
%}"
class=
"icon-chevron-sign-right"
></a>
</li>
</ul>
</nav>
{% weekview year=year week=week fragment="nav" %}
</div>
{% endblock %}
{% block main %}
{% for day in days %}
<h2>
{{ day.datetime|date:"D Y-m-d" }}
</h2>
<ul>
{% for cell in day.cells %}
<li>
{{ cell.datetime|date:"H:i" }} -
{% if cell.episode %}
{{ cell.episode.emission.title }} - {{ cell.episode.title }}
{% elif cell.emission %}
{{ cell.emission.title }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endfor %}
{% weekview year=year week=week fragment="program" %}
{% endblock %}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment