75 lines
2.3 KiB
Python
75 lines
2.3 KiB
Python
# passerelle-maarch
|
|
# 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 requests
|
|
from suds.client import Client
|
|
|
|
from django.core.urlresolvers import reverse
|
|
from django.views.generic import DetailView
|
|
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
|
from django.core.cache import cache
|
|
|
|
from passerelle import utils
|
|
|
|
from .soap import get_client
|
|
from .models import MaarchManagement
|
|
from .forms import MaarchManagementForm, MaarchManagementUpdateForm
|
|
|
|
class MaarchManagementDetailView(DetailView):
|
|
model = MaarchManagement
|
|
template_name = 'passerelle_maarch/detail.html'
|
|
|
|
|
|
class MaarchManagementCreateView(CreateView):
|
|
model = MaarchManagement
|
|
form_class = MaarchManagementForm
|
|
template_name = 'passerelle/manage/service_form.html'
|
|
|
|
|
|
class MaarchManagementUpdateView(UpdateView):
|
|
model = MaarchManagement
|
|
form_class = MaarchManagementUpdateForm
|
|
template_name = 'passerelle/manage/service_form.html'
|
|
|
|
|
|
class MaarchManagementDeleteView(DeleteView):
|
|
model = MaarchManagement
|
|
template_name = 'passerelle/manage/service_confirm_delete.html'
|
|
|
|
def get_success_url(self):
|
|
return reverse('manage-home')
|
|
|
|
|
|
class MaarchDetailView(DetailView):
|
|
model = MaarchManagement
|
|
|
|
def get_client(self):
|
|
return get_client(maarch=self.get_object())
|
|
|
|
def get_data(self, request, *args, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
@utils.protected_api('can_access')
|
|
def get(self, request, *args, **kwargs):
|
|
data = self.get_data(request, *args, **kwargs)
|
|
return utils.response_for_json(request, data)
|
|
|
|
|
|
class MaarchPingView(MaarchDetailView):
|
|
def get_data(self, request, *args, **kwargs):
|
|
client = self.get_client()
|
|
return {'ping': 'pong'}
|