From 1bc6954655e77c96abc15240b495331dfb0dd1a8 Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Wed, 2 Mar 2022 23:06:46 -0500 Subject: [PATCH] Add climbing models --- src/climbing/migrations/0001_initial.py | 81 ++++++++++++++++++ src/climbing/models.py | 109 +++++++++++++++++++++++- src/core/settings.py | 3 + 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 src/climbing/migrations/0001_initial.py diff --git a/src/climbing/migrations/0001_initial.py b/src/climbing/migrations/0001_initial.py new file mode 100644 index 0000000..38bf813 --- /dev/null +++ b/src/climbing/migrations/0001_initial.py @@ -0,0 +1,81 @@ +# Generated by Django 4.0.3 on 2022-03-03 04:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Area', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ], + ), + migrations.CreateModel( + name='Crag', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.area')), + ], + ), + migrations.CreateModel( + name='Route', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.crag')), + ], + ), + migrations.CreateModel( + name='Pitch', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64, null=True)), + ('difficulty', models.CharField(choices=[('5.0', '5.0'), ('5.1', '5.1'), ('5.2', '5.2'), ('5.3', '5.3'), ('5.4', '5.4'), ('5.5', '5.5'), ('5.6', '5.6'), ('5.6+', '5.6+'), ('5.7', '5.7'), ('5.7+', '5.7+'), ('5.8', '5.8'), ('5.8+', '5.8+'), ('5.9-', '5.9-'), ('5.9', '5.9'), ('5.9+', '5.9+'), ('5.10a', '5.10a'), ('5.10b', '5.10b'), ('5.10c', '5.10c'), ('5.10d', '5.10d'), ('5.11a', '5.11a'), ('5.11b', '5.11b'), ('5.11c', '5.11c'), ('5.11d', '5.11d'), ('5.12a', '5.12a'), ('5.12b', '5.12b'), ('5.12c', '5.12c'), ('5.12d', '5.12d'), ('5.13a', '5.13a'), ('5.13b', '5.13b'), ('5.13c', '5.13c'), ('5.13d', '5.13d'), ('5.14a', '5.14a'), ('5.14b', '5.14b'), ('5.14c', '5.14c'), ('5.14d', '5.14d'), ('5.15a', '5.15a'), ('5.15b', '5.15b'), ('5.15c', '5.15c'), ('5.15d', '5.15d')], max_length=5)), + ('safety', models.CharField(choices=[('G', 'G'), ('PG', 'PG'), ('PG13', 'PG13'), ('R', 'R'), ('X', 'X')], max_length=4)), + ('notes', models.TextField()), + ('route', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.route')), + ], + ), + migrations.CreateModel( + name='Cluster', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.area')), + ], + ), + migrations.CreateModel( + name='Boulder', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ('cluster', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.cluster')), + ], + ), + migrations.CreateModel( + name='Problem', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('difficulty', models.CharField(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')], max_length=3)), + ('safety', models.CharField(choices=[('G', 'G'), ('PG', 'PG'), ('PG13', 'PG13'), ('R', 'R'), ('X', 'X')], max_length=4)), + ('notes', models.TextField()), + ('boulder', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='climbing.boulder')), + ], + ), + ] diff --git a/src/climbing/models.py b/src/climbing/models.py index 71a8362..0f17d7a 100644 --- a/src/climbing/models.py +++ b/src/climbing/models.py @@ -1,3 +1,110 @@ from django.db import models -# Create your models here. +class Area(models.Model): + name = models.CharField(max_length=64) + notes = models.TextField() + +class Crag(models.Model): + area = models.ForeignKey(Area, on_delete=models.CASCADE) + name = models.CharField(max_length=64) + notes = models.TextField() + +class Route(models.Model): + area = models.ForeignKey(Crag, on_delete=models.CASCADE) + name = models.CharField(max_length=64) + notes = models.TextField() + +ROUTE_DIFFICULTY_CHOICES = ( + ('5.0', '5.0'), + ('5.1', '5.1'), + ('5.2', '5.2'), + ('5.3', '5.3'), + ('5.4', '5.4'), + ('5.5', '5.5'), + ('5.6', '5.6'), + ('5.6+', '5.6+'), + ('5.7', '5.7'), + ('5.7+', '5.7+'), + ('5.8', '5.8'), + ('5.8+', '5.8+'), + ('5.9-', '5.9-'), + ('5.9', '5.9'), + ('5.9+', '5.9+'), + ('5.10a', '5.10a'), + ('5.10b', '5.10b'), + ('5.10c', '5.10c'), + ('5.10d', '5.10d'), + ('5.11a', '5.11a'), + ('5.11b', '5.11b'), + ('5.11c', '5.11c'), + ('5.11d', '5.11d'), + ('5.12a', '5.12a'), + ('5.12b', '5.12b'), + ('5.12c', '5.12c'), + ('5.12d', '5.12d'), + ('5.13a', '5.13a'), + ('5.13b', '5.13b'), + ('5.13c', '5.13c'), + ('5.13d', '5.13d'), + ('5.14a', '5.14a'), + ('5.14b', '5.14b'), + ('5.14c', '5.14c'), + ('5.14d', '5.14d'), + ('5.15a', '5.15a'), + ('5.15b', '5.15b'), + ('5.15c', '5.15c'), + ('5.15d', '5.15d'), +) + +SAFETY_CHOICES = ( + ('G', 'G'), + ('PG', 'PG'), + ('PG13', 'PG13'), + ('R', 'R'), + ('X', 'X'), +) + +class Pitch(models.Model): + route = models.ForeignKey(Route, on_delete=models.CASCADE) + name = models.CharField(max_length=64, null=True) + difficulty = models.CharField(max_length=5, choices=ROUTE_DIFFICULTY_CHOICES) + safety = models.CharField(max_length=4, choices=SAFETY_CHOICES) + notes = models.TextField() + +class Cluster(models.Model): + area = models.ForeignKey(Area, on_delete=models.CASCADE) + name = models.CharField(max_length=64) + notes = models.TextField() + +class Boulder(models.Model): + cluster = models.ForeignKey(Cluster, on_delete=models.CASCADE) + name = models.CharField(max_length=64) + notes = models.TextField() + +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 Problem(models.Model): + boulder = models.ForeignKey(Boulder, on_delete=models.CASCADE) + 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) + notes = models.TextField() diff --git a/src/core/settings.py b/src/core/settings.py index 9a0c510..e47a56f 100644 --- a/src/core/settings.py +++ b/src/core/settings.py @@ -38,6 +38,9 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'core', + 'climbing', + 'nutrition', + 'training', ] MIDDLEWARE = [ -- 2.20.1