general: add a generic connector view (#11200)
This commit is contained in:
parent
72ae98d529
commit
22184d8a90
|
@ -21,9 +21,6 @@ class BaseAdresse(BaseResource):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Base Adresse Web Service')
|
verbose_name = _('Base Adresse Web Service')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse('base_adresse-view', kwargs={'slug': self.slug})
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_icon_class(cls):
|
def get_icon_class(cls):
|
||||||
return 'gis'
|
return 'gis'
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.conf.urls import patterns, url
|
||||||
from django.conf.urls import patterns, include, url
|
|
||||||
|
|
||||||
from passerelle.urls_utils import decorated_includes, required, app_enabled
|
from views import SearchPathView
|
||||||
|
|
||||||
from views import *
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^(?P<slug>[\w,-]+)/$', BaseAdresseDetailView.as_view(), name='base_adresse-view'),
|
|
||||||
url(r'^(?P<slug>[\w,-]+)/search/(?P<path>.*)$', SearchPathView.as_view(), name='base_adresse-path-search'),
|
url(r'^(?P<slug>[\w,-]+)/search/(?P<path>.*)$', SearchPathView.as_view(), name='base_adresse-path-search'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,16 +1,4 @@
|
||||||
from django.views.generic.detail import DetailView
|
|
||||||
from passerelle.views import GenericEndpointView
|
from passerelle.views import GenericEndpointView
|
||||||
from .models import BaseAdresse
|
|
||||||
|
|
||||||
|
|
||||||
class BaseAdresseDetailView(DetailView):
|
|
||||||
model = BaseAdresse
|
|
||||||
template_name = 'base_adresse/base_adresse_detail.html'
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super(BaseAdresseDetailView, self).get_context_data(**kwargs)
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class SearchPathView(GenericEndpointView):
|
class SearchPathView(GenericEndpointView):
|
||||||
def get_connector(self, **kwargs):
|
def get_connector(self, **kwargs):
|
||||||
|
|
|
@ -41,15 +41,6 @@ class MobytSMSGateway(BaseResource, SMSGatewayMixin):
|
||||||
def get_icon_class(cls):
|
def get_icon_class(cls):
|
||||||
return 'phone'
|
return 'phone'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse('mobyt-view', kwargs={'slug': self.slug})
|
|
||||||
|
|
||||||
def get_edit_url(self):
|
|
||||||
return reverse('edit-connector', kwargs={'connector': 'mobyt', 'slug': self.slug})
|
|
||||||
|
|
||||||
def get_delete_url(self):
|
|
||||||
return reverse('delete-connector', kwargs={'connector': 'mobyt', 'slug': self.slug})
|
|
||||||
|
|
||||||
def send_msg(self, text, sender, destinations):
|
def send_msg(self, text, sender, destinations):
|
||||||
"""Send a SMS using the Mobyt provider"""
|
"""Send a SMS using the Mobyt provider"""
|
||||||
# unfortunately it lacks a batch API...
|
# unfortunately it lacks a batch API...
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.conf.urls import patterns, url
|
|
||||||
from views import *
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
|
||||||
url(r'^(?P<slug>[\w,-]+)/$', MobytDetailView.as_view(), name='mobyt-view'),
|
|
||||||
)
|
|
|
@ -1,8 +0,0 @@
|
||||||
from passerelle.base.views import ResourceView
|
|
||||||
|
|
||||||
from .models import MobytSMSGateway
|
|
||||||
|
|
||||||
|
|
||||||
class MobytDetailView(ResourceView):
|
|
||||||
model = MobytSMSGateway
|
|
||||||
template_name = 'passerelle/manage/messages_service_view.html'
|
|
|
@ -1,31 +0,0 @@
|
||||||
# passerelle - uniform access to multiple data sources and services
|
|
||||||
# Copyright (C) 2016 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 django.apps
|
|
||||||
|
|
||||||
class AppConfig(django.apps.AppConfig):
|
|
||||||
name = 'ovh'
|
|
||||||
label = 'ovh'
|
|
||||||
|
|
||||||
def get_after_urls(self):
|
|
||||||
from . import urls
|
|
||||||
return urls.urlpatterns
|
|
||||||
|
|
||||||
def get_connector_model(self):
|
|
||||||
from . import models
|
|
||||||
return models.OVHSMSGateway
|
|
||||||
|
|
||||||
default_app_config = 'ovh.AppConfig'
|
|
|
@ -4,7 +4,6 @@ import json
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
|
|
||||||
from passerelle.base.models import BaseResource
|
from passerelle.base.models import BaseResource
|
||||||
from passerelle.sms import SMSGatewayMixin
|
from passerelle.sms import SMSGatewayMixin
|
||||||
|
@ -47,15 +46,6 @@ class OVHSMSGateway(BaseResource, SMSGatewayMixin):
|
||||||
def get_icon_class(cls):
|
def get_icon_class(cls):
|
||||||
return 'phone'
|
return 'phone'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse('ovh-view', kwargs={'slug': self.slug})
|
|
||||||
|
|
||||||
def get_edit_url(self):
|
|
||||||
return reverse('edit-connector', kwargs={'connector': 'ovh', 'slug': self.slug})
|
|
||||||
|
|
||||||
def get_delete_url(self):
|
|
||||||
return reverse('delete-connector', kwargs={'connector': 'ovh', 'slug': self.slug})
|
|
||||||
|
|
||||||
def send_msg(self, text, sender, destinations):
|
def send_msg(self, text, sender, destinations):
|
||||||
"""Send a SMS using the OVH provider"""
|
"""Send a SMS using the OVH provider"""
|
||||||
# unfortunately it lacks a batch API...
|
# unfortunately it lacks a batch API...
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.conf.urls import patterns, url
|
|
||||||
from views import *
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
|
||||||
url(r'^(?P<slug>[\w,-]+)/$', OvhDetailView.as_view(), name='ovh-view'),
|
|
||||||
)
|
|
|
@ -1,8 +0,0 @@
|
||||||
from passerelle.base.views import ResourceView
|
|
||||||
|
|
||||||
from .models import OVHSMSGateway
|
|
||||||
|
|
||||||
|
|
||||||
class OvhDetailView(ResourceView):
|
|
||||||
model = OVHSMSGateway
|
|
||||||
template_name = 'passerelle/manage/messages_service_view.html'
|
|
|
@ -29,15 +29,6 @@ class OxydSMSGateway(BaseResource, SMSGatewayMixin):
|
||||||
def get_icon_class(cls):
|
def get_icon_class(cls):
|
||||||
return 'phone'
|
return 'phone'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse('oxyd-view', kwargs={'slug': self.slug})
|
|
||||||
|
|
||||||
def get_edit_url(self):
|
|
||||||
return reverse('edit-connector', kwargs={'connector': 'oxyd', 'slug': self.slug})
|
|
||||||
|
|
||||||
def get_delete_url(self):
|
|
||||||
return reverse('delete-connector', kwargs={'connector': 'oxyd', 'slug': self.slug})
|
|
||||||
|
|
||||||
def send_msg(self, text, sender, destinations):
|
def send_msg(self, text, sender, destinations):
|
||||||
"""Send a SMS using the Oxyd provider"""
|
"""Send a SMS using the Oxyd provider"""
|
||||||
# unfortunately it lacks a batch API...
|
# unfortunately it lacks a batch API...
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.conf.urls import patterns, url
|
|
||||||
from views import *
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
|
||||||
url(r'^(?P<slug>[\w,-]+)/$', OxydDetailView.as_view(), name='oxyd-view'),
|
|
||||||
)
|
|
|
@ -1,8 +0,0 @@
|
||||||
from passerelle.base.views import ResourceView
|
|
||||||
|
|
||||||
from .models import OxydSMSGateway
|
|
||||||
|
|
||||||
|
|
||||||
class OxydDetailView(ResourceView):
|
|
||||||
model = OxydSMSGateway
|
|
||||||
template_name = 'passerelle/manage/messages_service_view.html'
|
|
|
@ -133,6 +133,10 @@ class BaseResource(models.Model):
|
||||||
def get_connector_slug(cls):
|
def get_connector_slug(cls):
|
||||||
return cls._meta.app_label.replace('_', '-')
|
return cls._meta.app_label.replace('_', '-')
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('view-connector',
|
||||||
|
kwargs={'connector': self.get_connector_slug(), 'slug': self.slug})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_add_url(cls):
|
def get_add_url(cls):
|
||||||
return reverse('create-connector', kwargs={'connector': cls.get_connector_slug()})
|
return reverse('create-connector', kwargs={'connector': cls.get_connector_slug()})
|
||||||
|
|
|
@ -36,9 +36,6 @@ class StubInvoicesConnector(BaseResource):
|
||||||
def get_icon_class(cls):
|
def get_icon_class(cls):
|
||||||
return 'ressources'
|
return 'ressources'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return reverse('stub-invoices-view', kwargs={'slug': self.slug})
|
|
||||||
|
|
||||||
# generate a serie of stub invoices
|
# generate a serie of stub invoices
|
||||||
invoices = {}
|
invoices = {}
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
|
|
|
@ -22,8 +22,6 @@ from .views import *
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^(?P<slug>[\w,-]+)/$', StubInvoicesConnectorDetailView.as_view(),
|
|
||||||
name='stub-invoices-view'),
|
|
||||||
url(r'^(?P<slug>[\w,-]+)/invoices/history/$', HistoryInvoicesView.as_view(),
|
url(r'^(?P<slug>[\w,-]+)/invoices/history/$', HistoryInvoicesView.as_view(),
|
||||||
name='stub-invoices-invoices-history'),
|
name='stub-invoices-invoices-history'),
|
||||||
url(r'^(?P<slug>[\w,-]+)/invoices/$', InvoicesView.as_view(),
|
url(r'^(?P<slug>[\w,-]+)/invoices/$', InvoicesView.as_view(),
|
||||||
|
|
|
@ -28,11 +28,6 @@ from passerelle import utils
|
||||||
from .models import StubInvoicesConnector
|
from .models import StubInvoicesConnector
|
||||||
|
|
||||||
|
|
||||||
class StubInvoicesConnectorDetailView(DetailView):
|
|
||||||
model = StubInvoicesConnector
|
|
||||||
template_name = 'passerelle/stub-invoices/detail.html'
|
|
||||||
|
|
||||||
|
|
||||||
class InvoicesView(DetailView):
|
class InvoicesView(DetailView):
|
||||||
model = StubInvoicesConnector
|
model = StubInvoicesConnector
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.views.static import serve as static_serve
|
||||||
|
|
||||||
from .views import (HomePageView, ManageView, ManageAddView,
|
from .views import (HomePageView, ManageView, ManageAddView,
|
||||||
GenericCreateConnectorView, GenericDeleteConnectorView,
|
GenericCreateConnectorView, GenericDeleteConnectorView,
|
||||||
GenericEditConnectorView, GenericEndpointView,
|
GenericEditConnectorView, GenericEndpointView, GenericConnectorView,
|
||||||
LEGACY_APPS_PATTERNS, LegacyPageView, login, logout)
|
LEGACY_APPS_PATTERNS, LegacyPageView, login, logout)
|
||||||
from .urls_utils import decorated_includes, required, app_enabled
|
from .urls_utils import decorated_includes, required, app_enabled
|
||||||
from .base.urls import access_urlpatterns
|
from .base.urls import access_urlpatterns
|
||||||
|
@ -85,6 +85,8 @@ urlpatterns += patterns('',
|
||||||
)))))
|
)))))
|
||||||
|
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
|
url(r'^(?P<connector>[\w,-]+)/(?P<slug>[\w,-]+)/$',
|
||||||
|
GenericConnectorView.as_view(), name='view-connector'),
|
||||||
url(r'^(?P<connector>[\w,-]+)/(?P<slug>[\w,-]+)/(?P<endpoint>[\w,-]+)$',
|
url(r'^(?P<connector>[\w,-]+)/(?P<slug>[\w,-]+)/(?P<endpoint>[\w,-]+)$',
|
||||||
GenericEndpointView.as_view(), name='generic-endpoint')
|
GenericEndpointView.as_view(), name='generic-endpoint')
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,8 @@ from django.contrib.auth import logout as auth_logout
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
from django.http import HttpResponseBadRequest, HttpResponseRedirect, Http404
|
from django.http import HttpResponseBadRequest, HttpResponseRedirect, Http404
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.views.generic import RedirectView, View, TemplateView, CreateView, DeleteView, UpdateView
|
from django.views.generic import (RedirectView, View, TemplateView, CreateView,
|
||||||
|
DeleteView, UpdateView, DetailView)
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -91,6 +92,10 @@ class GenericConnectorMixin(object):
|
||||||
request, *args, **kwargs)
|
request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class GenericConnectorView(GenericConnectorMixin, DetailView):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class GenericCreateConnectorView(GenericConnectorMixin, CreateView):
|
class GenericCreateConnectorView(GenericConnectorMixin, CreateView):
|
||||||
template_name = 'passerelle/manage/service_form.html'
|
template_name = 'passerelle/manage/service_form.html'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue