Skip to content

Commit

Permalink
Fix default REST_FRAMEWORK permission classes could break api views
Browse files Browse the repository at this point in the history
  • Loading branch information
bmihelac committed Jan 5, 2022
1 parent 08272a9 commit ebe4e91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions wagtail_localize/test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,12 @@


DEFAULT_AUTO_FIELD = "django.db.models.AutoField"


# wagtail localize should not use DEFAULT_PERMISSION_CLASSES
# see: https://github.com/wagtail/wagtail-localize/issues/499
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
],
}
5 changes: 4 additions & 1 deletion wagtail_localize/views/edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from django.views.decorators.http import require_POST
from modelcluster.fields import ParentalKey
from rest_framework import serializers, status
from rest_framework.decorators import api_view
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from wagtail.admin import messages
from wagtail.admin.edit_handlers import (
Expand Down Expand Up @@ -984,6 +985,7 @@ def restart_translation(request, translation, instance):


@api_view(["PUT", "DELETE"])
@permission_classes([IsAuthenticated])
def edit_string_translation(request, translation_id, string_segment_id):
translation = get_object_or_404(Translation, id=translation_id)
string_segment = get_object_or_404(StringSegment, id=string_segment_id)
Expand Down Expand Up @@ -1041,6 +1043,7 @@ def edit_string_translation(request, translation_id, string_segment_id):


@api_view(["PUT", "DELETE"])
@permission_classes([IsAuthenticated])
def edit_override(request, translation_id, overridable_segment_id):
translation = get_object_or_404(Translation, id=translation_id)
overridable_segment = get_object_or_404(
Expand Down

0 comments on commit ebe4e91

Please sign in to comment.