diff --git a/forecasts/admin.py b/forecasts/admin.py index 5e79b15998694eef038947471006c68f69b05e37..07dd750edf8bbec0b7744f281032e3751e5581fc 100644 --- a/forecasts/admin.py +++ b/forecasts/admin.py @@ -16,11 +16,17 @@ # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # from django.contrib import admin -from forecasts.models import ResultParameter, MeasurementUnit, ModelGraphParameter, HighChartsType +from forecasts.models import ResultParameter, ResultParameterLocal, MeasurementUnit, ModelGraphParameter, HighChartsType + +class ResultParameterLocalAdminInline(admin.StackedInline): + model = ResultParameterLocal + extra = 2 + fields = ['language_code', 'local_name'] class ResultParameterAdmin(admin.ModelAdmin): list_display = ['namespace','key','name'] list_filter = ['namespace'] + inlines = [ResultParameterLocalAdminInline] admin.site.register(ResultParameter,ResultParameterAdmin) diff --git a/forecasts/locale/bg/LC_MESSAGES/django.mo b/forecasts/locale/bg/LC_MESSAGES/django.mo index 504d1207954e450e8ffdde7e41963e2dc8c00267..7a03c59b2e08fad6f08c00edd2bd931696e2b4f6 100644 Binary files a/forecasts/locale/bg/LC_MESSAGES/django.mo and b/forecasts/locale/bg/LC_MESSAGES/django.mo differ diff --git a/forecasts/locale/bg/LC_MESSAGES/django.po b/forecasts/locale/bg/LC_MESSAGES/django.po index d729573b4fdbf721f2bb8d9bc1034b1b7f1c8118..229a61dc2dc7ad24a54ddedb9e54111be020e4fb 100644 --- a/forecasts/locale/bg/LC_MESSAGES/django.po +++ b/forecasts/locale/bg/LC_MESSAGES/django.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: VIPS BG\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-26 14:27+0100\n" +"POT-Creation-Date: 2016-03-31 14:50+0200\n" "PO-Revision-Date: 2014-05-14 09:37+0200\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -30,58 +30,112 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 1.6.5\n" +#: models.py:496 +msgid "Language code" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:1 +msgid "Percent" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:2 +msgid "Number" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:3 +msgid "Aggregated day degrees" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:4 +msgid "Degrees Celcius" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:5 +msgid "Hours" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:6 +msgid "Millimeters" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:7 +msgid "Minutes" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:8 +msgid "Minutes/day" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:9 +msgid "Minutes/hour" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:10 +#, fuzzy +#| msgid "Timestamp" +msgid "Time" +msgstr "Единица за време" + +#: templates/forecasts/bogus_translation_template.html:11 +msgid "Watt/square meter" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:12 +msgid "Yes or no" +msgstr "" + #: templates/forecasts/detail.html:25 templates/forecasts/detail.html.py:27 #: templates/forecasts/detail_error.html:25 msgid "Details" msgstr "Подробности" -#: templates/forecasts/detail.html:39 +#: templates/forecasts/detail.html:38 msgid "Model" msgstr "Модел" -#: templates/forecasts/detail.html:40 templates/forecasts/index.html:55 +#: templates/forecasts/detail.html:39 templates/forecasts/index.html:55 #: templates/forecasts/index.html.py:76 msgid "Location" msgstr "Място" -#: templates/forecasts/detail.html:41 templates/forecasts/index.html:54 +#: templates/forecasts/detail.html:40 templates/forecasts/index.html:54 #: templates/forecasts/index.html.py:75 msgid "Weather station" msgstr "Климатична станция" -#: templates/forecasts/detail.html:41 +#: templates/forecasts/detail.html:40 msgid "Distance to location" msgstr "Разстояние до мястото" -#: templates/forecasts/detail.html:42 +#: templates/forecasts/detail.html:41 msgid "Period" msgstr "Период" -#: templates/forecasts/detail.html:46 +#: templates/forecasts/detail.html:45 msgid "Showing latest" msgstr "" -#: templates/forecasts/detail.html:48 +#: templates/forecasts/detail.html:47 msgid "Days" msgstr "" -#: templates/forecasts/detail.html:49 +#: templates/forecasts/detail.html:48 msgid "Change" msgstr "" -#: templates/forecasts/detail.html:57 +#: templates/forecasts/detail.html:56 msgid "Scroll past chart by swiping the dotted line on the right" msgstr "" -#: templates/forecasts/detail.html:69 +#: templates/forecasts/detail.html:68 msgid "Timestamp" msgstr "Единица за време" -#: templates/forecasts/detail.html:70 +#: templates/forecasts/detail.html:69 msgid "Warning status" msgstr "Вид предупреждение" -#: templates/forecasts/detail.html:90 +#: templates/forecasts/detail.html:89 msgid "No results for this forecast" msgstr "Няма резултати за тази прогноза" @@ -147,24 +201,24 @@ msgstr "" msgid "Select model" msgstr "" -#: templates/models/detail.html:22 templates/models/index.html:22 -#: templates/models/index.html.py:24 +#: templates/models/detail.html:22 templates/models/detail_test.html:22 +#: templates/models/index.html:22 templates/models/index.html.py:24 msgid "Models" msgstr "Модели" -#: templates/models/detail.html:28 +#: templates/models/detail.html:28 templates/models/detail_test.html:28 msgid "Description" msgstr "Описание" -#: templates/models/detail.html:29 +#: templates/models/detail.html:29 templates/models/detail_test.html:29 msgid "Interpretation of warning status" msgstr "" -#: templates/models/detail.html:30 +#: templates/models/detail.html:30 templates/models/detail_test.html:30 msgid "Technical usage" msgstr "" -#: templates/models/detail.html:31 +#: templates/models/detail.html:31 templates/models/detail_test.html:31 msgid "Sample configuration" msgstr "Конфигурация на пробата" diff --git a/forecasts/locale/bs/LC_MESSAGES/django.mo b/forecasts/locale/bs/LC_MESSAGES/django.mo index ccf4b3ed342bc48337b6bedd47ee3135c3b3739a..8dc7545de5444fbdc7e436b14cd7f83e68b66978 100644 Binary files a/forecasts/locale/bs/LC_MESSAGES/django.mo and b/forecasts/locale/bs/LC_MESSAGES/django.mo differ diff --git a/forecasts/locale/bs/LC_MESSAGES/django.po b/forecasts/locale/bs/LC_MESSAGES/django.po index 338cf83a8fa05b391429ccace9aa13ba5e7b6e5e..dd3f1162c1193533c3c8f6679c9f87b60afba368 100644 --- a/forecasts/locale/bs/LC_MESSAGES/django.po +++ b/forecasts/locale/bs/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: VIPS\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-26 14:27+0100\n" +"POT-Creation-Date: 2016-03-31 14:50+0200\n" "PO-Revision-Date: 2015-02-13 11:10+0100\n" "Last-Translator: Mladen Cucak <mladencucak@gmail.com>\n" "Language-Team: LANGUAGE <wvjeko@gmail.com>\n" @@ -20,58 +20,112 @@ msgstr "" "X-Generator: Poedit 1.7.4\n" "X-Poedit-SourceCharset: UTF-8\n" +#: models.py:496 +msgid "Language code" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:1 +msgid "Percent" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:2 +msgid "Number" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:3 +msgid "Aggregated day degrees" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:4 +msgid "Degrees Celcius" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:5 +msgid "Hours" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:6 +msgid "Millimeters" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:7 +msgid "Minutes" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:8 +msgid "Minutes/day" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:9 +msgid "Minutes/hour" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:10 +#, fuzzy +#| msgid "Timestamp" +msgid "Time" +msgstr "Tačno vrijeme " + +#: templates/forecasts/bogus_translation_template.html:11 +msgid "Watt/square meter" +msgstr "" + +#: templates/forecasts/bogus_translation_template.html:12 +msgid "Yes or no" +msgstr "" + #: templates/forecasts/detail.html:25 templates/forecasts/detail.html.py:27 #: templates/forecasts/detail_error.html:25 msgid "Details" msgstr "Detalji" -#: templates/forecasts/detail.html:39 +#: templates/forecasts/detail.html:38 msgid "Model" msgstr "Model" -#: templates/forecasts/detail.html:40 templates/forecasts/index.html:55 +#: templates/forecasts/detail.html:39 templates/forecasts/index.html:55 #: templates/forecasts/index.html.py:76 msgid "Location" msgstr "Lokacija" -#: templates/forecasts/detail.html:41 templates/forecasts/index.html:54 +#: templates/forecasts/detail.html:40 templates/forecasts/index.html:54 #: templates/forecasts/index.html.py:75 msgid "Weather station" msgstr "Meteo stanica" -#: templates/forecasts/detail.html:41 +#: templates/forecasts/detail.html:40 msgid "Distance to location" msgstr "Udaljenost od lokacije" -#: templates/forecasts/detail.html:42 +#: templates/forecasts/detail.html:41 msgid "Period" msgstr "Razdoblje " -#: templates/forecasts/detail.html:46 +#: templates/forecasts/detail.html:45 msgid "Showing latest" msgstr "Prikazuje najnovije" -#: templates/forecasts/detail.html:48 +#: templates/forecasts/detail.html:47 msgid "Days" msgstr "Dana" -#: templates/forecasts/detail.html:49 +#: templates/forecasts/detail.html:48 msgid "Change" msgstr "Izmijeni" -#: templates/forecasts/detail.html:57 +#: templates/forecasts/detail.html:56 msgid "Scroll past chart by swiping the dotted line on the right" msgstr "" -#: templates/forecasts/detail.html:69 +#: templates/forecasts/detail.html:68 msgid "Timestamp" msgstr "Tačno vrijeme " -#: templates/forecasts/detail.html:70 +#: templates/forecasts/detail.html:69 msgid "Warning status" msgstr "Status upozorenja" -#: templates/forecasts/detail.html:90 +#: templates/forecasts/detail.html:89 msgid "No results for this forecast" msgstr "Nema rezultata za ovu prognozu" @@ -137,24 +191,24 @@ msgstr "" msgid "Select model" msgstr "" -#: templates/models/detail.html:22 templates/models/index.html:22 -#: templates/models/index.html.py:24 +#: templates/models/detail.html:22 templates/models/detail_test.html:22 +#: templates/models/index.html:22 templates/models/index.html.py:24 msgid "Models" msgstr "Modeli" -#: templates/models/detail.html:28 +#: templates/models/detail.html:28 templates/models/detail_test.html:28 msgid "Description" msgstr "Opis" -#: templates/models/detail.html:29 +#: templates/models/detail.html:29 templates/models/detail_test.html:29 msgid "Interpretation of warning status" msgstr "" -#: templates/models/detail.html:30 +#: templates/models/detail.html:30 templates/models/detail_test.html:30 msgid "Technical usage" msgstr "" -#: templates/models/detail.html:31 +#: templates/models/detail.html:31 templates/models/detail_test.html:31 msgid "Sample configuration" msgstr "Primjer konfiguracije " diff --git a/forecasts/locale/nb/LC_MESSAGES/django.mo b/forecasts/locale/nb/LC_MESSAGES/django.mo index 7490cf591d74a011971be1c0b40d1af2f97068dc..68f7177ef7122143db3d9f70204b869138f8b37a 100644 Binary files a/forecasts/locale/nb/LC_MESSAGES/django.mo and b/forecasts/locale/nb/LC_MESSAGES/django.mo differ diff --git a/forecasts/locale/nb/LC_MESSAGES/django.po b/forecasts/locale/nb/LC_MESSAGES/django.po index b38c7d034f3fba3f7d4820532b3555932d7c4b10..52cbacb106fdb99fc94dca386831a855df288555 100644 --- a/forecasts/locale/nb/LC_MESSAGES/django.po +++ b/forecasts/locale/nb/LC_MESSAGES/django.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-26 14:27+0100\n" +"POT-Creation-Date: 2016-03-31 14:50+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -31,61 +31,113 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: models.py:496 +msgid "Language code" +msgstr "Språkkode" + +#: templates/forecasts/bogus_translation_template.html:1 +msgid "Percent" +msgstr "Prosent" + +#: templates/forecasts/bogus_translation_template.html:2 +msgid "Number" +msgstr "Antall" + +#: templates/forecasts/bogus_translation_template.html:3 +msgid "Aggregated day degrees" +msgstr "Aggregerte døgngrader" + +#: templates/forecasts/bogus_translation_template.html:4 +msgid "Degrees Celcius" +msgstr "Grader Celcius" + +#: templates/forecasts/bogus_translation_template.html:5 +msgid "Hours" +msgstr "Timer" + +#: templates/forecasts/bogus_translation_template.html:6 +msgid "Millimeters" +msgstr "Millimeter" + +#: templates/forecasts/bogus_translation_template.html:7 +msgid "Minutes" +msgstr "Minutter" + +#: templates/forecasts/bogus_translation_template.html:8 +msgid "Minutes/day" +msgstr "Minutter/dag" + +#: templates/forecasts/bogus_translation_template.html:9 +msgid "Minutes/hour" +msgstr "Minutter/time" + +#: templates/forecasts/bogus_translation_template.html:10 +msgid "Time" +msgstr "Tidspunkt" + +#: templates/forecasts/bogus_translation_template.html:11 +msgid "Watt/square meter" +msgstr "Watt/kvadratmeter" + +#: templates/forecasts/bogus_translation_template.html:12 +msgid "Yes or no" +msgstr "Ja/nei" + #: templates/forecasts/detail.html:25 #: templates/forecasts/detail.html.py:27 #: templates/forecasts/detail_error.html:25 msgid "Details" msgstr "Detaljer" -#: templates/forecasts/detail.html:39 +#: templates/forecasts/detail.html:38 msgid "Model" msgstr "Modell" -#: templates/forecasts/detail.html:40 +#: templates/forecasts/detail.html:39 #: templates/forecasts/index.html:55 #: templates/forecasts/index.html.py:76 msgid "Location" msgstr "Plassering" -#: templates/forecasts/detail.html:41 +#: templates/forecasts/detail.html:40 #: templates/forecasts/index.html:54 #: templates/forecasts/index.html.py:75 msgid "Weather station" msgstr "Målestasjon" -#: templates/forecasts/detail.html:41 +#: templates/forecasts/detail.html:40 msgid "Distance to location" msgstr "Avstand til plassering" -#: templates/forecasts/detail.html:42 +#: templates/forecasts/detail.html:41 msgid "Period" msgstr "Periode" -#: templates/forecasts/detail.html:46 +#: templates/forecasts/detail.html:45 msgid "Showing latest" msgstr "Viser siste" -#: templates/forecasts/detail.html:48 +#: templates/forecasts/detail.html:47 msgid "Days" msgstr "Dager" -#: templates/forecasts/detail.html:49 +#: templates/forecasts/detail.html:48 msgid "Change" msgstr "Endre" -#: templates/forecasts/detail.html:57 +#: templates/forecasts/detail.html:56 msgid "Scroll past chart by swiping the dotted line on the right" msgstr "Bla forbi diagrammet ved å dra i den prikkete linjen til høyre" -#: templates/forecasts/detail.html:69 +#: templates/forecasts/detail.html:68 msgid "Timestamp" msgstr "Tidspunkt" -#: templates/forecasts/detail.html:70 +#: templates/forecasts/detail.html:69 msgid "Warning status" msgstr "Varselstatus" -#: templates/forecasts/detail.html:90 +#: templates/forecasts/detail.html:89 msgid "No results for this forecast" msgstr "Ingen resultater for dette varselet" @@ -157,24 +209,29 @@ msgid "Select model" msgstr "Velg modell" #: templates/models/detail.html:22 +#: templates/models/detail_test.html:22 #: templates/models/index.html:22 #: templates/models/index.html.py:24 msgid "Models" msgstr "Modeller" #: templates/models/detail.html:28 +#: templates/models/detail_test.html:28 msgid "Description" msgstr "Beskrivelse" #: templates/models/detail.html:29 +#: templates/models/detail_test.html:29 msgid "Interpretation of warning status" msgstr "Tolkning av varselstatus" #: templates/models/detail.html:30 +#: templates/models/detail_test.html:30 msgid "Technical usage" msgstr "Teknisk bruksanvisning" #: templates/models/detail.html:31 +#: templates/models/detail_test.html:31 msgid "Sample configuration" msgstr "Eksempelkonfigurasjon" diff --git a/forecasts/models.py b/forecasts/models.py index f006666bdac7d6d8e805de3d83876144e1b14f4f..670a0166361c0f09f27665c6a93bf315388dadd6 100644 --- a/forecasts/models.py +++ b/forecasts/models.py @@ -23,6 +23,7 @@ import requests import json from decimal import Decimal, InvalidOperation +from django.utils.translation import ugettext as _ from django.conf import settings from django.db import models from django.utils import translation @@ -126,8 +127,14 @@ class ForecastResult: # Setting up all parallel time series for model_graph_result_parameter in model_graph_result_parameters: result_parameter = model_graph_result_parameter.resultparameter + result_parameter_local_set = ResultParameterLocal.objects.filter(result_parameter_id=result_parameter.id) + if len(result_parameter_local_set) > 0: + for language_code in [translation.get_language(), settings.LANGUAGE_CODE,'en']: + for result_parameter_local in result_parameter_local_set: + if result_parameter_local.language_code == language_code: + result_parameter.set_local_name(result_parameter_local.local_name) result_parameter_timeseries = {} - result_parameter_timeseries["name"] = result_parameter.name + result_parameter_timeseries["name"] = result_parameter.get_local_name result_parameter_timeseries["type"] = model_graph_result_parameter.highcharts_type.name result_parameter_timeseries["data"] = [] @@ -423,10 +430,10 @@ def get_y_axis_for_parameter(result_parameter, axis_list): measurement_unit = MeasurementUnit.objects.filter(name="Number")[0] # Does it exist in axis_list? for index,axis in enumerate(axis_list): - if(axis["title"] == measurement_unit.name): + if(axis["title"] == _(measurement_unit.name)): return index # If not, add to axis_list - y_axis = {"title":measurement_unit.name, "abbr":measurement_unit.abbr,"color":measurement_unit.color_hexcode,"opposite":measurement_unit.opposite} + y_axis = {"title":_(measurement_unit.name), "abbr":measurement_unit.abbr,"color":measurement_unit.color_hexcode,"opposite":measurement_unit.opposite} axis_list.append(y_axis) # Return axis index return len(axis_list) - 1 @@ -458,6 +465,8 @@ class ResultParameter(models.Model): name = models.CharField(max_length=200) description = models.TextField() measurementunit = models.ForeignKey(MeasurementUnit) + local_name = None + def getNamespaceKey(self): return self.namespace + "." + self.key @@ -467,6 +476,24 @@ class ResultParameter(models.Model): class Meta: ordering = ['key'] + + + def set_local_name(self, local_name): + self.local_name = local_name + + @property + def get_local_name(self): + if self.local_name != None: + return self.local_name + else: + return self.name + + + +class ResultParameterLocal(models.Model): + result_parameter = models.ForeignKey(ResultParameter) + local_name = models.CharField(max_length=200) + language_code = models.CharField(max_length=2, verbose_name=_("Language code")) def validate_model_id_length(value): if len(value) != 10: diff --git a/forecasts/templates/forecasts/bogus_translation_template.html b/forecasts/templates/forecasts/bogus_translation_template.html new file mode 100644 index 0000000000000000000000000000000000000000..d0907c3b058ce44d2639cc54d4f74012410a934e --- /dev/null +++ b/forecasts/templates/forecasts/bogus_translation_template.html @@ -0,0 +1,13 @@ +{% trans "Percent" %} +{% trans "Number" %} +{% trans "Aggregated day degrees" %} +{% trans "Degrees Celcius" %} +{% trans "Hours" %} +{% trans "Millimeters" %} +{% trans "Minutes" %} +{% trans "Minutes/day" %} +{% trans "Minutes/hour" %} +{% trans "Time" %} +{% trans "Watt/square meter" %} +{% trans "Yes or no" %} + diff --git a/forecasts/templates/forecasts/detail.html b/forecasts/templates/forecasts/detail.html index 1dcece248cf0b04cbc324e9db01913796937e1b9..2a8998dfee20a5d521738132b143291f513d64d8 100644 --- a/forecasts/templates/forecasts/detail.html +++ b/forecasts/templates/forecasts/detail.html @@ -30,8 +30,7 @@ {% localize off %} <iframe width="300" height="200" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox={{forecast_configuration.location_point_of_interest.longitude| addfloat:-0.037722588}}%2C{{forecast_configuration.location_point_of_interest.latitude|addfloat:-0.016374048}}%2C{{forecast_configuration.location_point_of_interest.longitude|addfloat:0.037722588}}%2C{{forecast_configuration.location_point_of_interest.latitude|addfloat:0.016374048}}&layer=mapnik&marker={{forecast_configuration.location_point_of_interest.latitude}}%2C{{forecast_configuration.location_point_of_interest.longitude}}" - style="border: 1px solid black;"></iframe><br/> - <a href="http://www.openstreetmap.org/?mlat={{ forecast_configuration.location_point_of_interest.latitude }}&mlon={{ forecast_configuration.location_point_of_interest.longitude }}#map=14/{{ forecast_configuration.point_of_interest.latitude }}/{{ forecast_configuration.point_of_interest.longitude }}&layers=N" target="new">Full screen view</a> + style="border: 1px solid black;"></iframe> {% endlocalize %} </div> <div class="col-md-8"> @@ -69,7 +68,7 @@ <th>{% trans "Timestamp" %}</th> <th>{% trans "Warning status" %}</th> {% for result_parameter in result_parameters %} - <th>{{ result_parameter.name }} ({{result_parameter.key}})</th> + <th>{{ result_parameter.get_local_name }} ({{result_parameter.key}})</th> {% endfor %} </tr> </thead> @@ -89,6 +88,7 @@ {% else %} <div class="alert alert-info">{% trans "No results for this forecast" %}</div> {% endif %} + {% endblock %} {% block customJS %} <script type="text/javascript" src="{% url "views.settings_js" %}"></script> diff --git a/forecasts/templatetags/forecast_extras.py b/forecasts/templatetags/forecast_extras.py index 9846f50a63680b15dc4cebbd850f88a7d7c16196..69bbb2747ae378680db0978aede2d302f9992661 100644 --- a/forecasts/templatetags/forecast_extras.py +++ b/forecasts/templatetags/forecast_extras.py @@ -37,3 +37,7 @@ def addfloat(value, arg): def distanceto(valuePOI, argPOI): return valuePOI.distance_to(argPOI) +@register.filter(name="result_parameter_local_name") +def get_result_parameter_local_name(result_parameter_local_set, language_code): + return result_parameter.get_local_name(language_code) + diff --git a/forecasts/views.py b/forecasts/views.py index 30bcde9ba41d1c9081432aeaf60592adc2b2c0ba..66a1d7ef7968a9073eabf35e8240540d49615522 100644 --- a/forecasts/views.py +++ b/forecasts/views.py @@ -20,8 +20,10 @@ from django.http import HttpResponse from django.shortcuts import render +from django.conf import settings +from django.utils import translation -from forecasts.models import ForecastConfiguration, ForecastResult, ResultParameter, Model, MeasurementUnit, ModelGraphParameter +from forecasts.models import ForecastConfiguration, ForecastResult, ResultParameter, ResultParameterLocal, Model, MeasurementUnit, ModelGraphParameter def index(request): forecast_configurations = ForecastConfiguration.get_forecast_configurations_from_vipslogic(None).text @@ -54,7 +56,16 @@ def detail_latest_days(request, forecast_id, latest_days): if key not in all_result_keys: all_result_keys.append(key) inStr = "'" + "','".join(all_result_keys) + "'" - result_parameters = ResultParameter.objects.raw("SELECT * FROM forecasts_resultparameter WHERE namespace || '.' || key IN (%s)" % inStr) + result_parameters_temp = ResultParameter.objects.raw("SELECT * FROM forecasts_resultparameter WHERE namespace || '.' || key IN (%s)" % inStr) + result_parameters = [] + for p in result_parameters_temp: + result_parameter_local_set = ResultParameterLocal.objects.filter(result_parameter_id=p.id) + if len(result_parameter_local_set) > 0: + for language_code in [translation.get_language(), settings.LANGUAGE_CODE,'en']: + for result_parameter_local in result_parameter_local_set: + if result_parameter_local.language_code == language_code: + p.set_local_name(result_parameter_local.local_name) + result_parameters.append(p) context = { 'forecast_configuration': forecast_configuration, diff --git a/vips_messages/migrations/0003_auto_20160331_1121.py b/vips_messages/migrations/0003_auto_20160331_1121.py new file mode 100644 index 0000000000000000000000000000000000000000..fe4b18a77db9027da484b06d3914b377646df639 --- /dev/null +++ b/vips_messages/migrations/0003_auto_20160331_1121.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('vips_messages', '0002_auto_20160303_1002'), + ] + + operations = [ + migrations.AlterField( + model_name='advertisement', + name='illustration', + field=models.ImageField(upload_to=b'images/advertisement', verbose_name='Illustrasjon', blank=True), + ), + ]