Browse Source

Remove Features API

pull/1640/head
Hironsan 2 years ago
parent
commit
ca7c3a97f8
3 changed files with 2 additions and 87 deletions
  1. 8
      backend/api/urls.py
  2. 64
      backend/api/views/import_export.py
  3. 17
      backend/data_import/tests/test_views.py

8
backend/api/urls.py

@ -1,8 +1,7 @@
from django.urls import include, path from django.urls import include, path
from .views import (annotation, auto_labeling, comment, example, example_state, from .views import (annotation, auto_labeling, comment, example, example_state,
export_dataset, health, import_export, label, project, tag,
task)
export_dataset, health, label, project, tag, task)
from .views.tasks import category, relation, span, text from .views.tasks import category, relation, span, text
urlpatterns_project = [ urlpatterns_project = [
@ -204,11 +203,6 @@ urlpatterns = [
view=health.Health.as_view(), view=health.Health.as_view(),
name='health' name='health'
), ),
path(
route='features',
view=import_export.Features.as_view(),
name='features'
),
path( path(
route='projects', route='projects',
view=project.ProjectList.as_view(), view=project.ProjectList.as_view(),

64
backend/api/views/import_export.py

@ -1,64 +0,0 @@
from django.conf import settings
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
class Features(APIView):
permission_classes = (IsAuthenticated,)
def get(self, request, *args, **kwargs):
return Response({
'cloud_upload': bool(settings.CLOUD_BROWSER_APACHE_LIBCLOUD_PROVIDER),
})
# class CloudUploadAPI(APIView):
# permission_classes = TextUploadAPI.permission_classes
#
# def get(self, request, *args, **kwargs):
# try:
# project_id = request.query_params['project_id']
# file_format = request.query_params['upload_format']
# cloud_container = request.query_params['container']
# cloud_object = request.query_params['object']
# except KeyError as ex:
# raise ValidationError('query parameter {} is missing'.format(ex))
#
# try:
# cloud_file = self.get_cloud_object_as_io(cloud_container, cloud_object)
# except ContainerDoesNotExistError:
# raise ValidationError('cloud container {} does not exist'.format(cloud_container))
# except ObjectDoesNotExistError:
# raise ValidationError('cloud object {} does not exist'.format(cloud_object))
#
# TextUploadAPI.save_file(
# user=request.user,
# file=cloud_file,
# file_format=file_format,
# project_id=project_id,
# )
#
# next_url = request.query_params.get('next')
#
# if next_url == 'about:blank':
# return Response(data='', content_type='text/plain', status=status.HTTP_201_CREATED)
#
# if next_url:
# return redirect(next_url)
#
# return Response(status=status.HTTP_201_CREATED)
#
# @classmethod
# def get_cloud_object_as_io(cls, container_name, object_name):
# provider = settings.CLOUD_BROWSER_APACHE_LIBCLOUD_PROVIDER.lower()
# account = settings.CLOUD_BROWSER_APACHE_LIBCLOUD_ACCOUNT
# key = settings.CLOUD_BROWSER_APACHE_LIBCLOUD_SECRET_KEY
#
# driver = get_driver(DriverType.STORAGE, provider)
# client = driver(account, key)
#
# cloud_container = client.get_container(container_name)
# cloud_object = cloud_container.get_object(object_name)
#
# return iterable_to_io(cloud_object.as_stream())

17
backend/data_import/tests/test_views.py

@ -1,23 +1,8 @@
from django.test import override_settings
from rest_framework import status from rest_framework import status
from rest_framework.reverse import reverse from rest_framework.reverse import reverse
from api.models import DOCUMENT_CLASSIFICATION from api.models import DOCUMENT_CLASSIFICATION
from api.tests.api.utils import CRUDMixin, create_default_roles, make_user, prepare_project
class TestFeatures(CRUDMixin):
@classmethod
def setUpTestData(cls):
create_default_roles()
cls.user = make_user()
cls.url = reverse('features')
@override_settings(CLOUD_BROWSER_APACHE_LIBCLOUD_PROVIDER=None)
def test_no_cloud_upload(self):
response = self.assert_fetch(self.user, status.HTTP_200_OK)
self.assertFalse(response.json().get('cloud_upload'))
from api.tests.api.utils import CRUDMixin, prepare_project
class TestImportCatalog(CRUDMixin): class TestImportCatalog(CRUDMixin):

Loading…
Cancel
Save