示例#1
0
 def create(self, request, *args, **kwargs):
     request.data['remote_addr'] = utils.anonymize(request.META.get('REMOTE_ADDR'))
     request.data['voters'] = utils.Bloomfilter(iterable=[request.META.get('REMOTE_ADDR')]).array
     response = super(CommentViewSet, self).create(request, *args, **kwargs)
     response.set_cookie(str(response.data['id']), sha1(response.data['text']))
     response.set_cookie('isso-%i' % response.data['id'], sha1(response.data['text']))
     return response
示例#2
0
 def dislike(self, request, *args, **kwargs):
     comment = self.get_object()
     return Response(comment.vote(False, utils.anonymize(request.META.get('REMOTE_ADDR'))))