mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 08:51:09 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
@@ -3,26 +3,46 @@ from django.db.models.signals import post_migrate
|
||||
|
||||
|
||||
def create_photo_permissions(sender, **kwargs):
|
||||
"""Create custom permissions for photos"""
|
||||
"""Create custom permissions for domain-specific photo models"""
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from apps.media.models import Photo
|
||||
from apps.parks.models import ParkPhoto
|
||||
from apps.rides.models import RidePhoto
|
||||
|
||||
content_type = ContentType.objects.get_for_model(Photo)
|
||||
# Create permissions for ParkPhoto
|
||||
park_photo_content_type = ContentType.objects.get_for_model(ParkPhoto)
|
||||
Permission.objects.get_or_create(
|
||||
codename="add_photo",
|
||||
name="Can add photo",
|
||||
content_type=content_type,
|
||||
codename="add_parkphoto",
|
||||
name="Can add park photo",
|
||||
content_type=park_photo_content_type,
|
||||
)
|
||||
Permission.objects.get_or_create(
|
||||
codename="change_photo",
|
||||
name="Can change photo",
|
||||
content_type=content_type,
|
||||
codename="change_parkphoto",
|
||||
name="Can change park photo",
|
||||
content_type=park_photo_content_type,
|
||||
)
|
||||
Permission.objects.get_or_create(
|
||||
codename="delete_photo",
|
||||
name="Can delete photo",
|
||||
content_type=content_type,
|
||||
codename="delete_parkphoto",
|
||||
name="Can delete park photo",
|
||||
content_type=park_photo_content_type,
|
||||
)
|
||||
|
||||
# Create permissions for RidePhoto
|
||||
ride_photo_content_type = ContentType.objects.get_for_model(RidePhoto)
|
||||
Permission.objects.get_or_create(
|
||||
codename="add_ridephoto",
|
||||
name="Can add ride photo",
|
||||
content_type=ride_photo_content_type,
|
||||
)
|
||||
Permission.objects.get_or_create(
|
||||
codename="change_ridephoto",
|
||||
name="Can change ride photo",
|
||||
content_type=ride_photo_content_type,
|
||||
)
|
||||
Permission.objects.get_or_create(
|
||||
codename="delete_ridephoto",
|
||||
name="Can delete ride photo",
|
||||
content_type=ride_photo_content_type,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user