27 lines
982 B
Python
27 lines
982 B
Python
|
from rest_framework import serializers
|
||
|
from users.models import UserCredentialsForBlockchain, BlockchainUserInfo
|
||
|
from django.contrib.auth import get_user_model
|
||
|
from mnfapp.models import centralDatabase
|
||
|
|
||
|
User = get_user_model()
|
||
|
|
||
|
class BlockchainUserInfoSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = BlockchainUserInfo
|
||
|
fields = "__all__"
|
||
|
|
||
|
class UserCredentialsForBlockchainSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = UserCredentialsForBlockchain
|
||
|
fields = ('publicKey',)
|
||
|
|
||
|
class ProfileSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = centralDatabase
|
||
|
fields = ('firstName','lastName','address', 'contact', 'profile_photo')
|
||
|
|
||
|
class UserSerializer(serializers.ModelSerializer):
|
||
|
centraldatabase = ProfileSerializer(source='centraldatabase_set.first', read_only=True)
|
||
|
class Meta:
|
||
|
model = User
|
||
|
fields = ('id', 'username', 'email','first_name','last_name', 'centraldatabase')
|