Team managers/coaches now only see their own teams, can't create teams, and can view (but not edit) positions -- admins keep full rights. Locations and Opponents move from read-only stubs to full CRUD, gated to admins and management-position staff, with a country dropdown (django-countries) instead of free text. Also: the team list shows player/staff counts, and deleting a news item's main photo promotes another one instead of leaving the item without one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1gj3J1QPfP38XWpnpbFpy
19 lines
681 B
Python
19 lines
681 B
Python
"""Keep NewsPhoto's file in sync with the row: deleting a NewsPhoto -- one at
|
|
a time, or in bulk via a News item's cascade -- must also delete the image
|
|
from storage, or it just accumulates orphaned files forever.
|
|
|
|
Connecting a post_delete receiver also stops Django's fast-delete
|
|
optimisation for a News cascade, so every NewsPhoto instance (and this
|
|
signal) actually runs instead of being collapsed into one bulk SQL DELETE.
|
|
"""
|
|
|
|
from django.db.models.signals import post_delete
|
|
from django.dispatch import receiver
|
|
|
|
from .models import NewsPhoto
|
|
|
|
|
|
@receiver(post_delete, sender=NewsPhoto)
|
|
def delete_photo_file(sender, instance, **kwargs):
|
|
instance.image.delete(save=False)
|