Skip to content

Commit

Permalink
Foutmelding na invullen foutieve datum in energiecontract #1283
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Feb 11, 2021
1 parent 06ae527 commit c573981
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ v4.12.0 - 2021-xx-xx

- ``Fixed``: Translations - by @denvers [`#1260 <https://github.com/dsmrreader/dsmr-reader/issues/1260>`_]
- ``Fixed``: Bij update controleren op lokale openstaande wijzigingen [`#1259 <https://github.com/dsmrreader/dsmr-reader/issues/1259>`_]
- ``Fixed``: Foutmelding na invullen foutieve datum in energiecontract [`#1283 <https://github.com/dsmrreader/dsmr-reader/issues/1283>`_]


v4.11.0 - 2021-01-17
Expand Down
3 changes: 3 additions & 0 deletions dsmr_consumption/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def _validate_price_defined_for_range(self, field_name):
current_start = self.cleaned_data.get('start')
current_end = self.cleaned_data.get('end')

if current_start is None or current_end is None:
raise forms.ValidationError(_('Please fix contract start/end first'))

existing_contracts = EnergySupplierPrice.objects.exclude(
# Not do block ourselves.
pk=self.instance.pk
Expand Down
13 changes: 13 additions & 0 deletions dsmr_consumption/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ def test_add_esp_merged(self):
))
self.client.post(self.url, data=self.data)
self.assertTrue(EnergySupplierPrice.objects.filter(description=self.ESP_TEXT).exists())

def test_add_esp_invalid_date(self):
""" This used to crash first. """
self.assertEqual(EnergySupplierPrice.objects.all().count(), 1)
self.data.update(dict(
start='invalid',
end='2020-01-01',
gas_price=1,
))
self.client.post(self.url, data=self.data)

# Unchanged
self.assertEqual(EnergySupplierPrice.objects.all().count(), 1)
Binary file modified dsmrreader/locales/nl/LC_MESSAGES/django.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions dsmrreader/locales/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ msgstr "Verbruik"
msgid "Too many unprocessed readings: {}"
msgstr "Te veel onverwerkte telegrammen: {}"

msgid "Please fix contract start/end first"
msgstr "Vul eerst een correcte start-/einddatum in voor het contract"

msgid "This price is already set by another contract within a colliding date range ({} / {}): {}"
msgstr "Deze prijs is al ingesteld bij een ander contract met een overlappende contractdatum: {} ({} - {})"

Expand Down

0 comments on commit c573981

Please sign in to comment.