Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Add in jinja logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbashdown committed Jul 24, 2014
1 parent 73dc26f commit 5618cea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
12 changes: 8 additions & 4 deletions admin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from performanceplatform.client.admin import AdminAPI


@app.route("/", methods=['GET'])
def root():
def get_context(session):
context = dict()

if 'oauth_user' in session and 'oauth_token' in session:
Expand All @@ -16,12 +15,17 @@ def root():
'data_sets': admin_client.list_data_sets(),
}

return render_template('index.html', **context)
return context


@app.route("/", methods=['GET'])
def root():
return render_template('index.html')


@app.route("/data-sets", methods=['GET'])
def data_sets():
return render_template('data_sets.html')
return render_template('data_sets.html', **get_context(session))


@app.route("/upload-error", methods=['GET'])
Expand Down
16 changes: 10 additions & 6 deletions admin/templates/data_sets.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ <h3>Upload data to the Performance Platform</h3>
<ul class="list-unstyled">
<li>
<h4>Some data group</h4>
<ul class="list-unstyled">
<strong>Some data set name</strong>
<li>
{% include "upload/form.html" %}
</li>
</ul>
{% if data_sets %}
<ul class="list-unstyled">
{% for data_set in data_sets %}
<li>
<strong>{{ data_set.name }}</strong>
{% include "upload/form.html" %}
</li>
{% endfor %}
</ul>
{% endif %}
</li>
</ul>
</div>
Expand Down
8 changes: 5 additions & 3 deletions admin/templates/navbar/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
</div>
<nav role="navigation" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="/login" title="Sign in">Sign in</a>
</li>
{% if not user %}
<li>
<a href="/login" title="Sign in">Sign in</a>
</li>
{% endif %}
<li >
<a href="/contact">Contact</a>
</li>
Expand Down
7 changes: 3 additions & 4 deletions admin/templates/navbar/signed_in.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% if session.get('user') %}
{% if user %}
<div class="navbar-text pull-right">
Hello, <a href="https://signon.production.alphagov.co.uk">{{ session.get('user').get('name') }}</a>
&bull; <a href="{{ url_for("oauth_sign_out") }}">Sign out</a>

Hello, {{ user.name }}
&bull; <a href="/sign-out">Sign out</a>
</div>
{% endif %}

0 comments on commit 5618cea

Please sign in to comment.