Skip to content
Snippets Groups Projects
Commit 684cd868 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Fixed translation issue for information items

parent e1fbee98
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ def generate_main_menu(context): ...@@ -69,7 +69,7 @@ def generate_main_menu(context):
top_level = Information.objects.filter(parent_information__isnull=True) top_level = Information.objects.filter(parent_information__isnull=True)
items_html = [] items_html = []
for info in top_level: for info in top_level:
info_locale = InformationLocale.get_information_locale_with_fallback(info.pk) info_locale = InformationLocale.get_information_locale_with_fallback(info.pk, request.LANGUAGE_CODE)
items_html.append( item_template % (reverse('information:detail', kwargs={"information_id":info.pk}), info_locale.headline) ) items_html.append( item_template % (reverse('information:detail', kwargs={"information_id":info.pk}), info_locale.headline) )
menu_html += dropdown_template % (" currentLink" if request.path.startswith("/information") else "",_("Information"),"".join(items_html)) menu_html += dropdown_template % (" currentLink" if request.path.startswith("/information") else "",_("Information"),"".join(items_html))
......
...@@ -89,6 +89,25 @@ ...@@ -89,6 +89,25 @@
<div class="alert alert-info">{% trans "No results for this forecast" %}</div> <div class="alert alert-info">{% trans "No results for this forecast" %}</div>
{% endif %} {% endif %}
{% endblock %}
{% block customCSS %}
<style type="text/css">
.table-fixed thead {
width: 97%;
}
.table-fixed tbody {
height: 230px;
overflow-y: auto;
width: 100%;
}
.table-fixed thead, .table-fixed tbody, .table-fixed tr, .table-fixed td, .table-fixed th {
display: block;
}
.table-fixed tbody td, .table-fixed thead > tr> th {
float: left;
border-bottom-width: 0;
}
</style>
{% endblock %} {% endblock %}
{% block customJS %} {% block customJS %}
<script type="text/javascript" src="{% url "views.settings_js" %}"></script> <script type="text/javascript" src="{% url "views.settings_js" %}"></script>
......
...@@ -32,7 +32,7 @@ def index(request): ...@@ -32,7 +32,7 @@ def index(request):
return render(request, 'information/index.html', context) return render(request, 'information/index.html', context)
def detail(request, information_id): def detail(request, information_id):
information_locale = InformationLocale.get_information_locale_with_fallback(information_id) information_locale = InformationLocale.get_information_locale_with_fallback(information_id, request.LANGUAGE_CODE)
# Is there a parent? # Is there a parent?
#parent_information = information_locale.information.parent_information #parent_information = information_locale.information.parent_information
# We get all the children too # We get all the children too
...@@ -44,16 +44,16 @@ def detail(request, information_id): ...@@ -44,16 +44,16 @@ def detail(request, information_id):
'information_locale' : information_locale, 'information_locale' : information_locale,
#'parent_information' : parent_information, #'parent_information' : parent_information,
#'children_locales':children_locales, #'children_locales':children_locales,
'breadcrumb': get_breadcrumb(information_locale.information), 'breadcrumb': get_breadcrumb(information_locale.information, request.LANGUAGE_CODE),
'menu_html': get_menu_html(None, information_id) 'menu_html': get_menu_html(None, information_id, request.LANGUAGE_CODE)
} }
return render(request, 'information/detail.html', context) return render(request, 'information/detail.html', context)
def get_breadcrumb(information): def get_breadcrumb(information, language):
active_id= information.pk active_id= information.pk
breadcrumb = []#[] breadcrumb = []#[]
while information != None: while information != None:
information_locale = InformationLocale.get_information_locale_with_fallback(information.pk) information_locale = InformationLocale.get_information_locale_with_fallback(information.pk, language)
children_locales = [] children_locales = []
for child in information_locale.information.children.all(): for child in information_locale.information.children.all():
children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk)) children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk))
...@@ -87,7 +87,7 @@ toggleable_item_template=""" ...@@ -87,7 +87,7 @@ toggleable_item_template="""
simple_item_template = """<li class="%s">%s</li>""" simple_item_template = """<li class="%s">%s</li>"""
## Recursive method ## Recursive method
def get_menu_html(parent_information, active_information_pk): def get_menu_html(parent_information, active_information_pk, language):
# We start with backtracking from the active information object # We start with backtracking from the active information object
if(parent_information == None): if(parent_information == None):
...@@ -97,7 +97,7 @@ def get_menu_html(parent_information, active_information_pk): ...@@ -97,7 +97,7 @@ def get_menu_html(parent_information, active_information_pk):
items_html = [] items_html = []
for info in items: for info in items:
info_locale = InformationLocale.get_information_locale_with_fallback(info.pk) info_locale = InformationLocale.get_information_locale_with_fallback(info.pk, language)
if info.pk == int(active_information_pk): if info.pk == int(active_information_pk):
active_class = "active" active_class = "active"
title = """<span class="active">%s</span>""" % info_locale.headline title = """<span class="active">%s</span>""" % info_locale.headline
...@@ -105,7 +105,7 @@ def get_menu_html(parent_information, active_information_pk): ...@@ -105,7 +105,7 @@ def get_menu_html(parent_information, active_information_pk):
active_class = "" active_class = ""
title = link_title % (reverse('information:detail', kwargs={"information_id":info.pk}), info_locale.headline) title = link_title % (reverse('information:detail', kwargs={"information_id":info.pk}), info_locale.headline)
child_menu_html = get_menu_html(info, active_information_pk) child_menu_html = get_menu_html(info, active_information_pk, language)
# If item has no child items, create simple item # If item has no child items, create simple item
if child_menu_html == "": if child_menu_html == "":
items_html.append(simple_item_template % (active_class, title)) items_html.append(simple_item_template % (active_class, title))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment