Add require_submissions_enabled decorator to FileUploadViewSet Create (#22774)
* Added require_submissions_enabled decorator to FileUploadViewSet.create() * fix test, linting
This commit is contained in:
Родитель
c2fddde0c5
Коммит
e8a4b7de03
|
@ -121,6 +121,16 @@ class TestFileUploadViewSet(TestCase):
|
|||
)
|
||||
return response
|
||||
|
||||
def test_submissions_disabled(self):
|
||||
self.create_flag('enable-submissions', note=':-(', everyone=False)
|
||||
expected = {
|
||||
'error': 'Add-on uploads are temporarily unavailable.',
|
||||
'reason': ':-(',
|
||||
}
|
||||
response = self._create_post()
|
||||
assert response.status_code == 503
|
||||
assert response.json() == expected
|
||||
|
||||
def test_not_authenticated(self):
|
||||
self.client.logout_api()
|
||||
response = self.client.get(
|
||||
|
|
|
@ -10,6 +10,7 @@ from rest_framework.viewsets import ReadOnlyModelViewSet
|
|||
|
||||
import olympia.core.logger
|
||||
from olympia import amo
|
||||
from olympia.addons.decorators import require_submissions_enabled
|
||||
from olympia.amo.decorators import use_primary_db
|
||||
from olympia.amo.utils import HttpResponseXSendFile
|
||||
from olympia.api.authentication import (
|
||||
|
@ -72,6 +73,7 @@ class FileUploadViewSet(CreateModelMixin, ReadOnlyModelViewSet):
|
|||
def get_queryset(self):
|
||||
return super().get_queryset().filter(user=self.request.user)
|
||||
|
||||
@require_submissions_enabled
|
||||
def create(self, request):
|
||||
if 'upload' in request.FILES:
|
||||
filedata = request.FILES['upload']
|
||||
|
|
Загрузка…
Ссылка в новой задаче