feat: add description field for pet pictures
This commit is contained in:
6
main.py
6
main.py
@@ -38,6 +38,7 @@ def init_db():
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
filename TEXT NOT NULL,
|
||||
subscriber_name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
uploaded_at TIMESTAMP NOT NULL,
|
||||
posted BOOLEAN DEFAULT 0
|
||||
)
|
||||
@@ -68,6 +69,7 @@ def upload():
|
||||
|
||||
file = request.files["picture"]
|
||||
subscriber_name = request.form.get("subscriber_name")
|
||||
description = request.form.get("description", "").strip()
|
||||
|
||||
if file.filename == "":
|
||||
flash("No file selected")
|
||||
@@ -85,8 +87,8 @@ def upload():
|
||||
|
||||
with get_db() as db:
|
||||
db.execute(
|
||||
"INSERT INTO pet_pictures (filename, subscriber_name, uploaded_at) VALUES (?, ?, ?)",
|
||||
(filename, subscriber_name, datetime.now()),
|
||||
"INSERT INTO pet_pictures (filename, subscriber_name, description, uploaded_at) VALUES (?, ?, ?, ?)",
|
||||
(filename, subscriber_name, description, datetime.now()),
|
||||
)
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ endblock %} {% block content %}
|
||||
<h3 class="text-lg font-semibold text-gray-800">
|
||||
From: {{ picture.subscriber_name }}
|
||||
</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>
|
||||
<div class="mt-4 space-y-2">
|
||||
<a
|
||||
|
||||
@@ -25,6 +25,19 @@ Queue{% endblock %} {% block content %}
|
||||
/>
|
||||
</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>
|
||||
<label for="picture" class="block text-sm font-medium text-gray-700"
|
||||
>Pet Picture</label
|
||||
|
||||
Reference in New Issue
Block a user