Skip to content

Instantly share code, notes, and snippets.

@Alir3z4
Created April 22, 2011 08:04
Show Gist options
  • Save Alir3z4/936250 to your computer and use it in GitHub Desktop.
Save Alir3z4/936250 to your computer and use it in GitHub Desktop.
@login_required
def delete(request, msg_pk):
msg = get_object_or_404(Message, pk=msg_pk)
## is owner?
if request.user != msg.user and request.user != msg.to:
raise Http404()
# Sender or Receiver ?
if msg.delete_status == 2:
msg.delete_status = 3
elif request.user == msg.user and request.user != msg.to:
msg.delete_status = '1'
elif request.user == msg.to:
msg.delete_status = '2'
msg.save()
# Send sucessfull message for user with messages framework
return HttpResponse(status=200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment