views.py 文件源码

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

项目:djangocms-concurrent-users 作者: Blueshoe 项目源码 文件源码
def post(self, request, *args, **kwargs):
        _page = get_object_or_404(Page, pk=request.POST.get('page_id'))

        def update_indicator():
            indicator = PageIndicator.objects.get(editor=request.user, edited_on__gte=self.time_past, page=_page)
            indicator.edited_on = self.now
            indicator.save()

        # To avoid uncontrolled creation of PageIndicators delete any for this user/page combination which
        # is too old.
        PageIndicator.objects.filter(editor=request.user, edited_on__lte=self.time_past, page=_page).delete()

        try:
            update_indicator()
        except PageIndicator.DoesNotExist:
            PageIndicator.objects.create(editor=request.user, edited_on=self.now, started_editing=self.now, page=_page)

        return HttpResponse(status=200)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号