Skip to content

Commit

Permalink
remove all traces of quickfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Mar 16, 2022
1 parent 5c1ae0d commit f2785f7
Show file tree
Hide file tree
Showing 49 changed files with 46 additions and 991 deletions.
2 changes: 1 addition & 1 deletion README-docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
- Needed for api v2 citation style rendering.
- `docker-compose run --rm web python3 -m scripts.parse_citation_styles`
- Start ember_osf_web
- Needed for quickfiles feature:
- Needed for ember app:
- `docker-compose up -d ember_osf_web`
- OPTIONAL: Register OAuth Scopes
- Needed for things such as the ember-osf dummy app
Expand Down
17 changes: 3 additions & 14 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from api.caching.tasks import update_storage_usage_with_size

from addons.base.models import BaseStorageAddon
from addons.osfstorage.models import OsfStorageFile
from addons.osfstorage.models import OsfStorageFileNode
from addons.osfstorage.utils import update_analytics

Expand All @@ -33,7 +32,7 @@
from framework.auth.decorators import collect_auth, must_be_logged_in, must_be_signed
from framework.exceptions import HTTPError
from framework.sentry import log_exception
from framework.routing import json_renderer, proxy_url
from framework.routing import json_renderer
from framework.transactions.handlers import no_auto_transaction
from website import mails
from website import settings
Expand Down Expand Up @@ -403,7 +402,7 @@ def get_auth(auth, **kwargs):

@must_be_signed
@no_auto_transaction
@must_be_valid_project(quickfiles_valid=True, preprints_valid=True)
@must_be_valid_project(preprints_valid=True)
def create_waterbutler_log(payload, **kwargs):
with transaction.atomic():
try:
Expand Down Expand Up @@ -523,7 +522,7 @@ def create_waterbutler_log(payload, **kwargs):
metadata = payload.get('metadata') or payload.get('destination')

target_node = AbstractNode.load(metadata.get('nid'))
if target_node and not target_node.is_quickfiles and payload['action'] != 'download_file':
if target_node and payload['action'] != 'download_file':
update_storage_usage_with_size(payload)

with transaction.atomic():
Expand Down Expand Up @@ -847,16 +846,6 @@ def persistent_file_download(auth, **kwargs):
)


def addon_view_or_download_quickfile(**kwargs):
fid = kwargs.get('fid', 'NOT_AN_FID')
file_ = OsfStorageFile.load(fid)
if not file_:
raise HTTPError(http_status.HTTP_404_NOT_FOUND, data={
'message_short': 'File Not Found',
'message_long': 'The requested file could not be found.'
})
return proxy_url('/project/{}/files/osfstorage/{}/'.format(file_.target._id, fid))

def addon_view_file(auth, node, file_node, version):
# TODO: resolve circular import issue
from addons.wiki import settings as wiki_settings
Expand Down
2 changes: 1 addition & 1 deletion addons/osfstorage/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from framework.auth import cas

from osf import features
from osf.models import Tag, QuickFilesNode
from osf.models import Tag
from osf.models import files as models
from addons.osfstorage.apps import osf_storage_root
from addons.osfstorage import utils
Expand Down
3 changes: 0 additions & 3 deletions addons/osfstorage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ def osfstorage_create_child(file_node, payload, **kwargs):
if not (name or user) or '/' in name:
raise HTTPError(http_status.HTTP_400_BAD_REQUEST)

if getattr(file_node.target, 'is_quickfiles', False) and is_folder:
raise HTTPError(http_status.HTTP_400_BAD_REQUEST, data={'message_long': 'You may not create a folder for QuickFiles'})

try:
# Create a save point so that we can rollback and unlock
# the parent record
Expand Down
7 changes: 2 additions & 5 deletions api/caching/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def update_storage_usage_cache(target_id, target_guid, per_page=500000):
def update_storage_usage(target):
Preprint = apps.get_model('osf.preprint')

if settings.ENABLE_STORAGE_USAGE_CACHE and not isinstance(target, Preprint) and not target.is_quickfiles:
if settings.ENABLE_STORAGE_USAGE_CACHE and not isinstance(target, Preprint):
enqueue_postcommit_task(update_storage_usage_cache, (target.id, target._id,), {}, celery=True)

def update_storage_usage_with_size(payload):
Expand All @@ -151,9 +151,6 @@ def update_storage_usage_with_size(payload):
return
target_node = AbstractNode.load(metadata['nid'])

if target_node.is_quickfiles:
return

action = payload['action']
provider = metadata.get('provider', 'osfstorage')

Expand Down Expand Up @@ -182,7 +179,7 @@ def update_storage_usage_with_size(payload):
source_provider = payload['source']['provider']
if target_node == source_node and source_provider == provider:
return # Its not going anywhere.
if source_provider == 'osfstorage' and not source_node.is_quickfiles:
if source_provider == 'osfstorage':
if source_node.storage_limit_status is settings.StorageLimits.NOT_CALCULATED:
return update_storage_usage(source_node)

