Add client list and detail.

This commit is contained in:
juanifioren 2015-01-13 18:46:57 -03:00
parent bf27696137
commit 2b55e8dd8e
8 changed files with 103 additions and 28 deletions

View file

@ -41,7 +41,18 @@
{% if user.is_authenticated %}
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">{{ user.email }}</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ user.email }} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Profile</a></li>
{% if user.is_staff %}
<li class="divider"></li>
<li><a href="{% url 'openid_provider:client_list' %}">Clients</a></li>
{% endif %}
<li class="divider"></li>
<li><a href="{% url 'openid_provider:logout' %}">Logout</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
{% endif %}

View file

@ -0,0 +1,51 @@
{% extends "openid_provider/base.html" %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ object.name }}</h3>
</div>
<div class="panel-body">
<h4>ID</h4>
<div class="well well-sm">{{ object.client_id }}</div>
<h4>SECRET</h4>
<div class="well well-sm">{{ object.client_secret }}</div>
<table class="table table-bordered">
<tr>
<th scope="row">User</th>
<td>{{ object.user.email }}</td>
</tr>
<tr>
<th scope="row">Client Type</th>
<td>{{ object.client_type }}</td>
</tr>
<tr>
<th scope="row">Response Type</th>
<td>{{ object.response_type }}</td>
</tr>
<tr>
<th scope="row">Redirect URIs</th>
<td>{{ object.redirect_uris|join:', ' }} </td>
</tr>
<tr>
<th scope="row">Scopes</th>
<td>{{ object.scope|join:', ' }} </td>
</tr>
</table>
<div class="btn-group btn-group btn-group-justified" role="group">
<a href="{% url 'openid_provider:client_list' %}" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Go Back</a>
<a class="btn btn-danger">Delete</a>
<a class="btn btn-success">Edit</a>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -8,6 +8,12 @@
<div class="col-md-3 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">
<span class="badge">{{ object_list.count }}</span>
<strong>Total</strong>
</li>
</ul>
<a href="#" class="btn btn-success btn-block">New Client</a>
</div>
</div>
@ -18,9 +24,10 @@
<h3 class="panel-title">Clients</h3>
</div>
<div class="panel-body">
<p>{% trans 'Click on the client you want to see.' %}</p>
<div class="list-group">
{% for client in object_list %}
<a href="#{{ client.client_id }}" class="list-group-item">{{ client.name }}</a>
<a href="{% url 'openid_provider:client_detail' client.id %}" class="list-group-item">{{ client.name }}<span class="badge">{{ client.default_redirect_uri }}</span></a>
{% empty %}
<div class="list-group-item">No clients yet.</div>
{% endfor %}

View file

@ -27,8 +27,9 @@
<input name="remember" type="checkbox" value="Remember Me"> Remember Me
</label>
</div>
<input type="hidden" name="next" value="{{ next }}" />
<input class="btn btn-success btn-block" type="submit" value="OK">
<input type="hidden" name="next" value="{% if next %}{{ next }}{% else %}/openid/profile/{% endif %}" />
<input class="btn btn-primary btn-block" type="submit" value="OK">
</fieldset>
</form>
</div>

View file

@ -0,0 +1,19 @@
{% extends "openid_provider/base.html" %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-body" >
<h2>{{ title }}</h2>
<p>{% trans "Thanks for spending some quality time with the Web site today." %}</p>
<p><a href="{% url 'openid_provider:login' %}">{% trans 'Log in again' %}</a></p>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,19 +0,0 @@
{% extends "openid_provider/base.html" %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-body">
<h2>Logged out</h2>
<hr>
<p>See you next time.</p>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -10,9 +10,10 @@ urlpatterns = patterns('',
url(r'^token/$', csrf_exempt(endpoints.TokenView.as_view()), name='token'),
url(r'^userinfo/$', csrf_exempt(endpoints.userinfo), name='userinfo'),
url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),
url(r'^login/$', 'django.contrib.auth.views.login', { 'template_name': 'openid_provider/login.html' }, name='login'),
url(r'^logout/$', 'django.contrib.auth.views.logout', { 'template_name': 'openid_provider/logout.html' }, name='logout'),
url(r'^clients/$', clients.ClientListView.as_view(), name='clients'),
url(r'^clients/$', clients.ClientListView.as_view(), name='client_list'),
url(r'^clients/(?P<pk>[\d]+)/$', clients.ClientDetailView.as_view(), name='client_detail'),
)

View file

@ -1,4 +1,5 @@
from django.utils.decorators import method_decorator
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from openid_provider.lib.utils.decorators import staff_required
from openid_provider.models import Client
@ -7,8 +8,11 @@ from openid_provider.models import Client
class ClientListView(ListView):
model = Client
template_name = "openid_provider/clients.html"
@method_decorator(staff_required)
def dispatch(self, *args, **kwargs):
return super(ClientListView, self).dispatch(*args, **kwargs)
return super(ClientListView, self).dispatch(*args, **kwargs)
class ClientDetailView(DetailView):
model = Client