diff --git a/addons/base/views.py b/addons/base/views.py index cb73a4552db..89951d905f8 100644 --- a/addons/base/views.py +++ b/addons/base/views.py @@ -391,9 +391,7 @@ def get_auth(auth, **kwargs): waterbutler_data = decrypt_and_decode_jwt_payload() # Authenticate the resource based on the node_id and handle potential draft nodes - nid = waterbutler_data.get('nid') - - resource = get_authenticated_resource(nid) + resource = get_authenticated_resource(waterbutler_data.get('nid')) # Authenticate the user using cookie or Oauth if possible authenticate_user_if_needed(auth, waterbutler_data, resource) diff --git a/api/base/filters.py b/api/base/filters.py index 4d9bc37a442..30b9ea87a3d 100644 --- a/api/base/filters.py +++ b/api/base/filters.py @@ -292,6 +292,9 @@ def parse_query_params(self, query_params): field_name: self._parse_date_param(field, source_field_name, op, value), }) elif not isinstance(value, int) and source_field_name in ['_id', 'guid._id']: + # TODO: this is broken since value can be a multi-value str separated by comma; in addition, + # as for a single-versioned-guid value, the filter is `or` but we need `and`; this will + # be fixed in [ENG-6878](https://openscience.atlassian.net/browse/ENG-6878). base_guid, version = Guid.split_guid(value) if base_guid is None and version is None: raise InvalidFilterValue( diff --git a/api/guids/views.py b/api/guids/views.py index 4a0d1ab4a5b..de9171a0451 100644 --- a/api/guids/views.py +++ b/api/guids/views.py @@ -11,7 +11,6 @@ from api.base.utils import get_object_or_error, is_truthy from api.guids.serializers import GuidSerializer from osf.models import Guid -from osf.models.base import VersionedGuidMixin class GuidDetail(JSONAPIBaseView, generics.RetrieveAPIView): @@ -50,9 +49,10 @@ def get_serializer_class(self): return None def get_object(self): + base_guid_str, _ = Guid.split_guid(self.kwargs['guids']) return get_object_or_error( Guid, - self.kwargs['guids'].split(VersionedGuidMixin.GUID_VERSION_DELIMITER)[0], # .split('_v')[0] to support versioned preprints + base_guid_str, self.request, display_name='guid', ) diff --git a/osf/models/__init__.py b/osf/models/__init__.py index 170f6949a4b..652d94942a9 100644 --- a/osf/models/__init__.py +++ b/osf/models/__init__.py @@ -17,7 +17,7 @@ BlackListGuid, Guid, GuidVersionsThrough, - VersionedGuidMixin + VersionedGuidMixin, ) from .brand import Brand from .cedar_metadata import CedarMetadataRecord, CedarMetadataTemplate diff --git a/osf/models/preprint.py b/osf/models/preprint.py index 6a8c29ce7b5..af689522eea 100644 --- a/osf/models/preprint.py +++ b/osf/models/preprint.py @@ -1554,7 +1554,6 @@ def run_accept(self, user, comment, **kwargs): versioned_guid.save() return ret - # Override ReviewableMixin def run_reject(self, user, comment): """Override `ReviewableMixin`/`MachineableMixin`. Run the 'reject' state transition and create a corresponding Action.