38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
# combo - content management system
|
|
# Copyright (C) 2015 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import json
|
|
|
|
from django.conf import settings
|
|
from django.http import Http404, HttpResponse
|
|
|
|
def services_js(request, *args, **kwargs):
|
|
if not getattr(settings, 'KNOWN_SERVICES', None):
|
|
raise Http404()
|
|
services = []
|
|
for service_id, services_dict in settings.KNOWN_SERVICES.items():
|
|
for service_slug, service in services_dict.items():
|
|
services.append({
|
|
'title': service['title'],
|
|
'slug': service_slug,
|
|
'service_id': service_id,
|
|
'uniq': bool(len(services_dict) == 1),
|
|
'url': service['url'],
|
|
'backoffice_menu_url': service['backoffice-menu-url'],
|
|
})
|
|
response_body = 'var COMBO_KNOWN_SERVICES = %s;' % json.dumps(services)
|
|
return HttpResponse(response_body, content_type='text/javascript')
|