2015-02-08 15:14:58 +01:00
|
|
|
# lingo - basket and payment 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/>.
|
2015-02-08 11:32:29 +01:00
|
|
|
|
2015-02-08 15:14:58 +01:00
|
|
|
import json
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.views.generic import ListView
|
|
|
|
|
|
|
|
from .models import Regie
|
|
|
|
|
|
|
|
class RegiesApiView(ListView):
|
|
|
|
model = Regie
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
response = HttpResponse(content_type='application/json')
|
|
|
|
data = {'data': [x.as_api_dict() for x in self.get_queryset()]}
|
|
|
|
json_str = json.dumps(data)
|
|
|
|
if 'jsonpCallback' in request.GET:
|
|
|
|
json_str = '%s(%s);' % (request.GET['jsonpCallback'], json_str)
|
|
|
|
response.write(json_str)
|
|
|
|
return response
|