Commit 45ca87a4 authored by fred's avatar fred

add topiks to main navigation

parent ae85bb0d
......@@ -126,9 +126,23 @@ def player(context):
@register.inclusion_tag('includes/metaNav.html', takes_context=True)
def metanav(context, active=None):
request_path = context['request'].path
section = 'About'
if request_path == '/':
section = 'Home'
elif request_path.startswith('/actus/'):
section = 'News'
elif request_path.startswith('/sons/'):
section = 'Listen'
elif request_path.startswith('/topiks'):
section = 'Topiks'
elif request_path.startswith('/emissions') or request_path == '/grille' or request_path == '/programme/':
section = 'Emissions'
elif request_path == '/recherche/':
section = 'Search'
return {
'LANGUAGE_CODE': context.get('LANGUAGE_CODE'),
'sectionName': context.get('sectionName')
'sectionName': section,
}
@register.inclusion_tag('includes/week.html')
......
......@@ -135,7 +135,6 @@ class GlobalSearchForm(FacetedSearchForm):
class SearchView(FacetedSearchView):
def extra_context(self):
context = super(SearchView, self).extra_context()
context['sectionName'] = 'Search'
if self.request.GET.getlist('selected_facets'):
context['facets_qs'] = '&selected_facets=' + '&'.join(self.request.GET.getlist('selected_facets'))
context['selected_categories'] = [
......@@ -182,7 +181,6 @@ class ListenArchivesView(FacetedSearchView):
def extra_context(self):
context = super(ListenArchivesView, self).extra_context()
context['sectionName'] = "Listen"
if self.request.GET.getlist('selected_facets'):
context['facets_qs'] = '&selected_facets=' + '&'.join(self.request.GET.getlist('selected_facets'))
context['selected_format'] = [
......@@ -226,7 +224,6 @@ class NewsArchivesView(FacetedSearchView):
context = super(NewsArchivesView, self).extra_context()
if self.request.GET.getlist('selected_facets'):
context['facets_qs'] = '&selected_facets=' + '&'.join(self.request.GET.getlist('selected_facets'))
context['sectionName'] = 'News'
context['selected_news_categories'] = [
x.split(':', 1)[1] for x in self.request.GET.getlist('selected_facets')
if x.startswith('news_categories_exact')]
......
......@@ -99,7 +99,6 @@ class EmissionDetailView(DetailView, EmissionMixin):
def get_context_data(self, **kwargs):
context = super(EmissionDetailView, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['schedules'] = Schedule.objects.select_related().filter(
emission=self.object).order_by('rerun', 'datetime')
context['news'] = NewsItem.objects.all().filter(emission=self.object.id).order_by('-date')[:3]
......@@ -112,7 +111,6 @@ class EpisodeDetailView(DetailView, EmissionMixin):
def get_context_data(self, **kwargs):
context = super(EpisodeDetailView, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['diffusions'] = Diffusion.objects.select_related().filter(
episode=self.object.id).order_by('datetime')
try:
......@@ -133,7 +131,6 @@ class EmissionEpisodesDetailView(DetailView, EmissionMixin):
def get_context_data(self, **kwargs):
context = super(EmissionEpisodesDetailView, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['schedules'] = Schedule.objects.select_related().filter(
emission=self.object).order_by('rerun', 'datetime')
......@@ -155,7 +152,6 @@ class ProgramView(TemplateView):
def get_context_data(self, year=None, week=None, **kwargs):
context = super(ProgramView, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['weekday'] = datetime.today().weekday()
......@@ -204,7 +200,6 @@ class Grid(TemplateView):
def get_context_data(self, **kwargs):
context = super(Grid, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
nb_lines = 2 * 24 # the cells are half hours
grid = []
......@@ -430,7 +425,6 @@ class Home(TemplateView):
def get_context_data(self, **kwargs):
context = super(Home, self).get_context_data(**kwargs)
context['sectionName'] = "Home"
context['emissions'] = Emission.objects.filter(archived=False).order_by('-creation_timestamp')[:3]
context['newsitems'] = NewsItem.objects.order_by('-date')[:3]
......@@ -454,7 +448,6 @@ class NewsItemView(DetailView):
model = NewsItem
def get_context_data(self, **kwargs):
context = super(NewsItemView, self).get_context_data(**kwargs)
context['sectionName'] = "News"
context['categories'] = NewsCategory.objects.all()
context['news'] = NewsItem.objects.all().order_by('-date')
context['topiks'] = [x.topik for x in ItemTopik.objects.filter(newsitem=self.object)]
......@@ -465,7 +458,6 @@ class News(TemplateView):
template_name = 'news.html'
def get_context_data(self, **kwargs):
context = super(News, self).get_context_data(**kwargs)
context['sectionName'] = "News"
context['focus'] = NewsItem.objects.filter(got_focus__isnull=False).select_related('category').order_by('-date')[:10]
context['news'] = NewsItem.objects.all().order_by('-date')
return context
......@@ -477,7 +469,6 @@ class Agenda(TemplateView):
template_name = 'agenda.html'
def get_context_data(self, **kwargs):
context = super(Agenda, self).get_context_data(**kwargs)
context['sectionName'] = "News"
context['agenda'] = NewsItem.objects.filter(
event_date__gte=date.today()).order_by('date')[:20]
context['news'] = NewsItem.objects.all().order_by('-date')
......@@ -496,7 +487,6 @@ class AgendaByMonth(MonthArchiveView):
def get_context_data(self, **kwargs):
context = super(AgendaByMonth, self).get_context_data(**kwargs)
context['sectionName'] = "News"
context['agenda'] = context['object_list']
context['news'] = NewsItem.objects.all().order_by('-date')
return context
......@@ -509,7 +499,6 @@ class Emissions(TemplateView):
def get_context_data(self, **kwargs):
context = super(Emissions, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['emissions'] = Emission.objects.prefetch_related('categories').filter(archived=False).order_by('title')
context['categories'] = Category.objects.all()
return context
......@@ -521,7 +510,6 @@ class EmissionsArchives(TemplateView):
def get_context_data(self, **kwargs):
context = super(EmissionsArchives, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['emissions'] = Emission.objects.prefetch_related('categories').filter(archived=True).order_by('title')
context['categories'] = Category.objects.all()
return context
......@@ -533,7 +521,6 @@ class Listen(TemplateView):
def get_context_data(self, **kwargs):
context = super(Listen, self).get_context_data(**kwargs)
context['sectionName'] = "Listen"
context['focus'] = SoundFile.objects.prefetch_related('episode__emission__categories').filter(
podcastable=True, got_focus__isnull=False) \
.select_related().extra(select={
......
......@@ -269,11 +269,13 @@ body{
}
#metaNav form {
display: inline;
display: inline-block;
padding-top: 0.2em;
}
#metaNav input {
border: 1px solid #ececec;
width: 10em;
}
@media screen and (max-width:760px){
......
......@@ -13,6 +13,10 @@
<span class="nav-icon icon-headphones resymbol" ></span>
<span class="iconLabel">{% trans 'Sounds' %}</span>
</a></li>
<li class="{% if sectionName = "Topiks" %}active{% endif %}"><a href="/topiks/">
<span class="nav-icon icon-bolt" ></span>
<span class="iconLabel">Topiks</span>
</a></li>
<li class="{% if sectionName = "Emissions" %}active{% endif %}"><a title="Les émissions, le programme de la semaine, la grille" href="{% url 'grid' %}">
<span class="nav-icon icon-calendar resymbol" ></span>
<span class="iconLabel">{% trans 'Program' %}</span>
......@@ -28,9 +32,8 @@
</li>
<li id="nav-search" class="{% if sectionName = "Search" %}active{% endif %}"><a href="{% url 'search' %}">
<span class="nav-icon icon-search resymbol" ></span>
<span class="iconLabel">{% trans 'Search' %}</span>
</a>
<form action="{% url 'search' %}"><input name="q" type="search"></input></form>
<form action="{% url 'search' %}"><input placeholder="{% trans 'Search' %}" name="q" type="search"></input></form>
</li>
</ul>
......
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