diff --git a/README.md b/README.md index 7cb7e87d6..91153f032 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build Status](https://travis-ci.org/dennissiemensma/dsmr-reader.svg?branch=master)](https://travis-ci.org/dennissiemensma/dsmr-reader) [![Coverage](https://codecov.io/github/dennissiemensma/dsmr-reader/coverage.svg?branch=master)](https://codecov.io/github/dennissiemensma/dsmr-reader?branch=master) [![Requirements Status](https://requires.io/github/dennissiemensma/dsmr-reader/requirements.svg?branch=master)](https://requires.io/github/dennissiemensma/dsmr-reader/requirements/?branch=master) -[![Documentation Status](http://readthedocs.org/projects/dsmr-reader/badge/?version=latest)](http://dsmr-reader.readthedocs.org/en/latest/?badge=latest) +[![Documentation Status](http://readthedocs.org/projects/dsmr-reader/badge/?version=latest)](http://dsmr-reader.readthedocs.io/en/latest/?badge=latest) # About @@ -12,15 +12,15 @@ There are plenty of ‘scripts’ and websites available for performing DSMR rea **English** -See [Read The Docs, in English](http://dsmr-reader.readthedocs.org/en/latest/). Installation guide can be found there as well. +See [Read The Docs, in English](http://dsmr-reader.readthedocs.io/en/latest/). Installation guide can be found there as well. **Dutch / Nederlands** -Zie [Read The Docs, in het Nederlands](http://dsmr-reader.readthedocs.org/nl/latest/). Je kunt daar ook alle installatieinstructies vinden. +Zie [Read The Docs, in het Nederlands](http://dsmr-reader.readthedocs.io/nl/latest/). Je kunt daar ook alle installatieinstructies vinden. # Screenshots -More screenshots can be found in the documentation at [Read The Docs](http://dsmr-reader.readthedocs.org/en/latest/screenshots.html). +More screenshots can be found in the documentation at [Read The Docs](http://dsmr-reader.readthedocs.io/en/latest/screenshots.html). ## Dashboard ![Dashboard](docs/_static/screenshots/dashboard.png) diff --git a/dsmr_frontend/templates/dsmr_frontend/base.html b/dsmr_frontend/templates/dsmr_frontend/base.html index c31d3179c..cf4ffb877 100644 --- a/dsmr_frontend/templates/dsmr_frontend/base.html +++ b/dsmr_frontend/templates/dsmr_frontend/base.html @@ -59,7 +59,7 @@ {% block header_right %}{% endblock %}
  • - + v{{ dsmr_version }}
  • diff --git a/dsmr_frontend/templates/dsmr_frontend/status.html b/dsmr_frontend/templates/dsmr_frontend/status.html index 6bca65549..b2d610a12 100644 --- a/dsmr_frontend/templates/dsmr_frontend/status.html +++ b/dsmr_frontend/templates/dsmr_frontend/status.html @@ -25,11 +25,11 @@ - + - +
    {% trans "Current version" %} {% trans "DSMR-reader" %}v{{ dsmr_version }}v{{ dsmr_version }}
    {% trans "Changelog" %}{% trans 'View all releases' %}{% trans 'View all releases' %}
    diff --git a/dsmr_stats/services.py b/dsmr_stats/services.py index a0f75911c..773f66779 100644 --- a/dsmr_stats/services.py +++ b/dsmr_stats/services.py @@ -147,6 +147,11 @@ def electricity_tariff_percentage(start_date): electricity1=Sum('electricity1'), electricity2=Sum('electricity2'), ) + + # Empty data will crash. + if not all(totals.values()): + return None + global_total = totals['electricity1'] + totals['electricity2'] totals['electricity1'] = math.ceil(totals['electricity1'] / global_total * 100) totals['electricity2'] = 100 - totals['electricity1'] diff --git a/dsmr_stats/tests/test_services.py b/dsmr_stats/tests/test_services.py index 0ac0080a7..4b16cca8a 100644 --- a/dsmr_stats/tests/test_services.py +++ b/dsmr_stats/tests/test_services.py @@ -296,6 +296,10 @@ def test_electricity_tariff_percentage(self): self.assertEqual(percentages['electricity1'], 25) self.assertEqual(percentages['electricity2'], 75) + # Now try again without data. + DayStatistics.objects.all().delete() + percentages = dsmr_stats.services.electricity_tariff_percentage(start_date=target_date.date()) + class TestServicesWithoutGas(TestServices): fixtures = ['dsmr_stats/electricity-consumption.json']