Initial plant reference and basic login

This commit is contained in:
kit 2025-12-03 12:34:46 +00:00
parent a2dba58fe4
commit cada3c7357
31 changed files with 637 additions and 0 deletions

0
planterteque/__init__.py Normal file
View file

5
planterteque/admin.py Normal file
View file

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Plant
admin.site.register(Plant)

6
planterteque/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class PlantertequeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'planterteque'

View file

@ -0,0 +1,32 @@
# Generated by Django 5.2.6 on 2025-12-03 09:33
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Plant',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=512, unique=True)),
('create_date', models.DateTimeField(auto_now_add=True)),
('modified_date', models.DateTimeField(auto_now=True)),
('botanical_name', models.CharField(max_length=2048)),
('description_short', models.TextField(blank=2048)),
('description_long', models.TextField(blank=True)),
('growing_notes', models.TextField(blank=True)),
('spread', models.IntegerField(default=0)),
('height', models.IntegerField(default=0)),
('sow_depth', models.IntegerField(default=0)),
('spacing', models.IntegerField(default=0)),
('other_notes', models.TextField(blank=True)),
],
),
]

View file

21
planterteque/models.py Normal file
View file

@ -0,0 +1,21 @@
from django.db import models
class Plant(models.Model):
name = models.CharField(max_length=512, unique=True)
create_date = models.DateTimeField(auto_now_add=True)
modified_date = models.DateTimeField(auto_now=True)
botanical_name = models.CharField(max_length=2048)
description_short = models.TextField(blank=2048)
description_long = models.TextField(blank=True)
growing_notes = models.TextField(blank=True)
spread = models.IntegerField(default=0)
height = models.IntegerField(default=0)
sow_depth = models.IntegerField(default=0)
spacing = models.IntegerField(default=0)
other_notes = models.TextField(blank=True)
def __str__(self):
return self.name

View file

@ -0,0 +1,22 @@
{% extends 'base.html' %}
{% block head_title %}Verdure: Plant Reference{% endblock head_title %}
{%block head_content%}<h1>Plant Reference</h1>{%endblock head_content%}
{% block content %}
{% if latest_plants_list %}
<ul>
{% for plant in latest_plants_list %}
<li><a href="{% url 'planterteque:reference' plant.id %}" title="{{ plant.name }}">{{ plant.name }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No plants. Add some?</p>
{% endif %}
{% endblock content%}

View file

@ -0,0 +1,44 @@
{% extends 'base.html' %}
{% block head_title %}Verdure: Plant Reference{% endblock head_title %}
{% block head_content %}<h1>{{ plant.name }}</h1>{% endblock head_content %}
{% block content %}
{% if plant.description_short %}
<div>
{{ plant.description_short }}
</div>
{% endif %}
<dl>
{% if plant.height %}
<dt>Height</dt><dd>
{{ plant.height }}
</dd>
{% endif %}
{% if plant.spread %}
<dt>Spread</dt><dd>
{{ plant.spread }}
</dd>
{% endif %}
{% if plant.spacing %}
<dt>Spacing</dt><dd>
{{ plant.spacing }}
</dd>
{% endif %}
{% if plant.description_long %}
<div>
{{ plant.description_long }}
</div>
{% endif %}
</dl>
{% endblock content %}

3
planterteque/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
planterteque/urls.py Normal file
View file

@ -0,0 +1,9 @@
from django.urls import path
from . import views
app_name = "planterteque"
urlpatterns = [
path("", views.index, name="index"),
path("<int:plant_id>", views.reference, name="reference"),
]

21
planterteque/views.py Normal file
View file

@ -0,0 +1,21 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse, Http404
from django.template import loader
from .models import Plant
def index(request):
latest_plants_list = Plant.objects.order_by("-create_date")[:5]
context = { "latest_plants_list": latest_plants_list }
return render( request, "planterteque/index.html", context )
def reference(request, plant_id):
try:
plant = Plant.objects.get( pk=plant_id )
except Plant.DoesNotExist:
raise Http404("Plant does not exist")
context = { "plant": plant }
return render( request, "planterteque/reference.html", context )