Browse Source

[trails] Add trail and default activity type

Colin Powell 6 months ago
parent
commit
e606f0de01

+ 18 - 0
vrobbler/apps/trails/migrations/0002_trail_default_activity_type.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.2.16 on 2024-11-06 19:36
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('trails', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='trail',
+            name='default_activity_type',
+            field=models.CharField(blank=True, max_length=50, null=True),
+        ),
+    ]

+ 23 - 0
vrobbler/apps/trails/migrations/0003_trail_principal_type_and_more.py

@@ -0,0 +1,23 @@
+# Generated by Django 4.2.16 on 2024-11-06 19:47
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('trails', '0002_trail_default_activity_type'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='trail',
+            name='principal_type',
+            field=models.CharField(blank=True, choices=[('WOODS', 'Woods'), ('ROAD', 'Road'), ('BEACH', 'Beach'), ('MOUNTAIN', 'Mountain')], max_length=10, null=True),
+        ),
+        migrations.AlterField(
+            model_name='trail',
+            name='default_activity_type',
+            field=models.CharField(blank=True, choices=[('WALK', 'Walk'), ('HIKE', 'Hike'), ('RUN', 'Run'), ('BIKE', 'Bike')], max_length=10, null=True),
+        ),
+    ]

+ 16 - 5
vrobbler/apps/trails/models.py

@@ -1,4 +1,4 @@
-from enum import Enum
+from django.utils.translation import gettext_lazy as _
 from django.apps import apps
 from django.db import models
 from django.urls import reverse
@@ -9,12 +9,21 @@ from locations.models import GeoLocation
 BNULL = {"blank": True, "null": True}
 
 
-class TrailType(Enum):
-    WOODS = "Woods"
-    ROAD = "Road"
-
 
 class Trail(ScrobblableMixin):
+
+    class PrincipalType(models.TextChoices):
+        WOODS = "WOODS"
+        ROAD = "ROAD"
+        BEACH = "BEACH"
+        MOUNTAIN = "MOUNTAIN"
+
+    class ActivityType(models.TextChoices):
+        WALK= "WALK"
+        HIKE = "HIKE"
+        RUN = "RUN"
+        BIKE = "BIKE"
+
     description = models.TextField(**BNULL)
     trailhead_location = models.ForeignKey(
         GeoLocation,
@@ -30,6 +39,8 @@ class Trail(ScrobblableMixin):
     )
     strava_id = models.CharField(max_length=255, **BNULL)
     trailforks_id = models.CharField(max_length=255, **BNULL)
+    principal_type = models.CharField(max_length=10, choices=PrincipalType.choices, **BNULL)
+    default_activity_type = models.CharField(max_length=10, choices=ActivityType.choices, **BNULL)
 
     def get_absolute_url(self):
         return reverse("trails:trail_detail", kwargs={"slug": self.uuid})