@require_POST
@login_required
def hide_tweet(request):
 if (not settings.CC_ALLOW_REMOVE):
  return HttpResponse(status=418)
 try:
  id = int(request.POST.get('id'))
 except (ValueError, TypeError):
  return HttpResponseBadRequest(_('Invalid ID.'))
 try:
  tweet = Tweet.objects.get(pk=id)
 except Tweet.DoesNotExist:
  return HttpResponseNotFound(_('Invalid ID.'))
 if ((tweet.reply_to is not None) or Tweet.objects.filter(reply_to=tweet).exists()):
  return HttpResponseBadRequest(_('Tweets that are replies or have replies must not be hidden.'))
 try:
  tweet.hidden = True
  tweet.save(force_update=True)
 except Exception as e:
  return HttpResponseServerError(_('An error occured: {message}').format(message=e))
 return HttpResponse('ok')

@ require_POST @ login_required def hide_tweet ( request ) : if ( not settings . CC_ALLOW_REMOVE ) : return HttpResponse ( status = 418 ) try : id = int ( request . POST . get ( 'id' ) ) except ( ValueError , TypeError ) : return HttpResponseBadRequest ( _ ( 'Invalid ID.' ) ) try : tweet = Tweet . objects . get ( pk = id ) except Tweet . DoesNotExist : return HttpResponseNotFound ( _ ( 'Invalid ID.' ) ) if ( ( tweet . reply_to is not None ) or Tweet . objects . filter ( reply_to = tweet ) . exists ( ) ) : return HttpResponseBadRequest ( _ ( 'Tweets that are replies or have replies must not be hidden.' ) ) try : tweet . hidden = True tweet . save ( force_update = True ) except Exception as e : return HttpResponseServerError ( _ ( 'An error occured: {message}' ) . format ( message = e ) ) return HttpResponse ( 'ok' )
hide the tweet with a given id .