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())
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
Exemple #3
0
class ProjectMinimalSerializer(serializers.ModelSerializer):
    skills = SkillSerializer(many=True)
    project_parents = serializers.SerializerMethodField()
    status = serializers.SerializerMethodField()
    location = serializers.SerializerMethodField()
    name = serializers.SerializerMethodField()

    class Meta:
        model = Project
        fields = ('name', 'url_slug', 'skills', 'image', 'status', 'location',
                  'project_parents', 'is_draft', 'website')

    def get_name(self, obj):
        return get_project_name(obj, get_language())

    def get_project_parents(self, obj):
        serializer = ProjectParentsSerializer(obj.project_parent, many=True)
        return serializer.data

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

    def get_status(self, obj):
        serializer = ProjectStatusSerializer(obj.status, many=False)
        return serializer.data['name']
Exemple #4
0
class ProjectMinimalSerializer(serializers.ModelSerializer):
    skills = SkillSerializer(many=True)
    project_parents = serializers.SerializerMethodField()
    status = serializers.CharField(source='status.name', read_only=True)

    class Meta:
        model = Project
        fields = ('name', 'url_slug', 'skills', 'image', 'status', 'country',
                  'city', 'project_parents', 'is_draft', 'website')

    def get_project_parents(self, obj):
        serializer = ProjectParentsSerializer(obj.project_parent, many=True)
        return serializer.data
Exemple #5
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
Exemple #6
0
 def get_skills(self, obj):
     serializer = SkillSerializer(obj.skills, many=True)
     return serializer.data