Browsable API: use input fields for relations.

This commit is contained in:
Tom Hacohen 2020-09-13 14:13:06 +03:00
parent c04650f890
commit 3de1d48b9e

View File

@ -187,6 +187,7 @@ class CollectionItemRevisionSerializer(BetterErrorsMixin, serializers.ModelSeria
chunks = ChunksField( chunks = ChunksField(
source='chunks_relation', source='chunks_relation',
queryset=models.RevisionChunkRelation.objects.all(), queryset=models.RevisionChunkRelation.objects.all(),
style={'base_template': 'input.html'},
many=True many=True
) )
meta = BinaryBase64Field() meta = BinaryBase64Field()
@ -317,6 +318,7 @@ class CollectionMemberSerializer(BetterErrorsMixin, serializers.ModelSerializer)
username = UserSlugRelatedField( username = UserSlugRelatedField(
source='user', source='user',
read_only=True, read_only=True,
style={'base_template': 'input.html'},
) )
class Meta: class Meta:
@ -341,7 +343,8 @@ class CollectionMemberSerializer(BetterErrorsMixin, serializers.ModelSerializer)
class CollectionInvitationSerializer(BetterErrorsMixin, serializers.ModelSerializer): class CollectionInvitationSerializer(BetterErrorsMixin, serializers.ModelSerializer):
username = UserSlugRelatedField( username = UserSlugRelatedField(
source='user', source='user',
queryset=User.objects queryset=User.objects,
style={'base_template': 'input.html'},
) )
collection = serializers.CharField(source='collection.uid') collection = serializers.CharField(source='collection.uid')
fromPubkey = BinaryBase64Field(source='fromMember.user.userinfo.pubkey', read_only=True) fromPubkey = BinaryBase64Field(source='fromMember.user.userinfo.pubkey', read_only=True)