From e606f0de015fb745334a76b956d8c9731d1d68bf Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 6 Nov 2024 14:48:56 -0500 Subject: [PATCH] [trails] Add trail and default activity type --- .../0002_trail_default_activity_type.py | 18 +++++++++++++++ .../0003_trail_principal_type_and_more.py | 23 +++++++++++++++++++ vrobbler/apps/trails/models.py | 21 +++++++++++++---- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 vrobbler/apps/trails/migrations/0002_trail_default_activity_type.py create mode 100644 vrobbler/apps/trails/migrations/0003_trail_principal_type_and_more.py diff --git a/vrobbler/apps/trails/migrations/0002_trail_default_activity_type.py b/vrobbler/apps/trails/migrations/0002_trail_default_activity_type.py new file mode 100644 index 0000000..a024d31 --- /dev/null +++ b/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), + ), + ] diff --git a/vrobbler/apps/trails/migrations/0003_trail_principal_type_and_more.py b/vrobbler/apps/trails/migrations/0003_trail_principal_type_and_more.py new file mode 100644 index 0000000..b3c8dc4 --- /dev/null +++ b/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), + ), + ] diff --git a/vrobbler/apps/trails/models.py b/vrobbler/apps/trails/models.py index 7f15a79..8a452a6 100644 --- a/vrobbler/apps/trails/models.py +++ b/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})