diff --git a/main-app-new.zip b/mainapp.zip similarity index 99% rename from main-app-new.zip rename to mainapp.zip index 4652649..34eb613 100644 Binary files a/main-app-new.zip and b/mainapp.zip differ diff --git a/migrations/versions/551167211686_auto.py b/migrations/versions/551167211686_auto.py new file mode 100644 index 0000000..6e7df17 --- /dev/null +++ b/migrations/versions/551167211686_auto.py @@ -0,0 +1,28 @@ +"""auto + +Revision ID: 551167211686 +Revises: 80cf84342c5f +Create Date: 2025-06-09 18:13:54.600906 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '551167211686' +down_revision = '80cf84342c5f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/plugins/plant/routes.py b/plugins/plant/routes.py index caf8ba8..d76daa7 100644 --- a/plugins/plant/routes.py +++ b/plugins/plant/routes.py @@ -1,3 +1,5 @@ +# plugins/plant/routes.py + from uuid import uuid4 from flask import ( Blueprint, @@ -12,7 +14,12 @@ from app import db from .models import Plant, PlantCommonName, PlantScientificName from .forms import PlantForm from plugins.media.models import Media -from plugins.media.utils import save_media_file, delete_media_file, rotate_media_file, generate_image_url +from plugins.media.utils import ( + save_media_file, + delete_media_file, + rotate_media_file, + generate_image_url +) bp = Blueprint( 'plant', @@ -21,9 +28,7 @@ bp = Blueprint( template_folder='templates' ) -# ----------------------------------------------------------------------------- -# Make generate_image_url available in all templates -# ----------------------------------------------------------------------------- +# Make generate_image_url available in all plant templates @bp.app_context_processor def inject_image_helper(): return dict(generate_image_url=generate_image_url) @@ -85,7 +90,8 @@ def create(): if form.mother_uuid.data != 'N/A' else None ), - custom_slug=form.custom_slug.data, + # ← HERE: convert blank slug to NULL + custom_slug=(form.custom_slug.data.strip() or None), notes=form.notes.data, data_verified=form.data_verified.data, is_active=form.is_active.data, @@ -101,16 +107,17 @@ def create(): @bp.route('/', methods=['GET']) @login_required def detail(uuid_val): - plant = Plant.query.filter_by(uuid=str(uuid_val)).first_or_404() + plant = Plant.query.filter_by(uuid=uuid_val).first_or_404() return render_template('plant/detail.html', plant=plant) # ─── EDIT ───────────────────────────────────────────────────────────────────── @bp.route('//edit', methods=['GET', 'POST']) @login_required def edit(uuid_val): - plant = Plant.query.filter_by(uuid=str(uuid_val)).first_or_404() + plant = Plant.query.filter_by(uuid=uuid_val).first_or_404() form = PlantForm() + # Populate dropdowns (same as in create) form.plant_type.choices = [ ('plant', 'Plant'), ('cutting', 'Cutting'), @@ -136,7 +143,7 @@ def edit(uuid_val): form.common_name.data = plant.common_id form.scientific_name.data = plant.scientific_id form.mother_uuid.data = plant.mother_uuid or 'N/A' - form.custom_slug.data = plant.custom_slug + form.custom_slug.data = plant.custom_slug or '' form.notes.data = plant.notes form.data_verified.data = plant.data_verified form.is_active.data = getattr(plant, 'is_active', True) @@ -150,7 +157,8 @@ def edit(uuid_val): if form.mother_uuid.data != 'N/A' else None ) - plant.custom_slug = form.custom_slug.data + # ← HERE as well + plant.custom_slug = (form.custom_slug.data.strip() or None) plant.notes = form.notes.data plant.data_verified = form.data_verified.data plant.is_active = form.is_active.data