mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-27 08:07:04 -05:00
feat: Introduce lists and reviews apps, refactor user list functionality from accounts, and add user profile fields.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# Generated by Django 5.1.6 on 2025-12-26 14:10
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("contenttypes", "0002_remove_content_type_name"),
|
||||
("core", "0003_pageviewevent_slughistoryevent_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="slughistory",
|
||||
options={
|
||||
"ordering": ["-created_at"],
|
||||
"verbose_name": "Slug History",
|
||||
"verbose_name_plural": "Slug Histories",
|
||||
},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistory",
|
||||
name="content_type",
|
||||
field=models.ForeignKey(
|
||||
help_text="Type of model this slug belongs to",
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="contenttypes.contenttype",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistory",
|
||||
name="object_id",
|
||||
field=models.CharField(
|
||||
help_text="ID of the object this slug belongs to", max_length=50
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistory",
|
||||
name="old_slug",
|
||||
field=models.SlugField(help_text="Previous slug value", max_length=200),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistoryevent",
|
||||
name="content_type",
|
||||
field=models.ForeignKey(
|
||||
db_constraint=False,
|
||||
help_text="Type of model this slug belongs to",
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="contenttypes.contenttype",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistoryevent",
|
||||
name="object_id",
|
||||
field=models.CharField(
|
||||
help_text="ID of the object this slug belongs to", max_length=50
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="slughistoryevent",
|
||||
name="old_slug",
|
||||
field=models.SlugField(
|
||||
db_index=False, help_text="Previous slug value", max_length=200
|
||||
),
|
||||
),
|
||||
]
|
||||
18
backend/apps/core/permissions.py
Normal file
18
backend/apps/core/permissions.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from rest_framework import permissions
|
||||
|
||||
class IsOwnerOrReadOnly(permissions.BasePermission):
|
||||
"""
|
||||
Custom permission to only allow owners of an object to edit it.
|
||||
"""
|
||||
|
||||
def has_object_permission(self, request, view, obj):
|
||||
# Read permissions are allowed to any request,
|
||||
# so we'll always allow GET, HEAD or OPTIONS requests.
|
||||
if request.method in permissions.SAFE_METHODS:
|
||||
return True
|
||||
|
||||
# Write permissions are only allowed to the owner of the object.
|
||||
# Assumes the model instance has an `user` attribute.
|
||||
if hasattr(obj, 'user'):
|
||||
return obj.user == request.user
|
||||
return False
|
||||
Reference in New Issue
Block a user