Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6812] BE Code clean-up - part 1 #10900

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading