From: David Kerkeslager Date: Fri, 4 Mar 2022 04:04:17 +0000 (-0500) Subject: Add a basic index and some models for each area X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=3977607665b62dae546113a3888fd3588d743283;p=climbing.kerkeslager.com Add a basic index and some models for each area --- diff --git a/src/climbing/templates/climbing/area_list.html b/src/climbing/templates/climbing/area_list.html new file mode 100644 index 0000000..02298ff --- /dev/null +++ b/src/climbing/templates/climbing/area_list.html @@ -0,0 +1,12 @@ +{% extends 'core/base.html' %} + +{% block content %} + {% for object in object_list %} +

{{ object.name }}

+ {% if not forloop.last %} +
+ {% endif %} + {% empty %} + No areas found. + {% endfor %} +{% endblock %} diff --git a/src/climbing/urls.py b/src/climbing/urls.py new file mode 100644 index 0000000..2d8403b --- /dev/null +++ b/src/climbing/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = ( + path('', views.index), +) diff --git a/src/climbing/views.py b/src/climbing/views.py index 91ea44a..3f013f2 100644 --- a/src/climbing/views.py +++ b/src/climbing/views.py @@ -1,3 +1,8 @@ -from django.shortcuts import render +from django.views.generic.list import ListView -# Create your views here. +from . import models + +class AreaListView(ListView): + model = models.Area + +index = AreaListView.as_view() diff --git a/src/core/settings.py b/src/core/settings.py index e47a56f..c07823b 100644 --- a/src/core/settings.py +++ b/src/core/settings.py @@ -37,10 +37,10 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'core', 'climbing', 'nutrition', 'training', + 'core', ] MIDDLEWARE = [ diff --git a/src/core/templates/core/base.html b/src/core/templates/core/base.html new file mode 100644 index 0000000..1879ad8 --- /dev/null +++ b/src/core/templates/core/base.html @@ -0,0 +1,15 @@ + + + + + + + + Climbing + + + + + {% block content %}{% endblock %} + + diff --git a/src/core/templates/core/index.html b/src/core/templates/core/index.html index c2b863c..7cb928d 100644 --- a/src/core/templates/core/index.html +++ b/src/core/templates/core/index.html @@ -1,16 +1,5 @@ - - - - - - - - Climbing - - - - - Hello, world - - +{% extends 'core/base.html' %} +{% block content %} + Goodnight, moon +{% endblock %} diff --git a/src/core/urls.py b/src/core/urls.py index b1a351e..8eef687 100644 --- a/src/core/urls.py +++ b/src/core/urls.py @@ -14,11 +14,18 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path + +from climbing import urls as climbing_urls +from nutrition import urls as nutrition_urls +from training import urls as training_urls from . import views urlpatterns = ( path('admin/', admin.site.urls), path('', views.index), + path('c/', include(climbing_urls)), + path('n/', include(nutrition_urls)), + path('t/', include(training_urls)), ) diff --git a/src/nutrition/migrations/0001_initial.py b/src/nutrition/migrations/0001_initial.py new file mode 100644 index 0000000..9898665 --- /dev/null +++ b/src/nutrition/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.3 on 2022-03-03 16:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Food', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField(max_length=64)), + ('brand', models.TextField(max_length=64)), + ('calories', models.PositiveIntegerField()), + ], + ), + ] diff --git a/src/nutrition/models.py b/src/nutrition/models.py index 71a8362..ba7d415 100644 --- a/src/nutrition/models.py +++ b/src/nutrition/models.py @@ -1,3 +1,6 @@ from django.db import models -# Create your models here. +class Food(models.Model): + name = models.TextField(max_length=64) + brand = models.TextField(max_length=64) + calories = models.PositiveIntegerField() diff --git a/src/nutrition/templates/nutrition/food_list.html b/src/nutrition/templates/nutrition/food_list.html new file mode 100644 index 0000000..60c82b9 --- /dev/null +++ b/src/nutrition/templates/nutrition/food_list.html @@ -0,0 +1,12 @@ +{% extends 'core/base.html' %} + +{% block content %} + {% for object in object_list %} +

{{ object.name }}

+ {% if not forloop.last %} +
+ {% endif %} + {% empty %} + No foods found. + {% endfor %} +{% endblock %} diff --git a/src/nutrition/urls.py b/src/nutrition/urls.py new file mode 100644 index 0000000..2d8403b --- /dev/null +++ b/src/nutrition/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = ( + path('', views.index), +) diff --git a/src/nutrition/views.py b/src/nutrition/views.py index 91ea44a..fe4bc3b 100644 --- a/src/nutrition/views.py +++ b/src/nutrition/views.py @@ -1,3 +1,8 @@ -from django.shortcuts import render +from django.views.generic.list import ListView -# Create your views here. +from . import models + +class FoodListView(ListView): + model = models.Food + +index = FoodListView.as_view() diff --git a/src/training/migrations/0001_initial.py b/src/training/migrations/0001_initial.py new file mode 100644 index 0000000..4f63184 --- /dev/null +++ b/src/training/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 4.0.3 on 2022-03-03 16:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Exercise', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=64)), + ('notes', models.TextField()), + ], + ), + ] diff --git a/src/training/models.py b/src/training/models.py index 71a8362..618588d 100644 --- a/src/training/models.py +++ b/src/training/models.py @@ -1,3 +1,5 @@ from django.db import models -# Create your models here. +class Exercise(models.Model): + name = models.CharField(max_length=64) + notes = models.TextField() diff --git a/src/training/templates/training/exercise_list.html b/src/training/templates/training/exercise_list.html new file mode 100644 index 0000000..0e215f1 --- /dev/null +++ b/src/training/templates/training/exercise_list.html @@ -0,0 +1,12 @@ +{% extends 'core/base.html' %} + +{% block content %} + {% for object in object_list %} +

{{ object.name }}

+ {% if not forloop.last %} +
+ {% endif %} + {% empty %} + No exercises found. + {% endfor %} +{% endblock %} diff --git a/src/training/urls.py b/src/training/urls.py new file mode 100644 index 0000000..2d8403b --- /dev/null +++ b/src/training/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = ( + path('', views.index), +) diff --git a/src/training/views.py b/src/training/views.py index 91ea44a..2356a09 100644 --- a/src/training/views.py +++ b/src/training/views.py @@ -1,3 +1,8 @@ -from django.shortcuts import render +from django.views.generic.list import ListView -# Create your views here. +from . import models + +class ExerciseListView(ListView): + model = models.Exercise + +index = ExerciseListView.as_view()