Skip to content
GitLab
Menu
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
496ba2e3
Commit
496ba2e3
authored
Sep 13, 2013
by
fred
Browse files
archive view for newsitems
parent
d6006ba9
Changes
2
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
496ba2e3
...
...
@@ -99,7 +99,8 @@ class EmissionEpisodesDetailView(DetailView, EmissionMixin):
context
[
'search_query'
]
=
self
.
request
.
GET
.
get
(
'q'
)
if
context
[
'search_query'
]:
# query string
sqs
=
SearchQuerySet
().
filter
(
emission_slug_exact
=
self
.
object
.
slug
,
text
=
context
[
'search_query'
])
sqs
=
SearchQuerySet
().
filter
(
django_ct
=
'emissions.episode'
,
emission_slug_exact
=
self
.
object
.
slug
,
text
=
context
[
'search_query'
])
episode_ids
=
[
x
.
pk
for
x
in
sqs
]
else
:
episode_ids
=
None
...
...
@@ -458,9 +459,16 @@ class NewsArchives(TemplateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
NewsArchives
,
self
).
get_context_data
(
**
kwargs
)
context
[
'sectionName'
]
=
"News"
context
[
'focus'
]
=
list
(
NewsItem
.
objects
.
all
().
exclude
(
image__isnull
=
True
).
exclude
(
image__exact
=
''
).
order_by
(
'-date'
)[
0
:
6
])
context
[
'news'
]
=
list
(
NewsItem
.
objects
.
all
().
order_by
(
'-date'
)[
0
:
600
])
context
[
'categories'
]
=
NewsCategory
.
objects
.
all
()
context
[
'search_query'
]
=
self
.
request
.
GET
.
get
(
'q'
)
sqs
=
SearchQuerySet
().
filter
(
django_ct
=
'emissions.newsitem'
)
if
context
[
'search_query'
]:
# query string
sqs
=
sqs
.
filter
(
text
=
context
[
'search_query'
])
sqs
=
sqs
.
load_all
()
context
[
'results'
]
=
sqs
return
context
newsArchives
=
NewsArchives
.
as_view
()
...
...
panikweb_templates/templates/news/archives.html
View file @
496ba2e3
...
...
@@ -7,11 +7,55 @@
{% endblock %}
{% block main %}
<form
method=
"get"
action=
"."
class=
"padded center"
id=
"search-form"
>
<div
class=
"big "
>
<label
for=
"id_q"
>
Rechercher:
</label>
<label
for=
"id_q"
>
Rechercher
:
</label>
<input
id=
"id_q"
name=
"q"
type=
"text"
{%
if
search_query
%}
value=
"{{ search_query }}{% endif %}"
>
<button
class=
"icon-search"
></button>
</div>
</form>
<div
class=
"wrapper {% if results %}sided{% endif %}"
>
{% if search_query and not results %}
<div
class=
"big error padded center"
>
Sorry, no result with your query!
</div>
{% endif %}
{% if search_query and results or results.count
<
=
24
%}
<
ul
class=
"custom columns list news cf"
>
{% for result in results %}
<li
class=
"item"
>
{% with result.object as content %}{% news_inline %}{% endwith %}
</li>
{% endfor %}
</ul>
{% else %}
<div
id=
"Emission-container"
class=
"emission padded"
>
{% if results %}
{% regroup results by date|date:"F Y"|capfirst as month_list %}
<div>
{% for month in month_list %}
<div
class=
"monthGroup {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}"
>
<div
class=
"legend button"
onclick=
"$('#{{ month.grouper|slugify }}').toggle();"
>
{{ month.grouper }}
</div>
<ul
class=
"custom list"
id=
"{{ month.grouper|slugify }}"
{%
if
forloop.counter
>
= 3 %}style="display:none;"{% endif %}
>
{% for result in month.list %}
<li>
{% with result.object as content %}{% news_inline %}{% endwith %}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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