sort of working, more changes
This commit is contained in:
53
plugins/plant/templates/plant/create.html
Normal file
53
plugins/plant/templates/plant/create.html
Normal file
@ -0,0 +1,53 @@
|
||||
{% extends 'core_ui/base.html' %}
|
||||
{% block title %}Add New Plant – Nature In Pots{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-4">
|
||||
<h2>Create New Plant</h2>
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.plant_type.label(class="form-label") }}
|
||||
{{ form.plant_type(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.common_name.label(class="form-label") }}
|
||||
{{ form.common_name(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.scientific_name.label(class="form-label") }}
|
||||
{{ form.scientific_name(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.mother_uuid.label(class="form-label") }}
|
||||
{{ form.mother_uuid(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.custom_slug.label(class="form-label") }}
|
||||
{{ form.custom_slug(class="form-control") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.notes.label(class="form-label") }}
|
||||
{{ form.notes(class="form-control", rows=4) }}
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
{{ form.data_verified(class="form-check-input") }}
|
||||
{{ form.data_verified.label(class="form-check-label") }}
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
{{ form.is_active(class="form-check-input") }}
|
||||
{{ form.is_active.label(class="form-check-label") }}
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success">Create Plant</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,37 +1,73 @@
|
||||
{# plugins/plant/templates/plant/detail.html #}
|
||||
{% extends 'core_ui/base.html' %}
|
||||
{% block title %}{{ plant.common_name.name }} – Nature In Pots{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
{{ plant.common_name.name if plant.common_name else "Unnamed Plant" }} – Nature In Pots
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-4">
|
||||
<div class="row">
|
||||
<div class="row gx-4">
|
||||
<div class="col-md-4">
|
||||
<img src="https://placehold.co/300x300"
|
||||
class="img-fluid rounded mb-3"
|
||||
alt="{{ plant.common_name.name }}">
|
||||
{# determine featured or fallback to first media item #}
|
||||
{% set featured = plant.featured_media or plant.media|first %}
|
||||
<img
|
||||
src="{{ generate_image_url(featured.file_url if featured else None) }}"
|
||||
alt="Image of {{ plant.common_name.name if plant.common_name else 'Plant' }}"
|
||||
class="img-fluid rounded shadow-sm"
|
||||
style="object-fit: cover; width: 100%; height: auto;"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<h1>{{ plant.common_name.name }}</h1>
|
||||
<h2>
|
||||
{{ plant.common_name.name if plant.common_name else "Unnamed Plant" }}
|
||||
</h2>
|
||||
{% if plant.scientific_name %}
|
||||
<p class="text-muted"><em>{{ plant.scientific_name.name }}</em></p>
|
||||
<h5 class="text-muted">
|
||||
{{ plant.scientific_name.name }}
|
||||
</h5>
|
||||
{% endif %}
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Date Added</dt>
|
||||
<dd class="col-sm-9">{{ plant.created_at.strftime('%Y-%m-%d') }}</dd>
|
||||
|
||||
<dt class="col-sm-3">Status</dt>
|
||||
<dd class="col-sm-9">
|
||||
{{ 'Dead' if plant.is_dead else 'Active' }}
|
||||
</dd>
|
||||
</dl>
|
||||
<p class="mt-3">
|
||||
{{ plant.notes or "No description provided." }}
|
||||
</p>
|
||||
|
||||
<a href="{{ url_for('plant.index') }}" class="btn btn-secondary">
|
||||
← Back to list
|
||||
</a>
|
||||
<a href="{{ url_for('plant.edit', plant_id=plant.id) }}"
|
||||
class="btn btn-primary">
|
||||
Edit
|
||||
</a>
|
||||
{% if plant.mother_uuid %}
|
||||
<p class="text-muted">
|
||||
Parent:
|
||||
<a href="{{ url_for('plant.detail', uuid_val=plant.mother_uuid) }}">
|
||||
{{ plant.mother_uuid }}
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-4">
|
||||
<a
|
||||
href="{{ url_for('plant.edit', uuid_val=plant.uuid) }}"
|
||||
class="btn btn-primary me-2"
|
||||
>Edit</a>
|
||||
<a
|
||||
href="{{ url_for('plant.index') }}"
|
||||
class="btn btn-secondary"
|
||||
>Back to List</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if plant.media|length > (1 if plant.featured_media else 0) %}
|
||||
<hr class="my-4">
|
||||
<h4>Additional Images</h4>
|
||||
<div class="d-flex flex-wrap gap-3">
|
||||
{% for img in plant.media if img != featured %}
|
||||
<img
|
||||
src="{{ generate_image_url(img.file_url) }}"
|
||||
alt="Plant image"
|
||||
class="img-thumbnail"
|
||||
style="height: 160px; object-fit: cover;"
|
||||
>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
127
plugins/plant/templates/plant/edit.html
Normal file
127
plugins/plant/templates/plant/edit.html
Normal file
@ -0,0 +1,127 @@
|
||||
{% extends 'core_ui/base.html' %}
|
||||
{% block title %}Edit Plant – Nature In Pots{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-4">
|
||||
<h2>Edit Plant</h2>
|
||||
|
||||
{# ─── Main plant‐data form ──────────────────────────────────────────── #}
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.plant_type.label(class="form-label") }}
|
||||
{{ form.plant_type(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.common_name.label(class="form-label") }}
|
||||
{{ form.common_name(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.scientific_name.label(class="form-label") }}
|
||||
{{ form.scientific_name(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.mother_uuid.label(class="form-label") }}
|
||||
{{ form.mother_uuid(class="form-select") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.custom_slug.label(class="form-label") }}
|
||||
{{ form.custom_slug(class="form-control") }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.notes.label(class="form-label") }}
|
||||
{{ form.notes(class="form-control", rows=4) }}
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
{{ form.data_verified(class="form-check-input") }}
|
||||
{{ form.data_verified.label(class="form-check-label") }}
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
{{ form.is_active(class="form-check-input") }}
|
||||
{{ form.is_active.label(class="form-check-label") }}
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
{# ─── Upload new image ─────────────────────────────────────────────── #}
|
||||
<h4>Upload Image</h4>
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('plant.upload_image', uuid_val=plant.uuid) }}"
|
||||
enctype="multipart/form-data"
|
||||
class="mb-4"
|
||||
>
|
||||
<input
|
||||
type="hidden"
|
||||
name="csrf_token"
|
||||
value="{{ csrf_token() }}"
|
||||
>
|
||||
<div class="input-group">
|
||||
<input type="file" name="file" class="form-control" required>
|
||||
<button class="btn btn-secondary" type="submit">Upload</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{# ─── Existing images ──────────────────────────────────────────────── #}
|
||||
<h4>Existing Images</h4>
|
||||
<div class="row">
|
||||
{% for media in plant.media %}
|
||||
<div class="col-md-3 mb-4">
|
||||
<div class="card h-100">
|
||||
<img
|
||||
src="{{ generate_image_url(media.file_url) }}"
|
||||
class="card-img-top img-fluid"
|
||||
alt="Plant Image"
|
||||
style="object-fit:cover; height:150px;"
|
||||
>
|
||||
<div class="card-body text-center">
|
||||
{% if plant.featured_media_id == media.id %}
|
||||
<span class="badge bg-success mb-2">Featured</span>
|
||||
{% else %}
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('plant.set_featured_image', uuid_val=plant.uuid, media_id=media.id) }}"
|
||||
class="mb-2"
|
||||
>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button class="btn btn-outline-primary btn-sm">Set Featured</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<div class="d-grid gap-1">
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('plant.rotate_image', uuid_val=plant.uuid, media_id=media.id) }}"
|
||||
>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button class="btn btn-outline-secondary btn-sm">Rotate</button>
|
||||
</form>
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('plant.delete_image', uuid_val=plant.uuid, media_id=media.id) }}"
|
||||
onsubmit="return confirm('Delete this image?');"
|
||||
>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button class="btn btn-outline-danger btn-sm">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted">No images uploaded yet.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,12 +0,0 @@
|
||||
{% extends 'core_ui/base.html' %}
|
||||
{% block content %}
|
||||
<h1>{% if plant %}Edit{% else %}New{% endif %} Plant</h1>
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
<p>{{ form.name.label }}<br>{{ form.name(size=40) }}</p>
|
||||
<p>{{ form.type.label }}<br>{{ form.type(size=40) }}</p>
|
||||
<p>{{ form.notes.label }}<br>{{ form.notes(rows=5, cols=40) }}</p>
|
||||
<p>{{ form.is_active() }} {{ form.is_active.label }}</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
{% endblock %}
|
@ -1,32 +1,112 @@
|
||||
{# plugins/plant/templates/plant/index.html #}
|
||||
{% extends 'core_ui/base.html' %}
|
||||
|
||||
{% block title %}Plant List – Nature In Pots{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-4">
|
||||
<!-- Stats Section (responsive 2-col ↔ 1-col) -->
|
||||
<div class="mb-4 p-3 bg-light border rounded">
|
||||
<h5>Statistics</h5>
|
||||
<div class="row row-cols-1 row-cols-md-2 g-3 mt-3 text-center">
|
||||
<div class="col">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<i class="bi bi-seedling fs-3 text-success me-3"></i>
|
||||
<div>
|
||||
<div class="small text-muted">Your plants</div>
|
||||
<div class="fw-bold">{{ stats.user_plants }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<i class="bi bi-image fs-3 text-primary me-3"></i>
|
||||
<div>
|
||||
<div class="small text-muted">Your images</div>
|
||||
<div class="fw-bold">{{ stats.user_images }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<i class="bi bi-tree fs-3 text-success me-3"></i>
|
||||
<div>
|
||||
<div class="small text-muted">Total plants</div>
|
||||
<div class="fw-bold">{{ stats.total_plants }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<i class="bi bi-images fs-3 text-primary me-3"></i>
|
||||
<div>
|
||||
<div class="small text-muted">Total images</div>
|
||||
<div class="fw-bold">{{ stats.total_images }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1 class="mb-4">Plant List</h1>
|
||||
|
||||
<!-- Search & Add -->
|
||||
<div class="mb-3 d-flex flex-column flex-md-row justify-content-between align-items-start align-items-md-center gap-2">
|
||||
<div>
|
||||
<a href="{{ url_for('plant.create') }}" class="btn btn-success">Add New Plant</a>
|
||||
</div>
|
||||
<div class="input-group" style="max-width:300px; width:100%;">
|
||||
<span class="input-group-text">Search</span>
|
||||
<input id="searchInput" type="text" class="form-control" placeholder="by name…">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if plants %}
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4">
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-4" id="plantContainer">
|
||||
{% for plant in plants %}
|
||||
<div class="col">
|
||||
<div class="col plant-card" data-name="{{ plant.common_name.name|lower if plant.common_name else '' }}">
|
||||
<div class="card h-100">
|
||||
<!-- placeholder until you wire up real media -->
|
||||
<img src="https://placehold.co/150x150"
|
||||
class="card-img-top"
|
||||
alt="{{ plant.common_name.name if plant.common_name else 'Plant' }}">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title">
|
||||
{{ plant.common_name.name if plant.common_name else 'Unnamed' }}
|
||||
</h5>
|
||||
{% if plant.scientific_name %}
|
||||
<p class="card-text text-muted">
|
||||
<em>{{ plant.scientific_name.name }}</em>
|
||||
</p>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('plant.detail', plant_id=plant.id) }}"
|
||||
class="mt-auto btn btn-primary">
|
||||
View Details
|
||||
{# pick the featured media entry, or fall back to first item #}
|
||||
{% set featured = plant.media
|
||||
|selectattr('id','equalto', plant.featured_media_id)
|
||||
|first %}
|
||||
{% if not featured and plant.media %}
|
||||
{% set featured = plant.media|first %}
|
||||
{% endif %}
|
||||
|
||||
{% if featured %}
|
||||
<a href="{{ url_for('plant.detail', uuid_val=plant.uuid) }}">
|
||||
<img
|
||||
src="{{ generate_image_url(featured.file_url) }}"
|
||||
class="card-img-top"
|
||||
style="height:200px;object-fit:cover;"
|
||||
alt="Image for {{ plant.common_name.name if plant.common_name else 'Plant' }}">
|
||||
</a>
|
||||
{% else %}
|
||||
<img
|
||||
src="https://placehold.co/300x200"
|
||||
class="card-img-top"
|
||||
style="height:200px;object-fit:cover;"
|
||||
alt="No image available">
|
||||
{% endif %}
|
||||
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title mb-1">
|
||||
<a href="{{ url_for('plant.detail', uuid_val=plant.uuid) }}">
|
||||
{{ plant.common_name.name if plant.common_name else 'Untitled' }}
|
||||
</a>
|
||||
</h5>
|
||||
<h6 class="text-muted small">{{ plant.uuid }}</h6>
|
||||
<p class="mb-1"><strong>Type:</strong> {{ plant.plant_type }}</p>
|
||||
<p class="mb-2"><strong>Scientific:</strong>
|
||||
{{ plant.scientific_name.name if plant.scientific_name else '–' }}
|
||||
</p>
|
||||
<div class="mt-auto d-flex flex-wrap gap-1">
|
||||
<a href="{{ url_for('plant.detail', uuid_val=plant.uuid) }}"
|
||||
class="btn btn-sm btn-primary">View</a>
|
||||
<a href="{{ url_for('plant.edit', uuid_val=plant.uuid) }}"
|
||||
class="btn btn-sm btn-secondary">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -35,12 +115,15 @@
|
||||
{% else %}
|
||||
<p>No plants found yet. <a href="{{ url_for('plant.create') }}">Add one now.</a></p>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('plant.create') }}"
|
||||
class="btn btn-success">
|
||||
Add New Plant
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// client-side filtering
|
||||
document.getElementById('searchInput').addEventListener('input', function() {
|
||||
const q = this.value.trim().toLowerCase();
|
||||
document.querySelectorAll('#plantContainer .plant-card').forEach(card => {
|
||||
card.style.display = card.dataset.name.includes(q) ? '' : 'none';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user