[trails] Add trail and default activity type
This commit is contained in:
@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -1,4 +1,4 @@
|
|||||||
from enum import Enum
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -9,12 +9,21 @@ from locations.models import GeoLocation
|
|||||||
BNULL = {"blank": True, "null": True}
|
BNULL = {"blank": True, "null": True}
|
||||||
|
|
||||||
|
|
||||||
class TrailType(Enum):
|
|
||||||
WOODS = "Woods"
|
|
||||||
ROAD = "Road"
|
|
||||||
|
|
||||||
|
|
||||||
class Trail(ScrobblableMixin):
|
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)
|
description = models.TextField(**BNULL)
|
||||||
trailhead_location = models.ForeignKey(
|
trailhead_location = models.ForeignKey(
|
||||||
GeoLocation,
|
GeoLocation,
|
||||||
@ -30,6 +39,8 @@ class Trail(ScrobblableMixin):
|
|||||||
)
|
)
|
||||||
strava_id = models.CharField(max_length=255, **BNULL)
|
strava_id = models.CharField(max_length=255, **BNULL)
|
||||||
trailforks_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):
|
def get_absolute_url(self):
|
||||||
return reverse("trails:trail_detail", kwargs={"slug": self.uuid})
|
return reverse("trails:trail_detail", kwargs={"slug": self.uuid})
|
||||||
|
|||||||
Reference in New Issue
Block a user