Permalink
Browse files

Is github down?

  • Loading branch information...
1 parent 173272f commit f04a45f5964d48ac2ef08e50675e68648e009ea0 Johan committed Oct 9, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 apps/log/views.py
View
@@ -1,18 +1,20 @@
from pprint import pprint
from django.core import serializers
+from django.shortcuts import get_object_or_404
from django.utils import simplejson
from django.http import HttpResponse
from django.contrib.auth.models import User
def member(request, id):
- user = User.objects.get(id=id)
+ user = get_object_or_404(User, id=id)
+ log_entries = user.log_entries.all()[:10]
try:
- log_entries = user.log_entries.all()[:10]
+ log_entries[0]
except:
- return HttpResponse("No activity yet.")
+ return HttpResponse("No activity yet")
if user.first_name and user.last_name:
name = user.first_name + " " + user.last_name
@@ -21,13 +23,13 @@ def member(request, id):
try:
latest_checkin_entry = user.log_entries.filter(on_illutron=True)[0].time.isoformat()
- except:
+ except IndexError:
latest_checkin_entry = None
try:
image = user.get_profile().image.url
except:
- image = False
+ image = None
log_list = []
for log in log_entries:
@@ -54,5 +56,5 @@ def member_list(request):
Return a list of all members.
"""
- data = simplejson.dumps(list(User.objects.all().values('id', 'username', 'first_name', 'last_name')))
+ data = simplejson.dumps(list(User.objects.all().values('id', 'username',)))
return HttpResponse(data, mimetype='application/json')

0 comments on commit f04a45f

Please sign in to comment.