File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111try :
1212 # Python 3
1313 from urllib .request import urlopen
14+ from urllib .request import Request
1415except ImportError :
1516 # Python 2
16- from urllib import urlopen
17+ from urllib2 import urlopen
18+ from urllib2 import Request
1719import re
1820import json
1921
2022import isodate
23+ from django .conf import settings
2124from django .core .cache import cache
2225from django .conf import settings
2326
@@ -43,8 +46,17 @@ def fetch_json(url):
4346 json_obj = cache .get (url )
4447
4548 if json_obj is None :
49+ github_oauth_token = getattr (settings , 'GITHUB_OAUTH_TOKEN' , None )
50+
51+ if github_oauth_token :
52+ headers = {'Authorization' : 'token %s' % (github_oauth_token )}
53+ else :
54+ headers = {}
55+
56+ request = Request (url = url , headers = headers )
57+
4658 try :
47- json_obj = json .load (urlopen (url ))
59+ json_obj = json .load (urlopen (request ))
4860 except IOError as e :
4961 logger .exception ("Unable to load %s: %s" ,
5062 url , e , exc_info = True )
Original file line number Diff line number Diff line change 8686
8787US_TZ_AWARE_DATES = False # True to use timezone aware datetime objects with Github provider.
8888 # NOTE: Some database backends may not support tz aware dates.
89+
90+ GITHUB_OAUTH_TOKEN = None # Github oAuth token to use when using Github repo type. If not
91+ # specified, it will utilize unauthenticated requests which have
92+ # low rate limits.
Original file line number Diff line number Diff line change 66
77{% block extra_head %}
88{{ block.super }}
9- < link rel ="stylesheet " type ="text/css " href ="{% static '/ css/timeline.css' %} " />
9+ < link rel ="stylesheet " type ="text/css " href ="{% static 'css/timeline.css' %} " />
1010 < link rel ="stylesheet " type ="text/css " href ="{% static 'js/jqplot/jquery.jqplot.min.css' %} " />
1111{% endblock %}
1212
You can’t perform that action at this time.
0 commit comments