X-Git-Url: https://code.kerkeslager.com/?p=climbing.kerkeslager.com;a=blobdiff_plain;f=src%2Fclimbing%2Fmodels.py;fp=src%2Fclimbing%2Fmodels.py;h=69bbc9ff6a6ea68ee05b873e699238c5cfc46c03;hp=67befd7c7f3923016c43a9d93019cd11f5a42cf4;hb=c56fa7cca05d791db6bdb62d47e72680747a7961;hpb=d468d2cb0b98abf93a52cc28e48683bb92c7bbb1 diff --git a/src/climbing/models.py b/src/climbing/models.py index 67befd7..69bbc9f 100644 --- a/src/climbing/models.py +++ b/src/climbing/models.py @@ -109,13 +109,12 @@ class RouteDifficulty(models.IntegerChoices): YDS_5_15c = 37, '5.15c' YDS_5_15d = 38, '5.15d' -SAFETY_CHOICES = ( - ('G', 'G'), - ('PG', 'PG'), - ('PG13', 'PG13'), - ('R', 'R'), - ('X', 'X'), -) +class Safety(models.IntegerChoices): + G = 0, 'G' + PG = 1, 'PG' + PG13 = 2, 'PG13' + R = 3, 'R' + X = 4, 'X' class Pitch(models.Model): route = models.ForeignKey( @@ -125,7 +124,7 @@ class Pitch(models.Model): ) name = models.CharField(max_length=64, blank=True, null=True) difficulty = models.PositiveIntegerField(choices=RouteDifficulty.choices) - safety = models.CharField(max_length=4, choices=SAFETY_CHOICES) + safety = models.IntegerField(choices=Safety.choices) notes = models.TextField(blank=True, null=True) class Meta: @@ -160,26 +159,26 @@ class Boulder(models.Model): def __str__(self): return self.name -BOULDER_DIFFICULTY_CHOICES = ( - ('V0', 'V0'), - ('V1', 'V1'), - ('V2', 'V2'), - ('V3', 'V3'), - ('V4', 'V4'), - ('V5', 'V5'), - ('V6', 'V6'), - ('V7', 'V7'), - ('V8', 'V8'), - ('V9', 'V9'), - ('V10', 'V10'), - ('V11', 'V11'), - ('V12', 'V12'), - ('V13', 'V13'), - ('V14', 'V14'), - ('V15', 'V15'), - ('V16', 'V16'), - ('V17', 'V17'), -) +class BoulderDifficylty(models.IntegerChoices): + V0 = 0, 'V0' + V1 = 1, 'V1' + V2 = 2, 'V2' + V3 = 3, 'V3' + V4 = 4, 'V4' + V5 = 5, 'V5' + V6 = 6, 'V6' + V7 = 7, 'V7' + V8 = 8, 'V8' + V9 = 9, 'V9' + V10 = 10, 'V10' + V11 = 11, 'V11' + V12 = 12, 'V12' + V13 = 13, 'V13' + V14 = 14, 'V14' + V15 = 15, 'V15' + V16 = 16, 'V16' + V17 = 17, 'V17' + class Problem(models.Model): boulder = models.ForeignKey( @@ -188,8 +187,8 @@ class Problem(models.Model): related_name='problems', ) name = models.CharField(max_length=64) - difficulty = models.CharField(max_length=3, choices=BOULDER_DIFFICULTY_CHOICES) - safety = models.CharField(max_length=4, choices=SAFETY_CHOICES) + difficulty = models.IntegerField(choices=BoulderDifficylty.choices) + safety = models.IntegerField(choices=Safety.choices) mountain_project = models.URLField(blank=True, null=True) notes = models.TextField(blank=True, null=True)