Don't error out if there are no approved quotes avaliable
authorMagnus Hagander <magnus@hagander.net>
Thu, 15 Jul 2010 20:39:28 +0000 (22:39 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 15 Jul 2010 20:40:21 +0000 (22:40 +0200)
pgweb/core/views.py

index 363d6b833028e1bfca479f242cc1cf5817f671b0..7255c2b457b9bc87f43a1b7c68775cfb8eaee0f3 100644 (file)
@@ -32,7 +32,10 @@ from forms import OrganisationForm
 def home(request):
        news = NewsArticle.objects.filter(approved=True)[:5]
        events = Event.objects.select_related('country').filter(approved=True, training=False, enddate__gt=date.today).order_by('enddate', 'startdate')[:3]
-       quote = Quote.objects.filter(approved=True).order_by('?')[0]
+       try:
+               quote = Quote.objects.filter(approved=True).order_by('?')[0]
+       except:
+               pass # if there is no quote available, just ignore error
        versions = Version.objects.all()
        planet = ImportedRSSItem.objects.filter(feed__internalname="planet").order_by("-posttime")[:5]