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)
评论列表
文章目录