# Copyright 2011-2012 GRNET S.A. All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
-#
+#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
-#
+#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
-#
+#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
+#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
def render_fault(request, fault):
if isinstance(fault, InternalServerError) and settings.DEBUG:
fault.details = format_exc(fault)
-
+
request.serialization = 'text'
data = fault.message + '\n'
if fault.details:
x_auth_token = request.META.get('HTTP_X_AUTH_TOKEN')
if not x_auth_token:
return render_fault(request, BadRequest('Missing X-Auth-Token'))
-
+
try:
user = AstakosUser.objects.get(auth_token=x_auth_token)
except AstakosUser.DoesNotExist, e:
- return render_fault(request, Unauthorized('Invalid X-Auth-Token'))
-
+ return render_fault(request, Unauthorized('Invalid X-Auth-Token'))
+
# Check if the is active.
if not user.is_active:
return render_fault(request, Unauthorized('User inactive'))
-
+
# Check if the token has expired.
if (time() - mktime(user.auth_token_expires.timetuple())) > 0:
return render_fault(request, Unauthorized('Authentication expired'))
-
+
response = HttpResponse()
response.status=204
user_info = {'username':user.username,
def get_services(request):
if request.method != 'GET':
raise BadRequest('Method not allowed.')
+
+ callback = request.GET.get('callback', None)
data = json.dumps(CLOUD_SERVICES)
- return HttpResponse(content=data, mimetype="application/json")
+ mimetype = 'application/json'
+
+ if callback:
+ mimetype = 'application/javascript'
+ data = '%s(%s)' % (callback, data)
+
+ return HttpResponse(content=data, mimetype=mimetype)
def get_menu(request):
if request.method != 'GET':
'name': "feedback..." })
l.append({ 'url': absolute(reverse('astakos.im.views.logout')),
'name': "logout..."})
+
+ callback = request.GET.get('callback', None)
data = json.dumps(tuple(l))
- return HttpResponse(content=data, mimetype="application/json")
\ No newline at end of file
+ mimetype = 'application/json'
+
+ if callback:
+ mimetype = 'application/javascript'
+ data = '%s(%s)' % (callback, data)
+
+ return HttpResponse(content=data, mimetype=mimetype)
var services = $('<div class="services"></div>');
var profile = $('<div class="profile"></div>');
+ var get_services_url = window.GET_SERVICES_URL || window.CLOUDBAR_SERVICES;
+
// create services links and set the active class to the current service
- $.getJSON(window.GET_SERVICES_URL || window.CLOUDBAR_SERVICES, function(data) {
+ $.getJSON(get_services_url + "?callback=?", function(data) {
$.each(data, function(i, el){
var slink = $("<a>");
if (el.icon) {
var user = $('<div class="user"></div>');
var username = $('<a href="#"></a>');
var usermenu = $("<ul>");
- var get_menu_url = (window.GET_MENU_URL || window.CLOUDBAR_MENU).concat('?location=').concat(window.location.toString());
- $.getJSON(get_menu_url, function(data) {
+ var get_menu_url = (window.GET_MENU_URL || window.CLOUDBAR_MENU) + '?callback=?&location=' + window.location.toString();
+ $.getJSON(get_menu_url + "&callback=?", function(data) {
$.each(data, function(i,el) {
if (i == 0){
username.text(el.name);