Esempio n. 1
0
class UserProfileSerializer(serializers.ModelSerializer):
    id = serializers.SerializerMethodField()
    first_name = serializers.SerializerMethodField()
    last_name = serializers.SerializerMethodField()
    location = serializers.SerializerMethodField()
    availability = AvailabilitySerializer()
    skills = SkillSerializer(many=True)
    language = serializers.SerializerMethodField()
    biography = serializers.SerializerMethodField()

    class Meta:
        model = UserProfile
        fields = ('id', 'first_name', 'last_name', 'url_slug', 'image',
                  'background_image', 'biography', 'is_profile_verified',
                  'availability', 'skills', 'website', 'location', 'language')

    def get_id(self, obj):
        return obj.user.id

    def get_first_name(self, obj):
        return obj.user.first_name

    def get_last_name(self, obj):
        return obj.user.last_name

    def get_location(self, obj):
        if obj.location == None:
            return None
        return obj.location.name

    def get_language(self, obj):
        return obj.language.language_code

    def get_biography(self, obj):
        return get_user_profile_biography(obj, get_language())
Esempio n. 2
0
class PersonalProfileSerializer(serializers.ModelSerializer):
    id = serializers.SerializerMethodField()
    email = serializers.SerializerMethodField()
    first_name = serializers.SerializerMethodField()
    last_name = serializers.SerializerMethodField()
    location = serializers.SerializerMethodField()
    availability = AvailabilitySerializer()
    skills = SkillSerializer(many=True)

    class Meta:
        model = UserProfile
        fields = ('id', 'email', 'first_name', 'last_name', 'url_slug',
                  'image', 'background_image', 'location', 'biography',
                  'is_profile_verified', 'availability', 'skills',
                  'has_logged_in', 'website')

    def get_id(self, obj):
        return obj.user.id

    def get_email(self, obj):
        return obj.user.email

    def get_first_name(self, obj):
        return obj.user.first_name

    def get_last_name(self, obj):
        return obj.user.last_name

    def get_location(self, obj):
        if obj.location == None:
            return None
        return obj.location.name
Esempio n. 3
0
class ProjectMemberSerializer(serializers.ModelSerializer):
    user = serializers.SerializerMethodField()
    role = RoleSerializer()
    availability = AvailabilitySerializer()

    class Meta:
        model = ProjectMember
        fields = ('id', 'user', 'role', 'role_in_project', 'availability')

    def get_user(self, obj):
        return UserProfileStubSerializer(UserProfile.objects.filter(user=obj.user)[0]).data
Esempio n. 4
0
class UserProfileSerializer(serializers.ModelSerializer):
    id = serializers.SerializerMethodField()
    first_name = serializers.SerializerMethodField()
    last_name = serializers.SerializerMethodField()
    availability = AvailabilitySerializer()
    skills = SkillSerializer(many=True)

    class Meta:
        model = UserProfile
        fields = ('id', 'first_name', 'last_name', 'url_slug', 'image',
                  'background_image', 'country', 'state', 'city', 'biography',
                  'is_profile_verified', 'availability', 'skills', 'website')

    def get_id(self, obj):
        return obj.user.id

    def get_first_name(self, obj):
        return obj.user.first_name

    def get_last_name(self, obj):
        return obj.user.last_name