Expand Down
12 changes: 0 additions & 12 deletions api/files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,6 @@ class FileDetailSerializer(FileSerializer):
id = IDField(source='_id', required=True)


class QuickFilesSerializer(BaseFileSerializer):
user = RelationshipField(
related_view='users:user-detail',
related_view_kwargs={'user_id': '<target.creator._id>'},
help_text='The user who uploaded this file',
)


class QuickFilesDetailSerializer(QuickFilesSerializer):
id = IDField(source='_id', required=True)


class FileVersionSerializer(JSONAPISerializer):
filterable_fields = frozenset([
'id',
Expand Down
22 changes: 3 additions & 19 deletions api/files/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

from rest_framework import generics
from rest_framework import permissions as drf_permissions
from rest_framework.exceptions import NotFound, PermissionDenied, ValidationError
from rest_framework.exceptions import NotFound, ValidationError

from framework.auth.oauth_scopes import CoreScopes

from osf.models import (
Guid,
BaseFileNode,
FileVersion,
QuickFilesNode,
)

from api.base.exceptions import Gone
Expand All @@ -27,7 +26,7 @@
from api.files.permissions import CheckedOutOrAdmin
from api.files.permissions import FileMetadataRecordPermission
from api.files.serializers import FileSerializer
from api.files.serializers import FileDetailSerializer, QuickFilesDetailSerializer
from api.files.serializers import FileDetailSerializer
from api.files.serializers import FileMetadataRecordSerializer
from api.files.serializers import FileVersionSerializer
from osf.utils.permissions import ADMIN
Expand All @@ -54,10 +53,6 @@ def get_file(self, check_permissions=True):
if getattr(obj.target, 'deleted', None):
raise Gone(detail='The requested file is no longer available')

if getattr(obj.target, 'is_quickfiles', False) and getattr(obj.target, 'creator'):
if obj.target.creator.is_disabled:
raise Gone(detail='This user has been deactivated and their quickfiles are no longer available.')

if check_permissions:
# May raise a permission denied
self.check_object_permissions(self.request, obj)
Expand All @@ -84,16 +79,6 @@ class FileDetail(JSONAPIBaseView, generics.RetrieveUpdateAPIView, FileMixin):
view_category = 'files'
view_name = 'file-detail'

def get_serializer_class(self):
try:
target = self.get_target()
except (NotFound, Gone, PermissionDenied):
return FileDetailSerializer
else:
if isinstance(target, QuickFilesNode):
return QuickFilesDetailSerializer
return FileDetailSerializer

def get_target(self):
return self.get_file().target

Expand All @@ -103,8 +88,7 @@ def get_object(self):
file = self.get_file()

if self.request.GET.get('create_guid', False):
# allows quickfiles to be given guids when another user wants a permanent link to it
if (self.get_target().has_permission(user, ADMIN) and utils.has_admin_scope(self.request)) or getattr(file.target, 'is_quickfiles', False):
if self.get_target().has_permission(user, ADMIN) and utils.has_admin_scope(self.request):
file.get_guid(create=True)
return file

Expand Down
1 change: 0 additions & 1 deletion api/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
url(r'^(?P<user_id>\w+)/preprints/$', views.UserPreprints.as_view(), name=views.UserPreprints.view_name),
url(r'^(?P<user_id>\w+)/registrations/$', views.UserRegistrations.as_view(), name=views.UserRegistrations.view_name),
url(r'^(?P<user_id>\w+)/settings/$', views.UserSettings.as_view(), name=views.UserSettings.view_name),
url(r'^(?P<user_id>\w+)/quickfiles/$', views.UserQuickFiles.as_view(), name=views.UserQuickFiles.view_name),
url(r'^(?P<user_id>\w+)/relationships/institutions/$', views.UserInstitutionsRelationship.as_view(), name=views.UserInstitutionsRelationship.view_name),
url(r'^(?P<user_id>\w+)/settings/emails/$', views.UserEmailsList.as_view(), name=views.UserEmailsList.view_name),
url(r'^(?P<user_id>\w+)/settings/emails/(?P<email_id>\w+)/$', views.UserEmailsDetail.as_view(), name=views.UserEmailsDetail.view_name),
Expand Down
18 changes: 1 addition & 17 deletions api/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from api.addons.views import AddonSettingsMixin
from api.base import permissions as base_permissions
from api.base.waffle_decorators import require_flag
from api.base.exceptions import Conflict, UserGone, Gone
from api.base.exceptions import Conflict, UserGone
from api.base.filters import ListFilterMixin, PreprintFilterMixin
from api.base.parsers import (
JSONAPIRelationshipParser,
Expand Down Expand Up @@ -361,22 +361,6 @@ def get_queryset(self):
return self.get_queryset_from_request()


class UserQuickFiles(JSONAPIBaseView, generics.ListAPIView):
view_category = 'users'
view_name = 'user-quickfiles'

permission_classes = (
drf_permissions.IsAuthenticatedOrReadOnly,
base_permissions.TokenHasScope,
)

required_read_scopes = [CoreScopes.NULL]
required_write_scopes = [CoreScopes.NULL]

def get(self, *args, **kwargs):
raise Gone()


class UserPreprints(JSONAPIBaseView, generics.ListAPIView, UserMixin, PreprintFilterMixin):
"""The documentation for this endpoint can be found [here](https://developer.osf.io/#operation/users_preprints_list).
"""
Expand Down
6 changes: 1 addition & 5 deletions api_tests/files/views/test_file_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from api.base.settings.defaults import API_BASE
from api_tests import utils as api_utils
from framework.auth.core import Auth
from osf.models import NodeLog, Session, QuickFilesNode
from osf.models import NodeLog, Session
from osf.utils.permissions import WRITE, READ
from osf.utils.workflows import DefaultStates
from osf_tests.factories import (
Expand Down Expand Up @@ -48,10 +48,6 @@ class TestFileView:
def node(self, user):
return ProjectFactory(creator=user, comment_level='public')

@pytest.fixture()
def quickfiles_node(self, user):
return QuickFilesNode.objects.get(creator=user)

@pytest.fixture()
def file(self, user, node):
return api_utils.create_test_file(node, user, create_guid=False)
Expand Down
23 changes: 0 additions & 23 deletions api_tests/wb/views/test_wb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest

from addons.osfstorage.models import OsfStorageFolder
from framework.auth import signing

from osf_tests.factories import (
Expand All @@ -11,26 +10,12 @@
PreprintFactory
)
from api_tests.utils import create_test_file, create_test_preprint_file
from osf.models import QuickFilesNode


@pytest.fixture()
def user():
return AuthUserFactory()

@pytest.fixture()
def quickfiles_node(user):
return QuickFilesNode.objects.get_for_user(user)

@pytest.fixture()
def quickfiles_file(user, quickfiles_node):
file = create_test_file(quickfiles_node, user, filename='road_dogg.mp3')
return file

@pytest.fixture()
def quickfiles_folder(quickfiles_node):
return OsfStorageFolder.objects.get_root(target=quickfiles_node)

@pytest.fixture()
def node(user):
return ProjectFactory(creator=user)
Expand Down Expand Up @@ -74,10 +59,6 @@ class TestMove():
def move_url(self, node):
return '/_/wb/hooks/{}/move/'.format(node._id)

@pytest.fixture()
def quickfiles_move_url(self, quickfiles_node):
return '/_/wb/hooks/{}/move/'.format(quickfiles_node._id)

@pytest.fixture()
def payload(self, file, folder, root_node, user):
return {
Expand Down Expand Up @@ -570,10 +551,6 @@ class TestCopy():
def copy_url(self, node):
return '/_/wb/hooks/{}/copy/'.format(node._id)

@pytest.fixture()
def quickfiles_copy_url(self, quickfiles_node):
return '/_/wb/hooks/{}/copy/'.format(quickfiles_node._id)

@pytest.fixture()
def payload(self, file, folder, root_node, user):
return {
Expand Down
27 changes: 0 additions & 27 deletions osf/management/commands/data_storage_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,6 @@
GROUP BY node.type, node.is_public
"""

# Aggregation of non-deleted quick file sizes (NOTE: This will break when QuickFolders is merged)
ND_QUICK_FILE_SIZE_SUM_SQL = """
SELECT
node.type, sum(size)
FROM osf_basefileversionsthrough AS obfnv
LEFT JOIN osf_basefilenode file ON obfnv.basefilenode_id = file.id
LEFT JOIN osf_fileversion version ON obfnv.fileversion_id = version.id
LEFT JOIN osf_abstractnode node ON file.target_object_id = node.id
WHERE file.provider = 'osfstorage' AND file.target_content_type_id = %s
AND node.type = 'osf.quickfilesnode'
AND node.is_deleted = False
AND file.deleted_on IS NULL
AND obfnv.id >= %s AND obfnv.id <= %s
GROUP BY node.type
"""

# Aggregation of size of non-deleted files in preprint supplemental nodes based on the node query above
ND_PREPRINT_SUPPLEMENT_SIZE_SUM_SQL = """
SELECT
Expand Down Expand Up @@ -321,16 +304,6 @@ def gather_usage_data(start, end, dry_run, zip_file):
cursor=cursor,
))

# TODO: Move the next when Quick Folders is done
logger.debug('Gathering quickfile summary at {}'.format(datetime.datetime.now()))
summary_data = combine_summary_data(summary_data, summarize(
sql=ND_QUICK_FILE_SIZE_SUM_SQL,
content_type=abstractnode_content_type,
start=start,
end=end,
cursor=cursor,
))

logger.debug('Gathering supplement summary at {}'.format(datetime.datetime.now()))
summary_data = combine_summary_data(summary_data, summarize(
sql=ND_PREPRINT_SUPPLEMENT_SIZE_SUM_SQL,
Expand Down
Loading

0 comments on commit f2785f7

Please sign in to comment.