Skip to content

Commit f294015

Browse files
committed
OpenHub: /openhub shows how to get OH_TOKEN if not set
/openhub now shows a short message on how to get an OH_TOKEN if it's not set Closes #201
1 parent 40109d0 commit f294015

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

openhub/views.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
from django.shortcuts import render
22

33
from openhub.models import PortfolioProject
4+
from openhub.oh_token import OH_TOKEN
45

56

67
def index(request):
7-
projects = PortfolioProject.objects.all()
8-
args = {'projects': projects}
8+
errors = []
9+
projects = []
10+
if OH_TOKEN is None:
11+
errors.append("""
12+
OH_TOKEN is not specified as an environment variable. <br/>
13+
You can get an OpenHub token by signing up at
14+
<a href="https://www.openhub.net">openhub.net</a>.
15+
""")
16+
else:
17+
projects = PortfolioProject.objects.all()
18+
19+
args = {'projects': projects, 'errors': errors}
920
return render(request, 'openhub.html', args)

templates/openhub.html

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
</head>
1111
<body>
1212
<h1>All of our Portfolio Projects</h1>
13+
{% for error in errors %}
14+
<p>{{ error | safe }}</p>
15+
{% endfor %}
16+
1317
{% for project in projects %}
1418
<div class="container">
1519
<div class="row">

0 commit comments

Comments
 (0)