diff --git a/donate/forms.py b/donate/forms.py index de9f6f1688dba03ac30ff0e17d44a7c1279b4153..67e731269f9c80a148f680da4f1256445727bad8 100644 --- a/donate/forms.py +++ b/donate/forms.py @@ -22,6 +22,15 @@ class DonateForm(forms.Form): raise forms.ValidationError("Wrong periodicity!") return value + def clean(self): + cleaned_data = super().clean() + if ( + cleaned_data["portal_project_id"] == self.PORTAL_ID_IN_SELECT + and cleaned_data["select_portal_project_id"] is None + ): + raise forms.ValidationError("Není zadán účel daru.") + return cleaned_data + def get_amount(self): amount = self.cleaned_data["amount"] if amount == self.CUSTOM_AMOUNT: diff --git a/donate/static/donate/assets/js/scripts.js b/donate/static/donate/assets/js/scripts.js index e6dce2a1dac3fc431d9857c6187db63ac8c742e8..49e387bb1d8d8eecc973567960dd04a814aa93e4 100644 --- a/donate/static/donate/assets/js/scripts.js +++ b/donate/static/donate/assets/js/scripts.js @@ -92,7 +92,7 @@ }); $("#other_target_select").change(function () { - if ($(this).val() !== "-") { + if ($(this).val() !== "") { $("#other_target").prop("checked", true); updateLink($(this).val()); } diff --git a/donate/templates/donate/donate_targeted_donations_page.html b/donate/templates/donate/donate_targeted_donations_page.html index e5fe9ba5eca5c33d1dcbcf28f27da6ad9f137744..b4464a2c990671914c344232e91fc70c63f0eea6 100644 --- a/donate/templates/donate/donate_targeted_donations_page.html +++ b/donate/templates/donate/donate_targeted_donations_page.html @@ -37,7 +37,7 @@ <label class="custom-control-label col-form-label-lg custom-control-label-for-select" for="other_target"> Dar pro: <select id="other_target_select" name="select_portal_project_id" class="custom-control-select"> - <option value="-">--- vybrat ---</option> + <option value="">--- vybrat ---</option> {% for target in other_targets %} <option value="{{ target.portal_project_id }}">{{ target.title }}</option> {% endfor %}