예제 #1
0
    def get_created_by(obj):
        from apps.user.serializers.user import PublicUserSerializer

        if obj.is_anonymous:
            return '익명'

        return PublicUserSerializer(obj.created_by).data
예제 #2
0
class CommentListActionSerializer(BaseCommentSerializer):
    from apps.user.serializers.user import PublicUserSerializer
    created_by = PublicUserSerializer(read_only=True, )
    my_vote = serializers.SerializerMethodField(read_only=True, )
    is_hidden = serializers.SerializerMethodField(read_only=True, )
    why_hidden = serializers.SerializerMethodField(read_only=True, )
    content = serializers.SerializerMethodField(read_only=True, )
    hidden_content = serializers.SerializerMethodField(read_only=True, )
    created_by = serializers.SerializerMethodField(read_only=True, )
예제 #3
0
class ReportSerializer(BaseReportSerializer):
    from apps.core.serializers.article import ArticleListActionSerializer
    parent_article = ArticleListActionSerializer(read_only=True, )

    from apps.core.serializers.comment import CommentListActionSerializer
    parent_comment = CommentListActionSerializer(read_only=True, )

    from apps.user.serializers.user import PublicUserSerializer
    reported_by = PublicUserSerializer(read_only=True, )
예제 #4
0
class CommentCreateActionSerializer(BaseCommentSerializer):
    class Meta(BaseCommentSerializer.Meta):
        read_only_fields = (
            'positive_vote_count',
            'negative_vote_count',
            'created_by',
        )

    from apps.user.serializers.user import PublicUserSerializer
    created_by = PublicUserSerializer(read_only=True, )
예제 #5
0
    def get_created_by(self, obj):
        from apps.user.serializers.user import PublicUserSerializer

        if obj.is_anonymous:
            return '익명'

        data = PublicUserSerializer(obj.created_by).data
        data['is_blocked'] = Block.is_blocked(
            blocked_by=self.context['request'].user, user=obj.created_by)

        return data
예제 #6
0
class CommentUpdateActionSerializer(BaseCommentSerializer):
    class Meta(BaseCommentSerializer.Meta):
        read_only_fields = (
            'is_anonymous',
            'positive_vote_count',
            'negative_vote_count',
            'created_by',
            'parent_article',
            'parent_comment',
        )

    from apps.user.serializers.user import PublicUserSerializer
    created_by = PublicUserSerializer(read_only=True, )
예제 #7
0
class CommentListActionSerializer(BaseCommentSerializer):
    from apps.user.serializers.user import PublicUserSerializer
    created_by = PublicUserSerializer(read_only=True, )

    from apps.core.serializers.comment_log import CommentUpdateLogSerializer
    comment_update_logs = CommentUpdateLogSerializer(
        many=True,
        read_only=True,
        source='comment_update_log_set',
    )

    my_vote = serializers.SerializerMethodField(read_only=True, )
    my_report = serializers.SerializerMethodField(read_only=True, )
    is_hidden = serializers.SerializerMethodField(read_only=True, )
    why_hidden = serializers.SerializerMethodField(read_only=True, )
    content = serializers.SerializerMethodField(read_only=True, )
    hidden_content = serializers.SerializerMethodField(read_only=True, )
    created_by = serializers.SerializerMethodField(read_only=True, )
예제 #8
0
class ScrapSerializer(BaseScrapSerializer):
    from apps.core.serializers.article import ArticleListActionSerializer
    parent_article = ArticleListActionSerializer(read_only=True, )

    from apps.user.serializers.user import PublicUserSerializer
    scrapped_by = PublicUserSerializer(read_only=True, )
예제 #9
0
파일: block.py 프로젝트: tkahng/new-ara-api
class BlockSerializer(BaseBlockSerializer):
    class Meta(BaseBlockSerializer.Meta):
        read_only_fields = ('blocked_by', )

    from apps.user.serializers.user import PublicUserSerializer
    user = PublicUserSerializer(read_only=True, )