photos fix

This commit is contained in:
pacnpal
2024-11-01 01:27:11 +00:00
parent 3cbda93094
commit 6265f82193
89 changed files with 2241 additions and 614 deletions

View File

@@ -1,6 +1,32 @@
from django.apps import AppConfig
from django.db.models.signals import post_migrate
def create_photo_permissions(sender, **kwargs):
"""Create custom permissions for photos"""
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from media.models import Photo
content_type = ContentType.objects.get_for_model(Photo)
Permission.objects.get_or_create(
codename='add_photo',
name='Can add photo',
content_type=content_type,
)
Permission.objects.get_or_create(
codename='change_photo',
name='Can change photo',
content_type=content_type,
)
Permission.objects.get_or_create(
codename='delete_photo',
name='Can delete photo',
content_type=content_type,
)
class MediaConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'media'
verbose_name = 'Media'
def ready(self):
post_migrate.connect(create_photo_permissions, sender=self)