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

[Django Upgrade] [ENG-4072] The Rest - Part 2 #10072

Merged
7 changes: 6 additions & 1 deletion api/draft_registrations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@
)
from api.taxonomies.serializers import TaxonomizableSerializerMixin
from osf.exceptions import DraftRegistrationStateError
from osf.models import Node
from website import settings


class NodeRelationshipField(RelationshipField):

def to_internal_value(self, node_id):
node = self.context['view'].get_node(node_id=node_id) if node_id else None
context_view = self.context['view']
if hasattr(context_view, 'get_node'):
node = self.context['view'].get_node(node_id=node_id) if node_id else None
else:
node = Node.load(node_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the upgrade, one test fails due to self.context['view'] returning an object not having .get_node. There is one concern of this fix since .get_node() checks permission and other stuff before loading the node. Might worth another look at the failed test.

return {'branched_from': node}


Expand Down