Skip to content

Commit

Permalink
Merge pull request #10900 from cslzchen/feature/be-code-clean-up
Browse files Browse the repository at this point in the history
[ENG-6812] BE Code clean-up - part 1
  • Loading branch information
cslzchen authored Jan 9, 2025
2 parents 608cce3 + d587741 commit 989ffd5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions api/base/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions api/guids/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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',
)
Expand Down
2 changes: 1 addition & 1 deletion osf/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
BlackListGuid,
Guid,
GuidVersionsThrough,
VersionedGuidMixin
VersionedGuidMixin,
)
from .brand import Brand
from .cedar_metadata import CedarMetadataRecord, CedarMetadataTemplate
Expand Down
1 change: 0 additions & 1 deletion osf/models/preprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 989ffd5

Please sign in to comment.