Skip to content

Commit

Permalink
move InstitutionRelated into institutions folder
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Jul 5, 2024
1 parent ce081ce commit e3425bf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
1 change: 0 additions & 1 deletion api/base/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,3 @@ def has_object_permission(self, request, view, obj):
return resource.is_public or resource.can_view(auth)
else:
return resource.has_permission(auth.user, osf_permissions.WRITE)

6 changes: 6 additions & 0 deletions api/institutions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,9 @@ def get_absolute_url(self, obj):
'version': 'v2',
},
)


class InstitutionRelated(JSONAPIRelationshipSerializer):
id = ser.CharField(source='_id', required=False, allow_null=True)
class Meta:
type_ = 'institutions'
7 changes: 1 addition & 6 deletions api/nodes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
)
from api.base.serializers import (
VersionedDateTimeField, HideIfRegistration, IDField,
JSONAPIRelationshipSerializer,
JSONAPISerializer, LinksField,
NodeFileHyperLinkField, RelationshipField,
ShowIfVersion, TargetTypeField, TypeField,
Expand Down Expand Up @@ -42,6 +41,7 @@
from website.project import new_private_link
from website.project.model import NodeUpdateError
from osf.utils import permissions as osf_permissions
from api.institutions.serializers import InstitutionRelated


class RegistrationProviderRelationshipField(RelationshipField):
Expand Down Expand Up @@ -1467,11 +1467,6 @@ def get_storage_addons_url(self, obj):
},
)

class InstitutionRelated(JSONAPIRelationshipSerializer):
id = ser.CharField(source='_id', required=False, allow_null=True)
class Meta:
type_ = 'institutions'


class NodeInstitutionsRelationshipSerializer(BaseAPISerializer):
data = ser.ListField(child=InstitutionRelated())
Expand Down
9 changes: 1 addition & 8 deletions api/preprints/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
WaterbutlerLink,
HideIfPreprint,
LinkedNodesRelationshipSerializer,
JSONAPIRelationshipSerializer,
)
from api.base.utils import absolute_reverse, get_user_auth
from api.base.parsers import NO_DATA_ERROR
Expand All @@ -40,6 +39,7 @@
)
from api.base.metrics import MetricsSerializerMixin
from api.taxonomies.serializers import TaxonomizableSerializerMixin
from api.institutions.serializers import InstitutionRelated
from framework.exceptions import PermissionsError
from website.project import signals as project_signals
from osf.exceptions import NodeStateError, PreprintStateError
Expand Down Expand Up @@ -534,13 +534,6 @@ def update(self, instance, validated_data):
})


class InstitutionRelated(JSONAPIRelationshipSerializer):
id = ser.CharField(source='_id', required=False, allow_null=True)

class Meta:
type_ = 'institutions'


class PreprintsInstitutionsRelationshipSerializer(BaseAPISerializer):
data = ser.ListField(child=InstitutionRelated())

Expand Down

0 comments on commit e3425bf

Please sign in to comment.