mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 10:51:09 -05:00
- Cleaned up and standardized assertions in ApiTestMixin for API response validation. - Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE. - Removed unused imports and improved formatting in settings.py. - Refactored URL patterns in urls.py for better readability and organization. - Enhanced view functions in views.py for consistency and clarity. - Added .flake8 configuration for linting and style enforcement. - Introduced type stubs for django-environ to improve type checking with Pylance.
35 lines
1021 B
Python
35 lines
1021 B
Python
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"
|
|
|
|
def ready(self):
|
|
post_migrate.connect(create_photo_permissions, sender=self)
|