Commit 496ba2e3 authored by fred's avatar fred
Browse files

archive view for newsitems

parent d6006ba9
......@@ -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()
......
......@@ -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 %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment