Commit 6a519f6a authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

astakos: Initial commit of API access view

api access view contains all available information for the user to access the
service api.
parent abfe0786
......@@ -180,3 +180,7 @@ RESOURCES_META = getattr(settings, 'ASTAKOS_RESOURCES_META', {})
# Do not require email verification for new users
SKIP_EMAIL_VERIFICATION = getattr(settings,
'ASTAKOS_SKIP_EMAIL_VERIFICATION', False)
# Kamaki download url. Displayed in api access view
API_CLIENT_URL = getattr(settings, 'ASTAKOS_API_CLIENT_URL',
'https://pypi.python.org/pypi/kamaki')
......@@ -113,3 +113,53 @@ span.action-desc { display: block; color: #fff;}
/* heading extra */
h2 .header-actions { float: right; font-size: 0.8em;}
.api-access-view div.detail .title {
float: left;
font-size: 0.8em;
}
.api-access-view div.detail input {
border: none;
text-decoration: none;
width: 80%;
font-family: monospace;
position: absolute;
left: 20%;
cursor: pointer;
}
.api-access-view div.detail {
display: block;
position: relative;
margin: 1em 0;
font-size: 1.3em;
cursor: pointer;
border-bottom: 1px solid #efefef;
padding-bottom: 0.2em;
}
.api-access-view div.detail.small {
padding-bottom: 0.9em;
}
.api-access-view div.detail .expires {
font-size: 9px;
font-family: 'Open Sans', sans-serif;
position: absolute;
right: 0;
bottom: 15px;
}
.api-access-view p.sub {
font-size: 0.7em;
text-align: right;
}
.api-access-view .api-clients h3 {
font-size: 1.2em;
}
.subsection {
margin-bottom: 4em;
}
......@@ -87,6 +87,11 @@ if (navigator.userAgent.match(/iPhone/i)) {
$(document).ready(function() {
/* api access */
$(".token-view .detail").click(function() {
$(this).find("input").select();
});
setContainerMinHeight('.container .wrapper');
//tableFixedCols('my-projects', 25);
......@@ -404,8 +409,6 @@ $('#members-table tr .check input').click(function(e){
/* end of project members page js */
});
$(window).resize(function() {
......
{% extends "im/account_base.html" %}
{% extends "im/api_access_base.html" %}
{% load filters %}
{% block page.body %}
<h2>API ACCESS</h2>
<p>Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci[ng] velit, sed quia non numquam [do] eius modi tempora inci[di]dunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?</p>
{% endblock %}
{% extends "im/account_base.html" %}
{% load filters %}
{% block page.body %}
<div class="api-access-view">
<div class="subsection">
{% block page.body.title %}
<h2>API ACCESS</h2>
{% endblock %}
{% block page.body.description %}
<p>
<em>{{ BRANDING_SERVICE_NAME }} API</em> allows you complete access to all
of your data stored accross the {{ BRANDING_SERVICE_NAME }} services.
</p>
{% endblock %}
</div>
<div class="subsection">
{% block page.body.token %}
<h2>API details</h2>
<div class="token-view">
<div class="detail clearfix">
<span class="title">Account UUID</span>
<input type="text" value="{{ request.user.uuid }}" disabled />
</div>
<div class="detail small clearfix">
<span class="title">Authentication url</span>
<input type="text" value="{{ token_url }}" disabled />
</div>
<div class="detail clearfix">
<span class="title">API Token</span>
<input type="text" value="{{ request.user.auth_token }}" disabled />
<span class="expires">
<span class="date">
expires in {{ request.user.auth_token_expires|timeuntil }}
({{ request.user.auth_token_expires|date }})
</span>
</span>
<span class="extra-img" id="token-span">&nbsp;</span>
</div>
<p class="sub">Make sure to set the new token in any client you may be using each
time you renew your token.</p>
</div>
{% endblock %}
</div>
<div class="subsection api-clients">
{% block page.body.clients %}
<h2>Command line client</h2>
<h3><a href="{{ client_url }}">Kamaki</a></h3>
<p>
Kamaki is a command line utility that fully supports the
{{ BRANDNING_SERVICE_NAME }} API.
</p>
<p class="download">You can download kamaki
from the <a href="{{ client_url }}">project homepage</a></p>
{% endblock %}
</div>
</div>
{% endblock %}
......@@ -47,6 +47,7 @@ urlpatterns = patterns(
url(r'^landing/?$', 'landing', {}, name='landing'),
url(r'^profile/update_token?$', 'update_token', {}, name='update_token'),
url(r'^profile/?$','edit_profile', {}, name='edit_profile'),
url(r'^api_access/?$','api_access', {}, name='api_access'),
url(r'^api_access/?$', 'api_access', {}, name='api_access'),
url(r'^feedback/?$', 'feedback', {}, name='feedback'),
url(r'^signup/?$', 'signup', {'on_success': 'index', 'extra_context': {'login_form': LoginForm()}}, name='signup'),
......
......@@ -51,6 +51,8 @@ from django.core.exceptions import PermissionDenied
from django.views.decorators.http import require_http_methods
from django.utils import simplejson as json
from synnefo.lib import join_urls
import astakos.im.messages as astakos_messages
from astakos.im import activation_backends
......@@ -202,6 +204,31 @@ def invite(request, template_name='im/invitations.html', extra_context=None):
context_instance=context)
@require_http_methods(["GET", "POST"])
@required_auth_methods_assigned()
@login_required
@cookie_fix
@signed_terms_required
def api_access(request, template_name='im/api_access.html',
extra_context=None):
"""
API access view.
"""
context = {}
token_url = join_urls(settings.BASE_URL, settings.BASE_PATH,
reverse('tokens_authenticate'))
context['services'] = Component.catalog()
context['token_url'] = token_url
context['client_url'] = settings.API_CLIENT_URL
if extra_context:
context.update(extra_context)
context_instance = get_context(request, context)
return render_response(template_name,
context_instance=context_instance)
@require_http_methods(["GET", "POST"])
@required_auth_methods_assigned(allow_access=True)
@login_required
......@@ -811,11 +838,6 @@ def landing(request):
context_instance=get_context(request), **context)
def api_access(request):
return render_response(
'im/api_access.html',
context_instance=get_context(request))
@cookie_fix
def get_menu(request, with_extra_links=False, with_signout=True):
user = request.user
......@@ -843,6 +865,9 @@ def get_menu(request, with_extra_links=False, with_signout=True):
append(item(url=request.build_absolute_uri(reverse('invite')),
name="Invitations"))
append(item(url=request.build_absolute_uri(reverse('api_access')),
name="API access"))
append(item(url=request.build_absolute_uri(reverse('resource_usage')),
name="Usage"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment