Skip to content

Commit e238c4d

Browse files
authored
Add unit column to TabularDataset table (#20)
* Add unit column to TabularDataset table * Lint code
1 parent 02a79cd commit e238c4d

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.5 on 2025-10-06 18:53
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("datasets", "0011_rename_data_tabularitem_metadata_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="tabulardataset",
15+
name="unit",
16+
field=models.CharField(blank=True, max_length=50, null=True),
17+
),
18+
]

vbos/datasets/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class TabularDataset(models.Model):
147147
)
148148
type = models.CharField(max_length=55, choices=TYPE_CHOICES, default="baseline")
149149
source = models.CharField(max_length=155, blank=True, null=True)
150+
unit = models.CharField(max_length=50, blank=True, null=True)
150151

151152
def __str__(self):
152153
return self.name

vbos/datasets/serializers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ class TabularDatasetSerializer(serializers.ModelSerializer):
6666

6767
class Meta:
6868
model = TabularDataset
69-
fields = ["id", "name", "created", "updated", "cluster", "type", "source"]
69+
fields = [
70+
"id",
71+
"name",
72+
"created",
73+
"updated",
74+
"cluster",
75+
"type",
76+
"source",
77+
"unit",
78+
]
7079

7180

7281
class TabularItemSerializer(serializers.ModelSerializer):

vbos/datasets/test/test_tabular_views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def setUp(self):
2020
cluster=Cluster.objects.create(name="Statistics"),
2121
source="Government",
2222
type="estimated_damage",
23+
unit="Vatu (VUV)",
2324
)
2425
self.url = reverse("datasets:tabular-list")
2526

@@ -35,6 +36,7 @@ def test_tabular_datasets_list(self):
3536
assert req.data.get("results")[1]["cluster"] == "Statistics"
3637
assert req.data.get("results")[0]["type"] == "baseline"
3738
assert req.data.get("results")[1]["type"] == "estimated_damage"
39+
assert req.data.get("results")[1]["unit"] == "Vatu (VUV)"
3840

3941
def test_raster_datasets_list_filter(self):
4042
req = self.client.get(self.url, {"cluster": "transportation"})

0 commit comments

Comments
 (0)