Skip to content

Commit

Permalink
[Fixes #104] Bug: setting a funder with fundingreference is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
mwallschlaeger committed Jun 6, 2024
1 parent 1ba8776 commit fbd0450
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
2 changes: 1 addition & 1 deletion geonode/base/api/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def to_internal_value_single(self, data, serializer):
funder = Funder.objects.get_or_create(**data)
except TypeError:
raise ParseError(detail="Could not convert related_identifier to internal object ...", code=400)
return funder
return funder[0]


class ComplexDynamicRelationField(DynamicRelationField):
Expand Down
63 changes: 26 additions & 37 deletions geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,37 +414,37 @@ def get_attribute(self, instance):
return False



class UserSerializer(BaseDynamicModelSerializer):
class Meta:
ref_name = "UserProfile"
model = get_user_model()
name = "user"
view_name = "users-list"
fields = ("pk",
"username",
"first_name",
"last_name",
"avatar",
"perms",
"is_superuser",
"is_staff",
"email",
"organization",
"profile",
"position",
"voice",
"fax",
"delivery",
"city",
"area",
"zipcode",
"keywords",
"country",
"language",
"timezone",
"orcid_identifier"
)
fields = (
"pk",
"username",
"first_name",
"last_name",
"avatar",
"perms",
"is_superuser",
"is_staff",
"email",
"organization",
"profile",
"position",
"voice",
"fax",
"delivery",
"city",
"area",
"zipcode",
"keywords",
"country",
"language",
"timezone",
"orcid_identifier",
)

@classmethod
def setup_eager_loading(cls, queryset):
Expand All @@ -466,10 +466,7 @@ def to_representation(self, instance):
return data

avatar = AvatarUrlField(240, read_only=True)
keywords = ComplexDynamicRelationField(
SimpleHierarchicalKeywordSerializer, embed=False, many=True
)

keywords = ComplexDynamicRelationField(SimpleHierarchicalKeywordSerializer, embed=False, many=True)


class ContactRoleField(DynamicComputedField):
Expand Down Expand Up @@ -995,14 +992,6 @@ class Meta:
fields = "__all__"


class FundingReferenceSerializer(DynamicModelSerializer):
class Meta:
name = "fundingreferences"
model = FundingReference
count_type = "fundingreferences"
fields = "__all__"


class RelatedProjectSerializer(DynamicModelSerializer):
class Meta:
name = "relatedprojects"
Expand Down

0 comments on commit fbd0450

Please sign in to comment.