experience_serializers.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:USTC-Software-2017 作者: igemsoftware2017 项目源码 文件源码
def create(self, validated_data):

        from biohub.core.conf import settings as biohub_settings
        from datetime import timedelta
        from django.utils.timezone import now

        brick = validated_data.pop('brick_name')
        author = validated_data['author']

        if Experience.objects.filter(
            author=author,
            brick=brick,
            pub_time__gte=now() - timedelta(seconds=biohub_settings.THROTTLE['experience'])
        ).exists():
            raise Throttled()

        content_serializer = validated_data.pop('content_input')
        content = content_serializer.save()
        experience = Experience.objects.create(
            brick=brick, content=content,
            author_name=author.username,
            **validated_data
        )
        return experience
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号