feat: add description field for pet pictures

This commit is contained in:
Ryan Chen
2025-06-13 17:07:22 -04:00
parent dd9cc42271
commit 7c62dc8d08
3 changed files with 20 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ def init_db():
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
filename TEXT NOT NULL, filename TEXT NOT NULL,
subscriber_name TEXT NOT NULL, subscriber_name TEXT NOT NULL,
description TEXT,
uploaded_at TIMESTAMP NOT NULL, uploaded_at TIMESTAMP NOT NULL,
posted BOOLEAN DEFAULT 0 posted BOOLEAN DEFAULT 0
) )
@@ -68,6 +69,7 @@ def upload():
file = request.files["picture"] file = request.files["picture"]
subscriber_name = request.form.get("subscriber_name") subscriber_name = request.form.get("subscriber_name")
description = request.form.get("description", "").strip()
if file.filename == "": if file.filename == "":
flash("No file selected") flash("No file selected")
@@ -85,8 +87,8 @@ def upload():
with get_db() as db: with get_db() as db:
db.execute( db.execute(
"INSERT INTO pet_pictures (filename, subscriber_name, uploaded_at) VALUES (?, ?, ?)", "INSERT INTO pet_pictures (filename, subscriber_name, description, uploaded_at) VALUES (?, ?, ?, ?)",
(filename, subscriber_name, datetime.now()), (filename, subscriber_name, description, datetime.now()),
) )
db.commit() db.commit()

View File

@@ -31,6 +31,9 @@ endblock %} {% block content %}
<h3 class="text-lg font-semibold text-gray-800"> <h3 class="text-lg font-semibold text-gray-800">
From: {{ picture.subscriber_name }} From: {{ picture.subscriber_name }}
</h3> </h3>
{% if picture.description %}
<p class="mt-2 text-gray-600">{{ picture.description }}</p>
{% endif %}
<p class="text-sm text-gray-600">Uploaded: {{ picture.uploaded_at }}</p> <p class="text-sm text-gray-600">Uploaded: {{ picture.uploaded_at }}</p>
<div class="mt-4 space-y-2"> <div class="mt-4 space-y-2">
<a <a

View File

@@ -25,6 +25,19 @@ Queue{% endblock %} {% block content %}
/> />
</div> </div>
<div>
<label for="description" class="block text-sm font-medium text-gray-700"
>Description (Optional)</label
>
<textarea
name="description"
id="description"
rows="3"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
placeholder="Add a description for the pet picture..."
></textarea>
</div>
<div> <div>
<label for="picture" class="block text-sm font-medium text-gray-700" <label for="picture" class="block text-sm font-medium text-gray-700"
>Pet Picture</label >Pet Picture</label