Commit 3edc52ee authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Services to dict helper method

parent a68519e3
...@@ -86,14 +86,17 @@ def api_method(http_method=None): ...@@ -86,14 +86,17 @@ def api_method(http_method=None):
return decorator return decorator
@api_method(http_method='GET') def get_services_dict():
def get_services(request):
callback = request.GET.get('callback', None)
services = Service.objects.all() services = Service.objects.all()
data = tuple({'id': s.pk, 'name': s.name, 'url': s.url, 'icon': data = tuple({'id': s.pk, 'name': s.name, 'url': s.url, 'icon':
s.icon} for s in services) s.icon} for s in services)
data = json.dumps(data) return data
@api_method(http_method=None)
def get_services(request):
callback = request.GET.get('callback', None)
mimetype = 'application/json' mimetype = 'application/json'
data = json.dumps(get_services_dict())
if callback: if callback:
mimetype = 'application/javascript' mimetype = 'application/javascript'
...@@ -126,7 +129,7 @@ def get_menu(request, with_extra_links=False, with_signout=True): ...@@ -126,7 +129,7 @@ def get_menu(request, with_extra_links=False, with_signout=True):
append(item( append(item(
url=absolute(request, reverse('invite')), url=absolute(request, reverse('invite')),
name="Invitations")) name="Invitations"))
if QUOTAHOLDER_URL: if QUOTAHOLDER_URL:
append(item( append(item(
url=absolute(request, reverse('project_list')), url=absolute(request, reverse('project_list')),
......
...@@ -100,7 +100,7 @@ from astakos.im.settings import ( ...@@ -100,7 +100,7 @@ from astakos.im.settings import (
LOGGING_LEVEL, PAGINATE_BY, LOGGING_LEVEL, PAGINATE_BY,
RESOURCES_PRESENTATION_DATA, PAGINATE_BY_ALL, RESOURCES_PRESENTATION_DATA, PAGINATE_BY_ALL,
MODERATION_ENABLED) MODERATION_ENABLED)
from astakos.im.api import get_services from astakos.im.api import get_services_dict
from astakos.im import settings as astakos_settings from astakos.im import settings as astakos_settings
from astakos.im.api.callpoint import AstakosCallpoint from astakos.im.api.callpoint import AstakosCallpoint
from astakos.im import auth_providers from astakos.im import auth_providers
...@@ -399,13 +399,7 @@ def edit_profile(request, template_name='im/profile.html', extra_context=None): ...@@ -399,13 +399,7 @@ def edit_profile(request, template_name='im/profile.html', extra_context=None):
# providers that user can add # providers that user can add
user_available_providers = request.user.get_available_auth_providers() user_available_providers = request.user.get_available_auth_providers()
try: extra_context['services'] = get_services_dict()
resp = get_services(request)
except Exception, e:
services = ()
else:
services = json.loads(resp.content)
extra_context['services'] = services
return render_response(template_name, return render_response(template_name,
profile_form = form, profile_form = form,
user_providers = user_providers, user_providers = user_providers,
......
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