From 8db1a387329a344ac84233e0ec7fae7bc32536b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org> Date: Fri, 31 Mar 2023 11:12:14 +0200 Subject: [PATCH] more truth-y/false-y validation --- contracts/models.py | 7 ++----- contracts/templates/contracts/index.html | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/contracts/models.py b/contracts/models.py index 1c1ca21..8dccd01 100644 --- a/contracts/models.py +++ b/contracts/models.py @@ -607,16 +607,13 @@ class Contract(NameStrMixin, models.Model): {"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( { "cost_unit_other": "Musí být definováno, pokud je vybrána jednotka nákladů 'jiné'." } ) - elif ( - self.cost_unit != self.CostUnits.OTHER[1] - and self.cost_unit_other is not None - ): + elif self.cost_unit != self.CostUnits.OTHER[1] and self.cost_unit_other: raise ValidationError( { "cost_unit_other": "Nemůže být definováno, pokud není vybrána jednotka nákladů 'jiné'." diff --git a/contracts/templates/contracts/index.html b/contracts/templates/contracts/index.html index 834f0da..be8f193 100644 --- a/contracts/templates/contracts/index.html +++ b/contracts/templates/contracts/index.html @@ -60,6 +60,7 @@ <h2 class="head-alt-md font-bold"> Všechny smlouvy </h2> + {% if request.user.can_create_contracts %} <a class="btn btn--inline-icon" -- GitLab