51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# lingo - payment and billing system
|
|
# Copyright (C) 2022 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.http import HttpResponse
|
|
from django.urls import reverse
|
|
from django.views.generic import TemplateView
|
|
|
|
|
|
class HomepageView(TemplateView):
|
|
template_name = 'lingo/manager_homepage.html'
|
|
|
|
|
|
homepage = HomepageView.as_view()
|
|
|
|
|
|
def menu_json(request):
|
|
label = _('Payments')
|
|
json_str = json.dumps(
|
|
[
|
|
{
|
|
'label': label,
|
|
'slug': 'lingo',
|
|
'url': request.build_absolute_uri(reverse('manage-homepage')),
|
|
}
|
|
]
|
|
)
|
|
content_type = 'application/json'
|
|
for variable in ('jsonpCallback', 'callback'):
|
|
if variable in request.GET:
|
|
json_str = '%s(%s);' % (request.GET[variable], json_str)
|
|
content_type = 'application/javascript'
|
|
break
|
|
response = HttpResponse(content_type=content_type)
|
|
response.write(json_str)
|
|
return response
|