Skip to content

Commit

Permalink
gci: Fail gracefully when GCI token not available
Browse files Browse the repository at this point in the history
When the GCI token is not available, the GCI page
should fail to build, while letting other parts of the
website be build.

Related to coala#3
  • Loading branch information
jayvdb committed Dec 10, 2017
1 parent ae7a546 commit c5578d7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gci/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from calendar import timegm
import requests

from gci.config import get_api_key
from .students import get_students, get_linked_students
from .gitorg import get_logo

Expand All @@ -14,6 +15,20 @@


def index(request):
try:
client = get_api_key('GCI')
except BaseException:
client = None

if client:
s = gci_overview()
else:
s = ['GCI data not available']

return HttpResponse('\n'.join(s))


def gci_overview():
linked_students = list(get_linked_students(get_students()))
org_id = linked_students[0]['organization_id']
org_name = linked_students[0]['organization_name']
Expand Down Expand Up @@ -66,4 +81,4 @@ def index(request):
s.append('<script src="static/timeago.js"></script>')
s.append('<script>loadTimeElements()</script>')

return HttpResponse('\n'.join(s))
return s

0 comments on commit c5578d7

Please sign in to comment.