character-fandom tag association system

Link character tags to fandom tags via fandom_id FK with auto-apply
behavior. Adding character:Saber (Fate) auto-creates fandom:Fate and
applies it to the image. Renaming a fandom cascades to all linked
characters. Includes set-fandom endpoint for retroactive association
and fandom selector dropdown in the tag editor UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 19:53:02 -05:00
parent 3a30b876a2
commit bf20eeab5c
6 changed files with 362 additions and 18 deletions
+10 -8
View File
@@ -4,7 +4,7 @@ A Flask-based image repository with Celery task processing for importing, organi
> **IMPORTANT**: This summary must be kept up to date with any code changes. Update the timestamp below when making modifications.
>
> **Last Updated**: 2026-02-05 (Consolidated JS utilities, shared modal template, Tags dropdown gap fix)
> **Last Updated**: 2026-02-11 (Character-fandom tag association system)
---
@@ -59,11 +59,12 @@ Fields: id, filename, filepath, thumb_path, hash (SHA256), perceptual_hash (256-
Relationships: tags (many-to-many via image_tags)
```
### Tag (lines 42-51)
### Tag (lines 42-53)
Tagging system for organization.
```
Fields: id, name (unique), kind (artist|archive|user|source|post|character|series|fandom|rating)
Relationships: images (many-to-many)
Fields: id, name (unique), kind (artist|archive|user|source|post|character|series|fandom|rating),
fandom_id (nullable FK to tag.id, self-referential for character→fandom link)
Relationships: images (many-to-many), fandom (self-referential, character tags point to fandom tags)
```
### ArchiveRecord (lines 53-66)
@@ -259,7 +260,8 @@ Import tasks support two modes based on `context.deep_scan`:
| `GET /api/tag/<id>` | 635-647 | Get tag details |
| `GET /api/post-metadata/<id>` | 649-680 | Get post metadata for a post tag |
| `GET /api/post-metadata/by-tag-name/<name>` | 682-714 | Get post metadata by tag name |
| `POST /api/tag/<id>/update` | 716-793 | Update/merge tag |
| `POST /api/tag/<id>/update` | 716-793 | Update/merge tag (cascades fandom renames to linked characters) |
| `POST /api/tag/<id>/set-fandom` | — | Set/clear character tag's fandom association (updates name suffix) |
| `POST /api/tag/<id>/delete` | 795-809 | Delete tag |
| `GET /api/tag/<id>/image-count` | 870-880 | Count images with tag |
@@ -376,7 +378,7 @@ layout.html (base)
| `gallery-infinite.js` | Infinite scroll, timeline navigation (uses TagUtils) |
| `view-modal.js` | Modal image navigation, tag editing, series management (uses TagUtils) |
| `bulk-select.js` | Multi-select with ordered selection, bulk tag editing, tag refresh (uses TagUtils) |
| `tag-editor.js` | Tag autocomplete and editing |
| `tag-editor.js` | Tag autocomplete and editing (includes fandom selector for character tags) |
| `showcase.js` | Showcase masonry layout and shuffle functionality (uses TagUtils) |
**Script Loading Order**: `tag-utils.js` must be loaded before other JS files that depend on `window.TagUtils`.
@@ -409,9 +411,9 @@ Files are stored with hash suffix: `{filename}__{hash[:10]}.{ext}`
- `source` - Platform source (prefix: `source:platform`)
- `post` - Post reference (prefix: `post:platform:artist:id`)
- `user` - User-created tags (no prefix)
- `character` - Character tags (prefix: `character:name`)
- `character` - Character tags (prefix: `character:name` or `character:name (fandom)`) — linked to fandom via `fandom_id` FK; adding a character auto-applies its fandom tag
- `series` - Series for ordered reading (prefix: `series:name`)
- `fandom` - Fandom/franchise tags (prefix: `fandom:name`)
- `fandom` - Fandom/franchise tags (prefix: `fandom:name`) — renaming cascades to all linked character tags
- `rating` - Content rating tags (prefix: `rating:level`)
### Import Pipeline