Skip to content

Commit fe6aa6d

Browse files
committed
Ensure percentage_kcals is not negative - see HEA-572
1 parent a5d30a3 commit fe6aa6d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 5.1.1 on 2024-11-22 03:51
2+
3+
import django.core.validators
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("baseline", "0016_alter_livelihoodstrategy_additional_identifier_and_more"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="livelihoodactivity",
16+
name="percentage_kcals",
17+
field=models.FloatField(
18+
blank=True,
19+
help_text="Percentage of annual household kcal requirement provided by this livelihood strategy",
20+
null=True,
21+
validators=[django.core.validators.MinValueValidator(0)],
22+
verbose_name="Percentage of required kcals",
23+
),
24+
),
25+
]

apps/baseline/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ class LivelihoodActivity(common_models.Model):
11251125
percentage_kcals = models.FloatField(
11261126
blank=True,
11271127
null=True,
1128+
validators=[MinValueValidator(0)],
11281129
verbose_name=_("Percentage of required kcals"),
11291130
help_text=_("Percentage of annual household kcal requirement provided by this livelihood strategy"),
11301131
)

0 commit comments

Comments
 (0)