remove contrib.seisin_by_email (#43487)
This commit is contained in:
parent
64048399a1
commit
59c64cdcd9
|
@ -1,12 +0,0 @@
|
|||
Connect Publik with INES : sendSeisinByEmail
|
||||
============================================
|
||||
|
||||
How to use
|
||||
----------
|
||||
|
||||
1) Install python-suds
|
||||
|
||||
2) Add to your settings.py
|
||||
|
||||
# local_settings.py:
|
||||
INSTALLED_APPS += ('passerelle.contrib.seisin_by_email',)
|
|
@ -1,33 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SeisinByEmailManagement',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('title', models.CharField(verbose_name='Title', max_length=50)),
|
||||
('slug', models.SlugField(verbose_name='Identifier', unique=True)),
|
||||
('description', models.TextField(verbose_name='Description')),
|
||||
('wsdl_url', models.CharField(help_text='Seisin-by-Email WSDL URL', max_length=128, verbose_name='WSDL URL')),
|
||||
('verify_cert', models.BooleanField(default=True, verbose_name='Check HTTPS Certificate validity')),
|
||||
('username', models.CharField(max_length=128, verbose_name='Username', blank=True)),
|
||||
('password', models.CharField(max_length=128, verbose_name='Password', blank=True)),
|
||||
('keystore', models.FileField(help_text='Certificate and private key in PEM format', upload_to=b'seisin-by-email', null=True, verbose_name='Keystore', blank=True)),
|
||||
('users', models.ManyToManyField(to='base.ApiUser', related_name='_seisinbyemailmanagement_users_+', related_query_name='+', blank=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Seisin-by-Email',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seisin_by_email', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='seisinbyemailmanagement',
|
||||
options={'verbose_name': 'Seisin by Email'},
|
||||
),
|
||||
]
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seisin_by_email', '0002_auto_20151007_0744'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='seisinbyemailmanagement',
|
||||
name='log_level',
|
||||
field=models.CharField(default=b'NOTSET', max_length=10, verbose_name='Log Level', choices=[(b'NOTSET', b'NOTSET'), (b'DEBUG', b'DEBUG'), (b'INFO', b'INFO'), (b'WARNING', b'WARNING'), (b'ERROR', b'ERROR'), (b'CRITICAL', b'CRITICAL')]),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seisin_by_email', '0003_seisinbyemailmanagement_log_level'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='seisinbyemailmanagement',
|
||||
name='slug',
|
||||
field=models.SlugField(verbose_name='Identifier', unique=True),
|
||||
),
|
||||
]
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.12 on 2018-11-19 13:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seisin_by_email', '0004_auto_20170920_0951'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='seisinbyemailmanagement',
|
||||
name='log_level',
|
||||
),
|
||||
]
|
|
@ -1,44 +0,0 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# 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/>.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from passerelle.base.models import BaseResource
|
||||
|
||||
class SeisinByEmailManagement(BaseResource):
|
||||
wsdl_url = models.CharField(max_length=128, blank=False,
|
||||
verbose_name=_('WSDL URL'),
|
||||
help_text=_('Seisin-by-Email WSDL URL'))
|
||||
verify_cert = models.BooleanField(default=True,
|
||||
verbose_name=_('Check HTTPS Certificate validity'))
|
||||
username = models.CharField(max_length=128, blank=True,
|
||||
verbose_name=_('Username'))
|
||||
password = models.CharField(max_length=128, blank=True,
|
||||
verbose_name=_('Password'))
|
||||
keystore = models.FileField(upload_to='seisin-by-email', null=True, blank=True,
|
||||
verbose_name=_('Keystore'),
|
||||
help_text=_('Certificate and private key in PEM format'))
|
||||
|
||||
category = _('Business Process Connectors')
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Seisin by Email')
|
||||
|
||||
@classmethod
|
||||
def get_verbose_name(cls):
|
||||
return cls._meta.verbose_name
|
|
@ -1,61 +0,0 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# 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/>.
|
||||
|
||||
# borrowed from https://pypi.python.org/pypi/suds_requests
|
||||
# and https://docs.oracle.com/cd/E50245_01/E50253/html/vmprg-soap-example-authentication-python.html
|
||||
|
||||
import requests
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.six import StringIO
|
||||
from suds.transport.http import HttpAuthenticated
|
||||
from suds.transport import Reply
|
||||
from suds.client import Client
|
||||
|
||||
|
||||
class Transport(HttpAuthenticated):
|
||||
def __init__(self, model, **kwargs):
|
||||
self.model = model
|
||||
HttpAuthenticated.__init__(self, **kwargs) # oldstyle class...
|
||||
|
||||
def get_requests_kwargs(self):
|
||||
kwargs = {}
|
||||
if self.model.username:
|
||||
kwargs['auth'] = (self.model.username, self.model.password)
|
||||
if self.model.keystore:
|
||||
kwargs['cert'] = (self.model.keystore.path, self.model.keystore.path)
|
||||
if not self.model.verify_cert:
|
||||
kwargs['verify'] = False
|
||||
if getattr(settings, 'REQUESTS_PROXIES', None):
|
||||
kwargs['proxies'] = settings.REQUESTS_PROXIES
|
||||
return kwargs
|
||||
|
||||
def open(self, request):
|
||||
resp = requests.get(request.url, headers=request.headers,
|
||||
**self.get_requests_kwargs())
|
||||
return StringIO(resp.content)
|
||||
|
||||
def send(self, request):
|
||||
self.addcredentials(request)
|
||||
resp = requests.post(request.url, data=request.message,
|
||||
headers=request.headers, **self.get_requests_kwargs())
|
||||
result = Reply(resp.status_code, resp.headers, resp.content)
|
||||
return result
|
||||
|
||||
|
||||
def get_client(model):
|
||||
transport = Transport(model)
|
||||
return Client(model.wsdl_url, transport=transport, cache=None)
|
|
@ -1,21 +0,0 @@
|
|||
{% extends "passerelle/manage/service_view.html" %}
|
||||
{% load i18n passerelle %}
|
||||
|
||||
{% block description %}
|
||||
{% endblock %}
|
||||
|
||||
{% block endpoints %}
|
||||
<ul>
|
||||
<li>{% trans 'Check WSDL availability:' %} <a href="{% url 'seisin-by-email-ping' slug=object.slug %}"
|
||||
>{{ site_base_uri }}{% url 'seisin-by-email-ping' slug=object.slug %}</a>[?debug]</li>
|
||||
<li>{% trans 'Send a resource by email:' %} POST <a href="{% url 'seisin-by-email-resource' slug=object.slug %}"
|
||||
>{{ site_base_uri }}{% url 'seisin-by-email-resource' slug=object.slug %}</a> (payload: JSON w.c.s. formdata)</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block security %}
|
||||
<p>
|
||||
{% trans 'Access is limited to the following API users:' %}
|
||||
</p>
|
||||
{% access_rights_table resource=object permission='can_access' %}
|
||||
{% endblock %}
|
|
@ -1,28 +0,0 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# 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/>.
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^(?P<slug>[\w,-]+)/$', SeisinByEmailManagementDetailView.as_view(),
|
||||
name='seisin-by-email-view'),
|
||||
url(r'^(?P<slug>[\w,-]+)/ping/$', PingView.as_view(),
|
||||
name='seisin-by-email-ping'),
|
||||
url(r'^(?P<slug>[\w,-]+)/resource/$', ResourceView.as_view(),
|
||||
name='seisin-by-email-resource'),
|
||||
]
|
|
@ -1,128 +0,0 @@
|
|||
# passerelle - uniform access to multiple data sources and services
|
||||
# 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/>.
|
||||
|
||||
from django.views.generic import DetailView as GenericDetailView
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from passerelle.compat import json_loads
|
||||
import passerelle.utils as utils
|
||||
from passerelle.soap import sudsobject_to_dict, client_to_jsondict
|
||||
|
||||
from .soap import get_client
|
||||
from .models import SeisinByEmailManagement
|
||||
|
||||
|
||||
class SeisinByEmailManagementDetailView(GenericDetailView):
|
||||
model = SeisinByEmailManagement
|
||||
template_name = 'passerelle/contrib/seisin_by_email/detail.html'
|
||||
|
||||
|
||||
class DetailView(GenericDetailView):
|
||||
model = SeisinByEmailManagement
|
||||
|
||||
def get_client(self):
|
||||
return get_client(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 PingView(DetailView):
|
||||
def get_data(self, request, *args, **kwargs):
|
||||
client = self.get_client()
|
||||
res = {'ping': 'pong'}
|
||||
if 'debug' in request.GET:
|
||||
res['client'] = client_to_jsondict(client)
|
||||
return res
|
||||
|
||||
|
||||
class ResourceView(DetailView):
|
||||
@method_decorator(csrf_exempt)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(ResourceView, self).dispatch(*args, **kwargs)
|
||||
|
||||
@utils.protected_api('can_access')
|
||||
def post(self, request, *args, **kwargs):
|
||||
client = self.get_client()
|
||||
formdata = json_loads(request.body)
|
||||
fields = formdata.get('fields', {})
|
||||
extras = formdata.get('extra', {})
|
||||
|
||||
debug = 'debug' in request.GET
|
||||
if debug:
|
||||
debug_output = {}
|
||||
|
||||
# attachment: only one (the first)
|
||||
attachmentData = client.factory.create('arrayOfAttachmentContent')
|
||||
attachmentData.source = '?'
|
||||
for name, value in fields.items():
|
||||
if isinstance(value, dict) and value.get('filename') and value.get('content'):
|
||||
attachmentData.fileName = '"%s"' % value['filename']
|
||||
attachmentData.attachmentType = value.get('content_type')
|
||||
attachmentData.source = value['content']
|
||||
break
|
||||
|
||||
if debug:
|
||||
debug_output['attachmentData'] = '%r' % attachmentData
|
||||
|
||||
# data
|
||||
data = client.factory.create('listOfData')
|
||||
data.datas = []
|
||||
for name, value in extras.items():
|
||||
if not name.startswith('seisin_by_email_data_'):
|
||||
continue
|
||||
item = client.factory.create('arrayOfDataContent')
|
||||
item.key = name[21:]
|
||||
item.value = value
|
||||
data.datas.append(item)
|
||||
|
||||
if debug:
|
||||
debug_output['data'] = '%r' % data
|
||||
|
||||
# other variables
|
||||
departement_number = extras.get('seisin_by_email_departement_number', '')
|
||||
target_entity = extras.get('seisin_by_email_target_entity', -1)
|
||||
theme = extras.get('seisin_by_email_theme', '')
|
||||
userType = extras.get('seisin_by_email_userType', '')
|
||||
request_object = extras.get('seisin_by_email_request_object', '')
|
||||
|
||||
if debug:
|
||||
debug_output['departement_number'] = departement_number
|
||||
debug_output['target_entity'] = target_entity
|
||||
debug_output['theme'] = theme
|
||||
debug_output['userType'] = userType
|
||||
debug_output['request_object'] = request_object
|
||||
|
||||
# call sendSeisinByEmail web service
|
||||
results = client.service.sendSeisinByEmail(departement_number,
|
||||
target_entity,
|
||||
theme,
|
||||
userType,
|
||||
request_object,
|
||||
data,
|
||||
attachmentData)
|
||||
data = sudsobject_to_dict(results)
|
||||
|
||||
if debug:
|
||||
data['debug'] = debug_output
|
||||
|
||||
return utils.response_for_json(request, data)
|
|
@ -29,7 +29,6 @@ INSTALLED_APPS += (
|
|||
'passerelle.contrib.meyzieu_newsletters',
|
||||
'passerelle.contrib.nancypoll',
|
||||
'passerelle.contrib.planitech',
|
||||
'passerelle.contrib.seisin_by_email',
|
||||
'passerelle.contrib.solis_apa',
|
||||
'passerelle.contrib.strasbourg_eu',
|
||||
'passerelle.contrib.stub_invoices',
|
||||
|
|
Loading…
Reference in New Issue