api.py 文件源码

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

项目:fire 作者: FundersClub 项目源码 文件源码
def approve(self, request, uuid=None):
        # We can't use `self.get_object()` because:
        # 1) It filters only for active repos and this one is potentially
        #    not active yet
        # 2) We want to always return a response even if the current user
        #    does not have access to this particular repo
        repo = get_object_or_404(models.Repository, uuid=uuid)

        # See if we're going to approve this repo
        if ((repo.status == models.Repository.Status.PendingInviterApproval) and
            (repo.inviter_login == request.user.username)):
            repo.approve_by_inviter(request.user)

        # Select which serializer class to use based on the current user's access
        serializer_class = RepositoryApproveSerializer
        if request.user in repo.admins.all():
            serializer_class = self.get_serializer_class()

        serializer = serializer_class(repo, context=self.get_serializer_context())
        return Response(serializer.data)


################################################################################
# Views
################################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号