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