Limit URL queries to current user

parent 6862efd3
......@@ -43,6 +43,9 @@ from scratch, is found in the README file in branch `prepare`.
Otherwise, just follow the commits, in exactly the order we
showed them in the lab on Monday, June 15, 2015.
In the lab, we went up to 6862efd3 but then I took the liberty
to continue a bit further.
---
Enjoy...
......
......@@ -11,7 +11,8 @@ from .models import Url
@login_required
def index(request):
context = {
'url_list': Url.objects.all()
'url_list': Url.objects.filter(user__exact=request.user)
.order_by('target')
}
return render(request, 'index.html', context)
......@@ -24,7 +25,7 @@ def redir(request, url_id):
@login_required
def details(request, url_id):
context = {
'url': get_object_or_404(Url, id=url_id)
'url': get_object_or_404(Url, id=url_id, user__exact=request.user)
}
return render(request, 'details.html', context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment