Skip to content

Commit

Permalink
OpenHub: /openhub shows how to get OH_TOKEN if not set
Browse files Browse the repository at this point in the history
/openhub now shows a short message on how to get an OH_TOKEN
if it's not set

Closes #201
  • Loading branch information
kx-chen committed Nov 2, 2018
1 parent 40109d0 commit f294015
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions openhub/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
from django.shortcuts import render

from openhub.models import PortfolioProject
from openhub.oh_token import OH_TOKEN


def index(request):
projects = PortfolioProject.objects.all()
args = {'projects': projects}
errors = []
projects = []
if OH_TOKEN is None:
errors.append("""
OH_TOKEN is not specified as an environment variable. <br/>
You can get an OpenHub token by signing up at
<a href="https://www.openhub.net">openhub.net</a>.
""")
else:
projects = PortfolioProject.objects.all()

args = {'projects': projects, 'errors': errors}
return render(request, 'openhub.html', args)
4 changes: 4 additions & 0 deletions templates/openhub.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
</head>
<body>
<h1>All of our Portfolio Projects</h1>
{% for error in errors %}
<p>{{ error | safe }}</p>
{% endfor %}

{% for project in projects %}
<div class="container">
<div class="row">
Expand Down

0 comments on commit f294015

Please sign in to comment.