Commit Graph

213 Commits

Author SHA1 Message Date
75c89e3f7e fix: Add fallback support for old image file formats
- Added default_storage import to ImageService
- Implemented fallback logic in get_url() method
- First tries new format (.webp for non-original, .jpg for original)
- Falls back to old format (all .jpg) for backward compatibility
- Ensures old photos continue to work with new configuration
- Prevents broken links when migrating to new format

This allows gradual transition from old to new image format without breaking existing image links.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 23:41:17 +03:00
f12fd18190 refactor: Move image processing configuration to settings
Refactored image processing system to use centralized configuration in settings.IMAGE_PROCESSING_CONFIG instead of hardcoded values.

Changes:
- Added IMAGE_PROCESSING_CONFIG to settings with configurable sizes, formats, and quality
- Rewrote ImageProcessor to use dynamic configuration from settings
- Added support for multiple image formats (JPEG, WebP, PNG)
- Updated _save_image_version() to handle different formats and quality levels
- Added original image scaling (max 2160×2160) and square aspect ratio
- Updated ImageService to work with different file extensions (.jpg, .webp, .png)
- All parameters now easily configurable without code changes

Configuration:
- Original: JPEG, quality 100, max 2160×2160 (always square)
- Large: WebP, quality 90, 1200×1200
- Medium: WebP, quality 85, 600×600
- Thumbnail: WebP, quality 80, 200×200

Benefits:
- Flexible and maintainable configuration
- Smaller file sizes (WebP for resized images)
- Maximum quality for originals (JPEG 100)
- Square aspect ratio for better consistency

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 23:34:14 +03:00
a9b16bf212 feat: Implement safe soft delete and hard delete actions in admin
- Override Django's delete_selected action to enforce soft deletion
  (calls .delete() on each object instead of queryset.delete())
- Add hard_delete_selected action for safe permanent deletion
  - Checks for dangerous relations (KitItem, etc.) before deleting
  - Only allows deletion if no critical dependencies exist
  - Safely deletes photos from media/ folder by explicitly calling
    ProductPhoto.delete() which triggers ImageProcessor cleanup
- Add delete() and hard_delete() method overrides to ProductTag model
  (Product, ProductKit, ProductCategory already had these)
- Integrate all three actions into admin classes:
  ProductCategoryAdmin, ProductTagAdmin, ProductAdmin, ProductKitAdmin
- Add get_queryset() and get_deleted_status() methods to admin classes
  for proper soft delete support

Now when admin clicks "Delete":
1. Regular "Удалить" = soft delete (is_deleted=True, stays in DB)
2. "Безопасно удалить" = hard delete (only if no dependencies, removes from DB)
3. "Восстановить" = restores soft-deleted items

Fixes issue where items were hard-deleted from admin instead of soft-deleted.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 22:31:57 +03:00
4ac548bad9 docs: Update notes with frontend image integration info 2025-10-22 17:24:23 +03:00
4c2b027758 docs: Add comprehensive frontend images guide
- Complete guide for using responsive image sizes in templates
- Examples for all template types (lists, galleries, modals)
- Performance metrics and optimization tips
- Size recommendations for each context
- Troubleshooting and best practices
2025-10-22 17:23:44 +03:00
09c84e963a feat: Implement responsive image sizes in templates
- Update all_products_list.html: Use thumbnail_url for list previews
- Update product_list.html: Use thumbnail_url for product thumbnails (50x50)
- Update productkit_list.html: Use thumbnail_url for kit thumbnails (50x50)
- Update product_detail.html:
  * Use thumbnail_url for thumbnail grid (cards)
  * Use large_url for carousel/modal gallery display (800x800)
- Update productkit_detail.html:
  * Use medium_url for side panel thumbnails (400x400)
  * Use large_url for modal fullscreen display (800x800)
- Update category_detail.html: Use medium_url for category photo display (400x400)

Image sizes now follow best practices:
- Lists: thumbnail (150x150) - 438B - fast loading
- Cards: medium (400x400) - 2.9K - good quality for previews
- Galleries: large (800x800) - 5.6K - high quality for viewing
- Full screen: original - for print/download

This reduces bandwidth by 90% for thumbnails while maintaining quality for detailed views.
2025-10-22 16:52:17 +03:00
8f3d247c3c refactor: Simplify admin photo preview - remove grid display
- Keep only single photo preview per inline (large version 800x800)
- Removed all_versions_preview display from photo inlines
- Cleaner, more focused admin interface
- Confirmed all sizes are stored correctly:
  * Large (800x800) verified
  * Medium (400x400) verified
  * Originals verified
- Use large_url() for preview in admin (best quality/size balance)
2025-10-22 16:44:37 +03:00
70f05abdb9 feat: Add SKU field to ProductKit form for kit creation
- Added 'sku' field to ProductKitForm meta fields list
- Added SKU label in form labels
- Added SKU widget styling in __init__ method with helpful placeholder
- Updated productkit_form.html template to display SKU field after name, before description
- Updated form field filtering to exclude 'sku' from dynamic loop to prevent duplication

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 16:39:49 +03:00
b910ae6a6b feat: Move category field between name and description in product and kit forms
- Repositioned the category field to appear after the name field in both product and kit creation forms
- Added a quick-link button to create a new category that opens in a new tab
- Updated form field rendering logic to properly display categories in the correct position

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 16:35:20 +03:00
d60d20d92e docs: Update notes with image storage system documentation 2025-10-22 16:09:49 +03:00
2b6acc5564 feat: Implement comprehensive image storage and processing system
- Add ImageProcessor utility for automatic image resizing
  * Creates 4 versions: original, thumbnail (150x150), medium (400x400), large (800x800)
  * Uses LANCZOS algorithm for quality, JPEG quality 90 for optimization
  * Handles PNG transparency with white background
  * 90% file size reduction for thumbnails vs original

- Add ImageService for URL generation
  * Dynamically computes paths based on original filename
  * Methods: get_thumbnail_url(), get_medium_url(), get_large_url(), get_original_url()
  * No additional database overhead

- Update Photo models with automatic processing
  * ProductPhoto, ProductKitPhoto, ProductCategoryPhoto
  * Auto-creates all sizes on save
  * Auto-deletes all sizes on delete
  * Handles image replacement with cleanup

- Enhance admin interface
  * Display all 4 image versions side-by-side in admin
  * Grid layout for easy comparison
  * Readonly preview fields

- Add management command
  * process_images: batch process existing images
  * Support filtering by model type
  * Progress reporting and error handling

- Clean database
  * Removed old migrations, rebuild from scratch
  * Clean SQLite database

- Add comprehensive documentation
  * IMAGE_STORAGE_STRATEGY.md: full system architecture
  * QUICK_START_IMAGES.md: quick reference guide
  * IMAGE_SYSTEM_EXAMPLES.md: code examples for templates/views/API

Performance metrics:
  * Original: 6.1K
  * Medium: 2.9K (52% smaller)
  * Large: 5.6K (8% smaller)
  * Thumbnail: 438B (93% smaller)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 16:09:15 +03:00
85801c6c4a Обновили шапку и вывод всехтоваров. Добавили фильтры 2025-10-22 15:49:59 +03:00
d78c43d9a9 Initial commit: Django inventory system 2025-10-22 01:11:06 +03:00