Skip to content

Commit

Permalink
non working - try to override_settings DEFAULT_PERMISSION_CLASSES
Browse files Browse the repository at this point in the history
  • Loading branch information
bmihelac committed Jan 5, 2022
1 parent ebe4e91 commit d6ec08b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions wagtail_localize/test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@

# 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"
],
}
# REST_FRAMEWORK = {
# "DEFAULT_PERMISSION_CLASSES": [
# "rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
# ],
# }
9 changes: 8 additions & 1 deletion wagtail_localize/tests/test_edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.messages import get_messages
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy
Expand Down Expand Up @@ -2226,6 +2226,13 @@ def test_cant_edit_overrides_without_page_perms(self):

self.assertEqual(response.status_code, 403)

def test_update_override_with_default_permissions_classes(self):
with override_settings(REST_FRAMEWORK={'DEFAULT_PERMISSION_CLASSES': ["rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"]}):
from wagtail_localize.views.edit_translation import edit_override
from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly
print(edit_override.view_class.permission_classes)
assert edit_override.view_class.permission_classes == [DjangoModelPermissionsOrAnonReadOnly]


class TestDownloadPOFileView(EditTranslationTestData, TestCase):
def test_download_pofile_page(self):
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize/views/edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def edit_string_translation(request, translation_id, string_segment_id):


@api_view(["PUT", "DELETE"])
@permission_classes([IsAuthenticated])
# @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 d6ec08b

Please sign in to comment.