feat: auto-populate slug fields on save
Add clubmanager.base.unique_slugify(instance, value, scope=...): slugify a source value, truncate to the field's max_length, and append -2/-3/... to stay unique within a scope. ClubScopedModel gains a slug_source hook that fills a blank slug (unique per club) on save. Wire it up so every SlugField auto-populates from its natural source when left blank (explicit values are always kept): - shop.Product.slug <- name (per club) - formbuilder.Form.slug <- title (per club) - formbuilder.Field.key <- label (per form) Club.slug already auto-populated; refactor it onto the shared helper. Also fix shop.Product.slug's multi-tenancy bug: it was globally unique (unique=True); make it unique per club like the others. Migrations added. Full suite at 100% coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.6 on 2026-07-12 19:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('formbuilder', '0003_fix_tenant_uniqueness'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='field',
|
||||
name='key',
|
||||
field=models.SlugField(blank=True, verbose_name='key'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='form',
|
||||
name='slug',
|
||||
field=models.SlugField(blank=True, verbose_name='slug'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user