Skip to content
Snippets Groups Projects
Commit 8db1a387 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

more truth-y/false-y validation

parent a4c2e079
No related branches found
No related tags found
No related merge requests found
Pipeline #12143 passed
...@@ -607,16 +607,13 @@ class Contract(NameStrMixin, models.Model): ...@@ -607,16 +607,13 @@ class Contract(NameStrMixin, models.Model):
{"cost_amount": "Nemůže být definováno bez jednoty nákladů."} {"cost_amount": "Nemůže být definováno bez jednoty nákladů."}
) )
if self.cost_unit == self.CostUnits.OTHER[1] and self.cost_unit_other is None: if self.cost_unit == self.CostUnits.OTHER[1] and not self.cost_unit_other:
raise ValidationError( raise ValidationError(
{ {
"cost_unit_other": "Musí být definováno, pokud je vybrána jednotka nákladů 'jiné'." "cost_unit_other": "Musí být definováno, pokud je vybrána jednotka nákladů 'jiné'."
} }
) )
elif ( elif self.cost_unit != self.CostUnits.OTHER[1] and self.cost_unit_other:
self.cost_unit != self.CostUnits.OTHER[1]
and self.cost_unit_other is not None
):
raise ValidationError( raise ValidationError(
{ {
"cost_unit_other": "Nemůže být definováno, pokud není vybrána jednotka nákladů 'jiné'." "cost_unit_other": "Nemůže být definováno, pokud není vybrána jednotka nákladů 'jiné'."
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
<h2 class="head-alt-md font-bold"> <h2 class="head-alt-md font-bold">
Všechny smlouvy Všechny smlouvy
</h2> </h2>
{% if request.user.can_create_contracts %} {% if request.user.can_create_contracts %}
<a <a
class="btn btn--inline-icon" class="btn btn--inline-icon"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment