Add a basic index and some models for each area
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 04:04:17 +0000 (23:04 -0500)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 4 Mar 2022 04:04:17 +0000 (23:04 -0500)
17 files changed:
src/climbing/templates/climbing/area_list.html [new file with mode: 0644]
src/climbing/urls.py [new file with mode: 0644]
src/climbing/views.py
src/core/settings.py
src/core/templates/core/base.html [new file with mode: 0644]
src/core/templates/core/index.html
src/core/urls.py
src/nutrition/migrations/0001_initial.py [new file with mode: 0644]
src/nutrition/models.py
src/nutrition/templates/nutrition/food_list.html [new file with mode: 0644]
src/nutrition/urls.py [new file with mode: 0644]
src/nutrition/views.py
src/training/migrations/0001_initial.py [new file with mode: 0644]
src/training/models.py
src/training/templates/training/exercise_list.html [new file with mode: 0644]
src/training/urls.py [new file with mode: 0644]
src/training/views.py

diff --git a/src/climbing/templates/climbing/area_list.html b/src/climbing/templates/climbing/area_list.html
new file mode 100644 (file)
index 0000000..02298ff
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends 'core/base.html' %}
+
+{% block content %}
+  {% for object in object_list %}
+    <p>{{ object.name }}</p>
+    {% if not forloop.last %}
+      <hr/>
+    {% endif %}
+  {% empty %}
+    <em>No areas found.</em>
+  {% endfor %}
+{% endblock %}
diff --git a/src/climbing/urls.py b/src/climbing/urls.py
new file mode 100644 (file)
index 0000000..2d8403b
--- /dev/null
@@ -0,0 +1,7 @@
+from django.urls import path
+
+from . import views
+
+urlpatterns = (
+    path('', views.index),
+)
index 91ea44a..3f013f2 100644 (file)
@@ -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()
index e47a56f..c07823b 100644 (file)
@@ -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 (file)
index 0000000..1879ad8
--- /dev/null
@@ -0,0 +1,15 @@
+<!doctype html>
+
+<html lang='en'>
+  <head>
+    <meta charset='utf-8'>
+    <meta name='viewport' content='width=device-width, initial-scale=1'>
+
+    <title>Climbing</title>
+    <meta name='author' content='David Kerkeslager'>
+  </head>
+
+  <body>
+    {% block content %}{% endblock %}
+  </body>
+</html>
index c2b863c..7cb928d 100644 (file)
@@ -1,16 +1,5 @@
-<!doctype html>
-
-<html lang='en'>
-  <head>
-    <meta charset='utf-8'>
-    <meta name='viewport' content='width=device-width, initial-scale=1'>
-
-    <title>Climbing</title>
-    <meta name='author' content='David Kerkeslager'>
-  </head>
-
-  <body>
-    Hello, world
-  </body>
-</html>
+{% extends 'core/base.html' %}
 
+{% block content %}
+  Goodnight, moon
+{% endblock %}
index b1a351e..8eef687 100644 (file)
@@ -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 (file)
index 0000000..9898665
--- /dev/null
@@ -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()),
+            ],
+        ),
+    ]
index 71a8362..ba7d415 100644 (file)
@@ -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 (file)
index 0000000..60c82b9
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends 'core/base.html' %}
+
+{% block content %}
+  {% for object in object_list %}
+    <p>{{ object.name }}</p>
+    {% if not forloop.last %}
+      <hr/>
+    {% endif %}
+  {% empty %}
+    <em>No foods found.</em>
+  {% endfor %}
+{% endblock %}
diff --git a/src/nutrition/urls.py b/src/nutrition/urls.py
new file mode 100644 (file)
index 0000000..2d8403b
--- /dev/null
@@ -0,0 +1,7 @@
+from django.urls import path
+
+from . import views
+
+urlpatterns = (
+    path('', views.index),
+)
index 91ea44a..fe4bc3b 100644 (file)
@@ -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 (file)
index 0000000..4f63184
--- /dev/null
@@ -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()),
+            ],
+        ),
+    ]
index 71a8362..618588d 100644 (file)
@@ -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 (file)
index 0000000..0e215f1
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends 'core/base.html' %}
+
+{% block content %}
+  {% for object in object_list %}
+    <p>{{ object.name }}</p>
+    {% if not forloop.last %}
+      <hr/>
+    {% endif %}
+  {% empty %}
+    <em>No exercises found.</em>
+  {% endfor %}
+{% endblock %}
diff --git a/src/training/urls.py b/src/training/urls.py
new file mode 100644 (file)
index 0000000..2d8403b
--- /dev/null
@@ -0,0 +1,7 @@
+from django.urls import path
+
+from . import views
+
+urlpatterns = (
+    path('', views.index),
+)
index 91ea44a..2356a09 100644 (file)
@@ -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()