Skip to content

Commit

Permalink
Small fix on list item delete
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdixon committed Apr 10, 2014
1 parent 00df931 commit 3236ea4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ Create lists of stuff with django.

Built using Harry Percival's book Test Driven Web Development with Python.

Todo:
- Only people logged in can create lists.
- Only list owners can view their lists.
- At the moment anyone that's logged in can delete list items from any list


Binary file not shown.
8 changes: 4 additions & 4 deletions lists/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def add_item(request, list_id):
def delete_item(request, item_id):
list_item = Item.objects.get(id=item_id)
list_ = list_item.list
if isinstance(request.user, AnonymousUser) and request.user is not list_.owner:
return redirect('/404_page_does_not_exist/')
list_item.delete()
return redirect('/lists/%d/' % (list_.id,))
if request.user == list_.owner:
list_item.delete()
return redirect('/lists/%d/' % (list_.id,))
return redirect('/404_page_does_not_exist/')

def my_lists(request, email):
owner = User.objects.get(email=email)
Expand Down

0 comments on commit 3236ea4

Please sign in to comment.