Projet

Général

Profil

0002-misc-apply-isort-52937.patch

Nicolas Roche, 12 avril 2021 10:08

Télécharger (315 ko)

Voir les différences:

Subject: [PATCH 2/3] misc: apply isort (#52937)

 functests/cmis/conftest.py                    |  2 +-
 functests/cmis/tests_cmis.py                  |  3 +-
 functests/planitech/test_planitech.py         |  2 +-
 functests/toulouse_axel/test_toulouse_axel.py |  1 +
 functests/vivaticket/test_vivaticket.py       |  6 ++-
 passerelle/api/views.py                       |  3 +-
 passerelle/apps/actesweb/models.py            |  4 +-
 passerelle/apps/api_entreprise/models.py      | 12 +++---
 .../migrations/0001_initial.py                |  2 +-
 passerelle/apps/api_particulier/models.py     |  1 +
 passerelle/apps/arcgis/forms.py               |  1 +
 .../migrations/0005_auto_20200310_1517.py     |  3 +-
 .../migrations/0006_auto_20200401_1025.py     |  2 +-
 passerelle/apps/arcgis/models.py              |  8 ++--
 passerelle/apps/arcgis/views.py               |  2 +-
 passerelle/apps/arpege_ecp/models.py          |  8 ++--
 .../apps/astregs/migrations/0001_initial.py   |  2 +-
 passerelle/apps/astregs/models.py             |  8 ++--
 passerelle/apps/atal/models.py                |  4 +-
 .../atos_genesys/migrations/0001_initial.py   |  4 +-
 passerelle/apps/atos_genesys/models.py        |  4 +-
 passerelle/apps/atos_genesys/utils.py         |  2 +-
 .../base_adresse/migrations/0001_initial.py   |  2 +-
 .../migrations/0002_auto_20150705_0330.py     |  2 +-
 .../migrations/0003_baseaddresse_log_level.py |  2 +-
 .../migrations/0004_auto_20160316_0910.py     |  2 +-
 .../migrations/0005_auto_20160407_0456.py     |  2 +-
 .../0008_delete_updatestreetmodel.py          |  2 +-
 .../0009_streetmodel_simple_name.py           |  2 +-
 .../migrations/0010_auto_20160914_0826.py     |  2 +-
 .../migrations/0011_auto_20160919_0949.py     |  2 +-
 .../migrations/0015_auto_20191206_1244.py     |  3 +-
 .../migrations/0016_auto_20200130_1604.py     |  2 +-
 passerelle/apps/base_adresse/models.py        | 10 ++---
 .../apps/bdp/migrations/0001_initial.py       |  2 +-
 .../apps/bdp/migrations/0002_bdp_log_level.py |  2 +-
 .../bdp/migrations/0003_auto_20160316_0910.py |  2 +-
 .../bdp/migrations/0004_auto_20160407_0456.py |  2 +-
 passerelle/apps/bdp/models.py                 |  6 +--
 passerelle/apps/bdp/urls.py                   |  5 ++-
 passerelle/apps/bdp/views.py                  |  4 +-
 .../cartads_cs/migrations/0001_initial.py     |  1 +
 .../migrations/0002_cartadsdatacache.py       |  2 +-
 ...0004_cartadsdossier_cartads_steps_cache.py |  2 +-
 ...0011_cartadsdossier_cartads_cache_infos.py |  2 +-
 passerelle/apps/cartads_cs/models.py          | 15 +++-----
 .../apps/choosit/migrations/0001_initial.py   |  2 +-
 .../migrations/0002_auto_20160316_0528.py     |  2 +-
 .../migrations/0003_auto_20160316_0910.py     |  2 +-
 .../migrations/0004_auto_20160407_0456.py     |  2 +-
 ..._choositsmsgateway_default_trunk_prefix.py |  2 +-
 passerelle/apps/choosit/models.py             |  2 +-
 passerelle/apps/cityweb/cityweb.py            |  8 ++--
 passerelle/apps/cityweb/models.py             | 10 ++---
 .../apps/clicrdv/migrations/0001_initial.py   |  2 +-
 passerelle/apps/clicrdv/models.py             |  6 +--
 passerelle/apps/clicrdv/urls.py               |  5 +--
 passerelle/apps/clicrdv/views.py              |  5 +--
 .../apps/cmis/migrations/0001_initial.py      |  2 +-
 passerelle/apps/cmis/models.py                | 17 +++++----
 passerelle/apps/cmis/views.py                 |  1 -
 .../apps/cryptor/migrations/0001_initial.py   |  6 ++-
 passerelle/apps/cryptor/models.py             |  6 +--
 .../management/commands/change-csv.py         |  2 +-
 .../csvdatasource/migrations/0001_initial.py  |  2 +-
 .../0002_csvdatasource_log_level.py           |  2 +-
 .../migrations/0003_auto_20160316_0910.py     |  2 +-
 .../migrations/0004_auto_20160407_0456.py     |  2 +-
 .../0005_csvdatasource__dialect_options.py    |  2 +-
 .../migrations/0006_auto_20160905_1031.py     |  2 +-
 .../migrations/0009_auto_20161109_0353.py     |  2 +-
 .../migrations/0011_auto_20180905_0936.py     |  4 +-
 .../migrations/0016_auto_20200406_1702.py     |  2 +-
 .../migrations/0019_csv_upload_to.py          |  1 +
 .../migrations/0020_csv_upload_to.py          |  1 +
 passerelle/apps/csvdatasource/models.py       | 23 +++++-------
 passerelle/apps/csvdatasource/views.py        |  2 +-
 .../apps/esirius/migrations/0001_initial.py   |  1 +
 passerelle/apps/esirius/models.py             |  4 +-
 .../apps/family/loaders/concerto_fondettes.py |  4 +-
 .../apps/family/loaders/concerto_orleans.py   | 11 +++---
 .../apps/family/loaders/opus_fondettes.py     |  4 +-
 .../commands/import_orleans_data.py           |  6 +--
 .../apps/family/migrations/0001_initial.py    |  2 +-
 .../migrations/0007_auto_20161122_1816.py     |  3 +-
 passerelle/apps/family/models.py              | 12 +++---
 passerelle/apps/feeds/models.py               |  1 -
 .../apps/gdc/migrations/0001_initial.py       |  2 +-
 .../apps/gdc/migrations/0002_gdc_log_level.py |  2 +-
 .../gdc/migrations/0003_auto_20160316_0910.py |  2 +-
 .../gdc/migrations/0004_auto_20160407_0456.py |  2 +-
 passerelle/apps/gdc/urls.py                   |  5 ++-
 passerelle/apps/gdc/views.py                  |  4 +-
 .../apps/gesbac/migrations/0001_initial.py    |  5 ++-
 passerelle/apps/gesbac/models.py              |  8 ++--
 .../jsondatastore/migrations/0001_initial.py  |  3 +-
 passerelle/apps/jsondatastore/models.py       |  2 +-
 .../apps/maelis/migrations/0001_initial.py    |  2 +-
 passerelle/apps/maelis/models.py              |  9 ++---
 passerelle/apps/maelis/utils.py               |  4 +-
 passerelle/apps/mdel/mdel.py                  |  7 ++--
 .../migrations/0003_auto_20170125_0450.py     |  3 +-
 .../migrations/0006_auto_20210126_1440.py     |  1 +
 passerelle/apps/mdel/models.py                |  6 +--
 passerelle/apps/mdel_ddpacs/abstract.py       | 13 +++----
 .../mdel_ddpacs/migrations/0001_initial.py    |  5 ++-
 .../migrations/0002_auto_20200504_1402.py     |  1 +
 passerelle/apps/mdel_ddpacs/models.py         |  5 +--
 .../apps/mobyt/migrations/0001_initial.py     |  2 +-
 .../0002_mobytsmsgateway_log_level.py         |  2 +-
 .../migrations/0003_auto_20160316_0910.py     |  2 +-
 .../migrations/0004_auto_20160407_0456.py     |  2 +-
 ...05_mobytsmsgateway_default_trunk_prefix.py |  2 +-
 passerelle/apps/mobyt/models.py               |  3 +-
 passerelle/apps/opendatasoft/forms.py         |  1 +
 .../opendatasoft/migrations/0001_initial.py   |  3 +-
 passerelle/apps/opendatasoft/models.py        |  4 +-
 passerelle/apps/opendatasoft/views.py         |  2 +-
 passerelle/apps/opengis/forms.py              |  1 +
 .../migrations/0005_auto_20180227_1531.py     |  2 +-
 .../migrations/0007_auto_20200401_1032.py     |  2 +-
 .../opengis/migrations/0008_featurecache.py   |  4 +-
 passerelle/apps/opengis/models.py             |  6 +--
 passerelle/apps/opengis/views.py              |  2 +-
 .../apps/orange/migrations/0001_initial.py    |  2 +-
 .../0002_orangesmsgateway_log_level.py        |  2 +-
 .../migrations/0003_auto_20160316_0910.py     |  2 +-
 .../migrations/0004_auto_20160407_0456.py     |  2 +-
 passerelle/apps/orange/models.py              |  1 -
 .../apps/ovh/migrations/0001_initial.py       |  2 +-
 .../0002_ovhsmsgateway_log_level.py           |  2 +-
 .../ovh/migrations/0003_auto_20160316_0910.py |  2 +-
 .../ovh/migrations/0004_auto_20160407_0456.py |  2 +-
 ...0005_ovhsmsgateway_default_trunk_prefix.py |  2 +-
 passerelle/apps/ovh/models.py                 |  4 +-
 .../apps/oxyd/migrations/0001_initial.py      |  2 +-
 .../0002_oxydsmsgateway_log_level.py          |  2 +-
 .../migrations/0003_auto_20160316_0910.py     |  2 +-
 .../migrations/0004_auto_20160407_0456.py     |  2 +-
 ...005_oxydsmsgateway_default_trunk_prefix.py |  2 +-
 passerelle/apps/oxyd/models.py                |  3 +-
 .../phonecalls/migrations/0001_initial.py     |  4 +-
 passerelle/apps/phonecalls/models.py          |  6 +--
 passerelle/apps/photon/models.py              |  6 +--
 .../migrations/0003_auto_20171219_0800.py     |  1 +
 .../solis/migrations/0006_solisrsalink.py     |  2 +-
 passerelle/apps/solis/models.py               |  4 +-
 passerelle/apps/sp_fr/fields.py               |  4 +-
 passerelle/apps/sp_fr/forms.py                |  2 +-
 .../apps/sp_fr/migrations/0001_initial.py     |  5 ++-
 passerelle/apps/sp_fr/models.py               | 18 ++++-----
 passerelle/apps/sp_fr/views.py                |  6 +--
 passerelle/apps/sp_fr/xsd.py                  |  3 +-
 passerelle/apps/twilio/models.py              |  5 +--
 passerelle/base/admin.py                      |  4 +-
 passerelle/base/forms.py                      |  2 +-
 passerelle/base/management/commands/cron.py   |  3 +-
 .../base/management/commands/ensure_jsonb.py  |  2 +-
 passerelle/base/migrations/0001_initial.py    |  2 +-
 .../migrations/0002_auto_20151009_0326.py     |  2 +-
 .../migrations/0003_auto_20170116_1656.py     |  2 +-
 .../migrations/0004_auto_20170117_0326.py     |  2 +-
 .../base/migrations/0005_resourcelog.py       |  2 +-
 .../base/migrations/0007_loggingparameters.py |  2 +-
 .../migrations/0011_auto_20190205_1126.py     |  2 +-
 passerelle/base/migrations/0012_job.py        |  4 +-
 .../migrations/0014_auto_20190820_0914.py     |  1 +
 .../migrations/0015_auto_20190921_0347.py     |  1 +
 .../migrations/0017_auto_20200310_1806.py     |  3 +-
 passerelle/base/models.py                     | 26 ++++++-------
 passerelle/base/signature.py                  |  5 +--
 passerelle/base/templatetags/passerelle.py    |  9 +++--
 passerelle/base/urls.py                       | 10 ++---
 passerelle/base/views.py                      | 11 +++---
 passerelle/contrib/dpark/models.py            |  8 ++--
 .../contrib/fake_family/default_database.py   |  4 +-
 .../fake_family/migrations/0001_initial.py    |  2 +-
 .../migrations/0002_fakefamily_log_level.py   |  2 +-
 passerelle/contrib/fake_family/models.py      |  3 +-
 passerelle/contrib/gdema/models.py            |  2 +-
 passerelle/contrib/greco/models.py            | 15 +++-----
 passerelle/contrib/grenoble_gru/models.py     |  8 ++--
 .../iparapheur/migrations/0001_initial.py     |  2 +-
 .../migrations/0002_auto_20160406_1123.py     |  2 +-
 .../migrations/0003_iparapheur_log_level.py   |  2 +-
 passerelle/contrib/iparapheur/models.py       |  9 ++---
 passerelle/contrib/isere_ens/models.py        |  7 ++--
 passerelle/contrib/iws/models.py              |  7 ++--
 passerelle/contrib/lille_kimoce/models.py     |  5 +--
 .../contrib/mdph13/migrations/0001_initial.py |  2 +-
 passerelle/contrib/mdph13/models.py           |  9 ++---
 .../nancypoll/migrations/0001_initial.py      |  2 +-
 .../migrations/0004_csv_upload_to.py          |  1 +
 .../migrations/0005_csv_upload_to.py          |  1 +
 passerelle/contrib/nancypoll/models.py        |  3 +-
 .../0002_planitechconnector_custom_fields.py  |  2 +-
 .../planitech/migrations/0003_pairing.py      |  2 +-
 passerelle/contrib/planitech/models.py        |  6 +--
 passerelle/contrib/planitech/mste.py          |  3 +-
 passerelle/contrib/rsa13/models.py            |  3 +-
 passerelle/contrib/sigerly/models.py          |  1 -
 .../solis_apa/migrations/0001_initial.py      |  2 +-
 passerelle/contrib/solis_apa/models.py        |  9 ++---
 passerelle/contrib/solis_apa/suivi.py         |  2 +-
 passerelle/contrib/solis_apa/views.py         |  7 ++--
 passerelle/contrib/strasbourg_eu/models.py    |  2 +-
 passerelle/contrib/stub_invoices/models.py    |  4 +-
 passerelle/contrib/tcl/models.py              |  2 +-
 .../teamnet_axel/migrations/0001_initial.py   |  2 +-
 .../0002_management_billing_regies.py         |  2 +-
 .../migrations/0003_management_log_level.py   |  2 +-
 passerelle/contrib/teamnet_axel/models.py     |  6 +--
 passerelle/contrib/teamnet_axel/soap.py       |  4 +-
 .../toulouse_axel/migrations/0001_initial.py  |  2 +-
 .../migrations/0003_auto_20191205_0948.py     |  2 +-
 passerelle/contrib/toulouse_axel/models.py    |  4 +-
 passerelle/contrib/toulouse_axel/schemas.py   |  4 +-
 passerelle/contrib/toulouse_axel/utils.py     |  4 +-
 passerelle/plugins.py                         |  2 +-
 passerelle/settings.py                        |  5 ++-
 passerelle/sms/models.py                      |  1 -
 passerelle/soap.py                            |  2 +-
 passerelle/urls.py                            | 23 +++++-------
 passerelle/urls_utils.py                      |  3 +-
 passerelle/utils/__init__.py                  | 29 +++++++--------
 passerelle/utils/conversion.py                |  3 +-
 passerelle/utils/files.py                     |  4 +-
 passerelle/utils/http_authenticators.py       |  1 -
 passerelle/utils/json.py                      |  1 -
 passerelle/utils/jsonresponse.py              | 12 +++---
 passerelle/utils/paginator.py                 |  2 +-
 passerelle/utils/sftp.py                      | 16 ++++----
 passerelle/utils/soap.py                      |  4 +-
 passerelle/utils/templates.py                 |  3 +-
 passerelle/utils/wcs.py                       | 15 ++++----
 passerelle/utils/xml.py                       |  2 +-
 passerelle/utils/zip.py                       | 14 +++----
 passerelle/views.py                           | 37 +++++++++----------
 setup.py                                      |  6 +--
 tests/conftest.py                             | 11 +++---
 tests/test_actesweb.py                        |  5 +--
 tests/test_adict.py                           |  4 +-
 tests/test_airquality.py                      |  3 +-
 tests/test_api.py                             |  8 ++--
 tests/test_api_access.py                      | 12 +++---
 tests/test_api_entreprise.py                  |  9 ++---
 tests/test_api_particulier.py                 | 14 +++----
 tests/test_arcgis.py                          | 11 +++---
 tests/test_arcgis_nancy.py                    |  9 ++---
 tests/test_arpege_ecp.py                      |  5 +--
 tests/test_astregs.py                         | 14 +++----
 tests/test_atal.py                            |  8 ++--
 tests/test_atos_genesys.py                    |  6 +--
 tests/test_availability.py                    |  5 +--
 tests/test_base_adresse.py                    | 13 +++----
 tests/test_cartads_cs.py                      | 12 +++---
 tests/test_cityweb.py                         | 15 ++++----
 tests/test_clicrdv.py                         |  9 ++---
 tests/test_cmis.py                            | 31 ++++++++--------
 tests/test_cron.py                            |  1 -
 tests/test_cryptor.py                         |  9 ++---
 tests/test_csv_datasource.py                  | 22 +++++------
 tests/test_dpark.py                           | 12 +++---
 tests/test_ensure_jsonbfields.py              |  1 -
 tests/test_esirius.py                         |  7 ++--
 tests/test_fake_family.py                     |  2 +-
 tests/test_family.py                          | 34 +++++++++--------
 tests/test_feeds.py                           |  3 +-
 tests/test_gdema.py                           |  7 ++--
 tests/test_generic_endpoint.py                | 20 ++++++----
 tests/test_gesbac.py                          |  6 +--
 tests/test_grandlyon_streetsections.py        |  5 +--
 tests/test_greco.py                           | 10 ++---
 tests/test_grenoble_gru.py                    |  3 +-
 tests/test_import_export.py                   | 14 +++----
 tests/test_iparapheur.py                      | 18 ++++-----
 tests/test_isere_ens.py                       |  3 +-
 tests/test_iws.py                             |  4 +-
 tests/test_jobs.py                            | 13 ++-----
 tests/test_jsondatastore.py                   |  5 +--
 tests/test_jsonresponse.py                    |  6 +--
 tests/test_lille_kimoce.py                    |  3 +-
 tests/test_lille_urban_card.py                |  6 +--
 tests/test_maelis.py                          | 14 +++----
 tests/test_manager.py                         | 10 ++---
 tests/test_mdel.py                            | 12 +++---
 tests/test_mdel_ddpacs.py                     |  6 +--
 tests/test_mdph13.py                          | 10 ++---
 tests/test_misc.py                            | 12 +++---
 tests/test_nancypoll.py                       |  8 ++--
 tests/test_okina.py                           |  7 ++--
 tests/test_opendatasoft.py                    |  8 ++--
 tests/test_opengis.py                         | 10 ++---
 tests/test_orange.py                          |  7 +---
 tests/test_phonecalls.py                      |  8 ++--
 tests/test_photon.py                          | 10 ++---
 tests/test_planitech.py                       | 10 ++---
 tests/test_proxylogger.py                     | 14 +++----
 tests/test_requests.py                        | 14 +++----
 tests/test_rsa13.py                           |  1 -
 tests/test_sigerly.py                         |  4 +-
 tests/test_sms.py                             | 16 ++++----
 tests/test_soap.py                            |  7 ++--
 tests/test_solis.py                           |  5 +--
 tests/test_solis_afi_mss.py                   |  1 -
 tests/test_solis_apa.py                       | 10 ++---
 tests/test_strasbourg_eu.py                   |  8 ++--
 tests/test_tcl.py                             |  7 ++--
 tests/test_teamnet_axel.py                    |  6 +--
 tests/test_toulouse_axel.py                   | 23 +++++-------
 tests/test_toulouse_axel_schema.py            |  4 +-
 tests/test_toulouse_axel_utils.py             |  3 +-
 tests/test_utils_files.py                     |  2 +-
 tests/test_utils_json.py                      |  6 +--
 tests/test_utils_sftp.py                      |  3 +-
 tests/test_utils_xml.py                       |  7 ++--
 tests/test_utils_zip.py                       |  2 +-
 tests/test_vivaticket.py                      |  4 +-
 tests/utils.py                                |  5 +--
 tests/wcs/conftest.py                         | 19 +++++-----
 tests/wcs/test_conftest.py                    |  3 +-
 tests/wcs/test_sp_fr.py                       |  8 ++--
 322 files changed, 807 insertions(+), 950 deletions(-)
functests/cmis/conftest.py
1 1
import random
2 2

  
3
import pytest
4 3
import cmislib
4
import pytest
5 5

  
6 6

  
7 7
def pytest_addoption(parser):
8 8
    parser.addoption("--cmis-connector-url", help="Url of a passerelle CMIS connector instance")
9 9
    parser.addoption("--cmis-endpoint", help="Url of a passerelle CMIS endpoint")
10 10
    parser.addoption("--cmis-username", help="Username for the CMIS endpoint")
11 11
    parser.addoption("--cmis-password", help="Password for the CMIS endpoint")
12 12
    parser.addoption("--preserve-tree", action="store_true", default=False, help="Preserve test directory")
functests/cmis/tests_cmis.py
1 1
import base64
2 2
import hashlib
3 3
import os
4 4

  
5
from django.utils.six.moves.urllib import parse as urlparse
6 5
import pytest
7 6
import requests
8

  
7
from django.utils.six.moves.urllib import parse as urlparse
9 8

  
10 9
SPECIAL_CHARS = '!#$%&+-^_`;[]{}+='
11 10

  
12 11

  
13 12
@pytest.mark.parametrize(
14 13
    "path,file_name",
15 14
    [
16 15
        ('', 'some.file'),
functests/planitech/test_planitech.py
1 1
import pprint
2 2
import random
3 3

  
4
from django.utils.six.moves.urllib import parse
5 4
import requests
5
from django.utils.six.moves.urllib import parse
6 6

  
7 7

  
8 8
def test_main(conn):
9 9
    # get days
10 10
    query_string = parse.urlencode(
11 11
        {'start_days': 1, 'end_days': 90, 'start_time': '10:00', 'end_time': '11:00', 'display': 'date'}
12 12
    )
13 13
    url = conn + '/getfreegaps?%s' % query_string
functests/toulouse_axel/test_toulouse_axel.py
1 1
import pprint
2

  
2 3
import requests
3 4

  
4 5

  
5 6
def test_link(conn, user):
6 7
    print("Get update management dates")
7 8
    url = conn + '/management_dates'
8 9
    resp = requests.get(url)
9 10
    resp.raise_for_status()
functests/vivaticket/test_vivaticket.py
1 1
from __future__ import print_function
2
import pprint
2

  
3 3
import datetime
4
import requests
4
import pprint
5 5
import random
6 6

  
7
import requests
8

  
7 9

  
8 10
def call_generic(conn, endpoint):
9 11
    print("%s \n" % endpoint)
10 12
    url = conn + '/%s' % endpoint
11 13
    resp = requests.get(url)
12 14
    resp.raise_for_status()
13 15
    res = resp.json()
14 16
    assert res['err'] == 0
passerelle/api/views.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.core.exceptions import PermissionDenied
18
from django.http import Http404
19
from django.http import JsonResponse
18
from django.http import Http404, JsonResponse
20 19
from django.views.generic import DetailView
21 20

  
22 21
from passerelle.base.models import Job
23 22
from passerelle.utils import is_authorized
24 23

  
25 24

  
26 25
class JobDetailView(DetailView):
27 26
    model = Job
passerelle/apps/actesweb/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
from __future__ import unicode_literals
17 17

  
18
import contextlib
18 19
import os
19 20
import stat
20 21
import tempfile
21
import contextlib
22 22

  
23 23
from django.core.files.storage import default_storage
24 24
from django.template.loader import get_template
25 25
from django.utils.dateparse import parse_date
26 26
from django.utils.encoding import force_bytes
27 27
from django.utils.timezone import now
28 28
from django.utils.translation import ugettext_lazy as _
29 29

  
30 30
from passerelle.base.models import BaseResource
31 31
from passerelle.compat import json_loads
32 32
from passerelle.utils.api import endpoint
33
from passerelle.utils.jsonresponse import APIError
34 33
from passerelle.utils.conversion import ensure_encoding
34
from passerelle.utils.jsonresponse import APIError
35 35

  
36 36

  
37 37
@contextlib.contextmanager
38 38
def named_tempfile(*args, **kwargs):
39 39
    with tempfile.NamedTemporaryFile(*args, **kwargs) as fp:
40 40
        yield fp
41 41

  
42 42

  
passerelle/apps/api_entreprise/models.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
'''Gateway to API-Entreprise web-service from SGMAP:
18 18
   https://entreprise.api.gouv.fr
19 19
'''
20 20

  
21
from six.moves.urllib_parse import urljoin
22 21
import requests
23

  
24

  
25
from django.db import models
26
from django.utils.translation import ugettext_lazy as _
27
from django.utils.timezone import datetime, make_aware, timedelta
28
from django.http import HttpResponse, Http404
29 22
from django.core import signing
23
from django.db import models
24
from django.http import Http404, HttpResponse
30 25
from django.urls import reverse
26
from django.utils.timezone import datetime, make_aware, timedelta
27
from django.utils.translation import ugettext_lazy as _
28
from six.moves.urllib_parse import urljoin
31 29

  
32 30
from passerelle.base.models import BaseResource
33 31
from passerelle.utils.api import endpoint
34 32
from passerelle.utils.jsonresponse import APIError, exception_to_text
35 33
from passerelle.views import WrongParameter
36 34

  
37 35
DOCUMENT_SIGNATURE_MAX_AGE = timedelta(days=7)
38 36

  
passerelle/apps/api_particulier/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/apps/api_particulier/models.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
'''Gateway to API-Particulier web-service from SGMAP:
18 18
   https://particulier.api.gouv.fr/
19 19
'''
20 20

  
21 21
from collections import OrderedDict
22

  
22 23
import requests
23 24

  
24 25
try:
25 26
    from json.decoder import JSONDecodeError
26 27
except ImportError:
27 28
    JSONDecodeError = ValueError
28 29

  
29 30

  
passerelle/apps/arcgis/forms.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django import forms
18 18

  
19 19
from passerelle.base.forms import BaseQueryFormMixin
20

  
20 21
from . import models
21 22

  
22 23

  
23 24
class QueryForm(BaseQueryFormMixin, forms.ModelForm):
24 25
    class Meta:
25 26
        model = models.Query
26 27
        fields = '__all__'
27 28
        exclude = ['resource']
passerelle/apps/arcgis/migrations/0005_auto_20200310_1517.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2020-03-10 20:17
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7

  
7 8
import passerelle.apps.arcgis.models
8 9
import passerelle.utils.templates
9 10

  
10 11

  
11 12
class Migration(migrations.Migration):
12 13

  
13 14
    dependencies = [
14 15
        ('arcgis', '0004_remove_arcgis_log_level'),
passerelle/apps/arcgis/migrations/0006_auto_20200401_1025.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-04-01 08:25
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('arcgis', '0005_auto_20200310_1517'),
13 13
    ]
14 14

  
passerelle/apps/arcgis/models.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import string
18 18

  
19 19
from django.core.exceptions import ValidationError
20
from django.urls import reverse
21 20
from django.db import models
22 21
from django.http import HttpResponse
23 22
from django.shortcuts import get_object_or_404
24
from django.utils.six.moves.urllib import parse as urlparse
23
from django.urls import reverse
25 24
from django.utils import six
25
from django.utils.six.moves.urllib import parse as urlparse
26 26
from django.utils.text import slugify
27 27
from django.utils.translation import ugettext_lazy as _
28 28

  
29
from passerelle.base.models import BaseQuery, BaseResource, HTTPResource
29 30
from passerelle.utils import mark_safe_lazy
30
from passerelle.utils.jsonresponse import APIError
31 31
from passerelle.utils.api import endpoint
32 32
from passerelle.utils.conversion import num2deg
33
from passerelle.utils.jsonresponse import APIError
33 34
from passerelle.utils.templates import render_to_string, validate_template
34
from passerelle.base.models import BaseResource, HTTPResource, BaseQuery
35 35

  
36 36

  
37 37
class ArcGISError(APIError):
38 38
    pass
39 39

  
40 40

  
41 41
class ArcGIS(BaseResource, HTTPResource):
42 42
    category = _('Geographic information system')
passerelle/apps/arcgis/views.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.generic import UpdateView, CreateView, DeleteView
17
from django.views.generic import CreateView, DeleteView, UpdateView
18 18

  
19 19
from passerelle.base.mixins import ResourceChildViewMixin
20 20

  
21 21
from . import models
22 22
from .forms import QueryForm
23 23

  
24 24

  
25 25
class QueryNew(ResourceChildViewMixin, CreateView):
passerelle/apps/arpege_ecp/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import json
18 18

  
19
from requests import RequestException
20

  
21 19
from django.db import models
22
from django.utils import six
20
from django.utils import six, timezone
21
from django.utils.dateparse import parse_date, parse_time
23 22
from django.utils.six.moves.urllib import parse as urlparse
24 23
from django.utils.translation import ugettext_lazy as _
25
from django.utils.dateparse import parse_date, parse_time
26
from django.utils import timezone
24
from requests import RequestException
27 25

  
28 26
from passerelle.base.models import BaseResource
29 27
from passerelle.utils.api import endpoint
30 28
from passerelle.utils.http_authenticators import HawkAuth
31 29
from passerelle.utils.jsonresponse import APIError
32 30

  
33 31

  
34 32
class ArpegeECP(BaseResource):
passerelle/apps/astregs/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-06-19 10:24
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    initial = True
12 12

  
13 13
    dependencies = [
14 14
        ('base', '0012_job'),
passerelle/apps/astregs/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18
import zeep
19
from zeep.helpers import serialize_object
20 18

  
19
import zeep
21 20
from django.db import models
22
from django.utils.translation import ugettext_lazy as _
23
from django.utils.six.moves.urllib import parse as urlparse
24 21
from django.http import Http404
22
from django.utils.six.moves.urllib import parse as urlparse
23
from django.utils.translation import ugettext_lazy as _
24
from zeep.helpers import serialize_object
25 25

  
26 26
from passerelle.base.models import BaseResource
27 27
from passerelle.utils.api import endpoint
28 28
from passerelle.utils.jsonresponse import APIError
29 29
from passerelle.utils.validation import is_number
30 30

  
31 31
ASSOCIATION_SCHEMA = {
32 32
    "$schema": "http://json-schema.org/draft-04/schema#",
passerelle/apps/atal/models.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18 18
import binascii
19 19

  
20
import lxml.etree
20 21
from django.db import models
21 22
from django.utils import dateformat, dateparse
22 23
from django.utils.encoding import force_text
23 24
from django.utils.six.moves import urllib
24 25
from django.utils.translation import ugettext_lazy as _
25
import lxml.etree
26 26
from zeep import helpers
27 27
from zeep.exceptions import Fault
28 28

  
29 29
from passerelle.base.models import BaseResource
30 30
from passerelle.utils.api import endpoint
31 31
from passerelle.utils.jsonresponse import APIError
32
from . import schemas
33 32

  
33
from . import schemas
34 34

  
35 35
DATE_FORMAT = 'l d F Y, G:i'
36 36

  
37 37

  
38 38
def process_response(demande_number):
39 39
    if demande_number.startswith('DIT') or demande_number.startswith('DPR'):
40 40
        return {'data': {'demande_number': demande_number}}
41 41
    raise APIError(demande_number)
passerelle/apps/atos_genesys/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.10 on 2018-09-18 09:42
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8 8

  
9 9

  
10 10
class Migration(migrations.Migration):
11 11

  
12 12
    initial = True
13 13

  
14 14
    dependencies = [
15 15
        ('base', '0006_resourcestatus'),
passerelle/apps/atos_genesys/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18
import requests
19 18
import xml.etree.ElementTree as ET
20 19

  
20
import requests
21 21
from django.contrib.postgres.fields import JSONField
22 22
from django.db import models
23 23
from django.utils import six
24 24
from django.utils.six.moves.urllib import parse as urlparse
25 25
from django.utils.translation import ugettext_lazy as _
26 26

  
27
from passerelle.base.models import BaseResource, HTTPResource
27 28
from passerelle.utils import xml as xmlutils
28 29
from passerelle.utils.api import endpoint
29 30
from passerelle.utils.conversion import to_ascii
30 31
from passerelle.utils.jsonresponse import APIError
31 32
from passerelle.utils.validation import is_number
32
from passerelle.base.models import BaseResource, HTTPResource
33 33

  
34 34
from . import utils
35 35

  
36 36

  
37 37
class Resource(BaseResource, HTTPResource):
38 38
    category = _('Business Process Connectors')
39 39

  
40 40
    webservice_base_url = models.URLField(_('Webservice Base URL'))
passerelle/apps/atos_genesys/utils.py
1 1
import time
2 2
from contextlib import contextmanager
3 3

  
4
from django.db import transaction
5 4
from django.core.cache import cache
5
from django.db import transaction
6 6
from django.utils import six
7 7

  
8 8
from passerelle.utils.jsonresponse import APIError
9 9

  
10 10
DEFAULT_DURATION = 5 * 60  # 5 minutes
11 11

  
12 12
# keep data in cache for 1 day, i.e. we can answer a request from cache for 1 day
13 13
# day
passerelle/apps/base_adresse/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0002_auto_20150705_0330.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0003_baseaddresse_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0002_auto_20150705_0330'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0004_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0003_baseaddresse_log_level'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0005_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0004_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0008_delete_updatestreetmodel.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0007_auto_20160729_1540'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0009_streetmodel_simple_name.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0008_delete_updatestreetmodel'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0010_auto_20160914_0826.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0009_streetmodel_simple_name'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0011_auto_20160919_0949.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base_adresse', '0010_auto_20160914_0826'),
11 11
    ]
12 12

  
passerelle/apps/base_adresse/migrations/0015_auto_20191206_1244.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2019-12-06 11:44
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7

  
7 8
import passerelle.apps.base_adresse.models
8 9

  
9 10

  
10 11
class Migration(migrations.Migration):
11 12

  
12 13
    dependencies = [
13 14
        ('base_adresse', '0014_auto_20190207_0456'),
14 15
    ]
passerelle/apps/base_adresse/migrations/0016_auto_20200130_1604.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-01-30 15:04
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('base_adresse', '0015_auto_20191206_1244'),
13 13
    ]
14 14

  
passerelle/apps/base_adresse/models.py
1 1
import datetime
2 2
import gzip
3 3

  
4
from requests import RequestException
5
from requests.exceptions import ConnectionError
6

  
7 4
from django.contrib.postgres.fields import JSONField
8 5
from django.db import connection, models
9 6
from django.db.models import Q
7
from django.utils import six, timezone
10 8
from django.utils.http import urlencode
11
from django.utils.translation import ugettext_lazy as _
12
from django.utils import timezone
13
from django.utils import six
14 9
from django.utils.six import StringIO
15 10
from django.utils.six.moves.urllib import parse as urlparse
11
from django.utils.translation import ugettext_lazy as _
12
from requests import RequestException
13
from requests.exceptions import ConnectionError
16 14

  
17 15
from passerelle.base.models import BaseResource
18 16
from passerelle.compat import json_loads
19 17
from passerelle.utils.api import endpoint
20 18
from passerelle.utils.conversion import simplify
21 19
from passerelle.utils.jsonresponse import APIError
22 20

  
23 21

  
passerelle/apps/bdp/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/bdp/migrations/0002_bdp_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('bdp', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/bdp/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('bdp', '0002_bdp_log_level'),
11 11
    ]
12 12

  
passerelle/apps/bdp/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('bdp', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/bdp/models.py
1 1
import json
2
import requests
3
from requests.auth import HTTPBasicAuth
4 2

  
5
from django.urls import reverse
3
import requests
6 4
from django.db import models
5
from django.urls import reverse
7 6
from django.utils.translation import ugettext_lazy as _
7
from requests.auth import HTTPBasicAuth
8 8

  
9 9
from passerelle.base.models import BaseResource
10 10

  
11 11

  
12 12
class Bdp(BaseResource):
13 13
    service_url = models.CharField(
14 14
        max_length=128, blank=False, verbose_name=_('Service URL'), help_text=_('BDP Web Service URL')
15 15
    )
passerelle/apps/bdp/urls.py
1
from django.views.decorators.csrf import csrf_exempt
2 1
from django.conf.urls import url
3
from .views import BdpDetailView, ResourcesView, PostAdherentView
2
from django.views.decorators.csrf import csrf_exempt
3

  
4
from .views import BdpDetailView, PostAdherentView, ResourcesView
4 5

  
5 6
urlpatterns = [
6 7
    url(r'^(?P<slug>[\w,-]+)/$', BdpDetailView.as_view(), name='bdp-view'),
7 8
    url(r'^(?P<slug>[\w,-]+)/(?P<resources>[\w,-]+)/$', ResourcesView.as_view(), name='bdp-resources'),
8 9
    url(
9 10
        r'^(?P<slug>[\w,-]+)/post/adherent/$',
10 11
        csrf_exempt(PostAdherentView.as_view()),
11 12
        name='bdp-post-adherent',
passerelle/apps/bdp/views.py
1 1
from django.http import Http404
2 2
from django.views.generic.base import View
3
from django.views.generic.detail import SingleObjectMixin, DetailView
3
from django.views.generic.detail import DetailView, SingleObjectMixin
4 4

  
5
from passerelle.compat import json_loads
6 5
import passerelle.utils as utils
6
from passerelle.compat import json_loads
7 7

  
8 8
from .models import Bdp
9 9

  
10 10
# See documentation:
11 11
# https://dev.entrouvert.org/projects/bdp/wiki/WebServices
12 12

  
13 13

  
14 14
class ResourcesView(View, SingleObjectMixin):
passerelle/apps/cartads_cs/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2019-02-20 10:38
3 3
from __future__ import unicode_literals
4 4

  
5 5
from django.db import migrations, models
6

  
6 7
import passerelle.apps.cartads_cs.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    initial = True
12 13

  
13 14
    dependencies = [
passerelle/apps/cartads_cs/migrations/0002_cartadsdatacache.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2019-08-31 09:48
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('cartads_cs', '0001_initial'),
13 13
    ]
14 14

  
passerelle/apps/cartads_cs/migrations/0004_cartadsdossier_cartads_steps_cache.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2019-09-03 07:19
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('cartads_cs', '0003_cartadsdossier_name_id'),
13 13
    ]
14 14

  
passerelle/apps/cartads_cs/migrations/0011_cartadsdossier_cartads_cache_infos.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2019-09-30 15:42
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('cartads_cs', '0010_cartadsdossier_cartads_cache_code_acces'),
13 13
    ]
14 14

  
passerelle/apps/cartads_cs/models.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import base64
19 19
import datetime
20
from ftplib import FTP
21 20
import json
22 21
import os
23 22
import random
24 23
import re
25
from xml.etree import ElementTree as etree
26 24
import zipfile
25
from ftplib import FTP
26
from xml.etree import ElementTree as etree
27 27

  
28 28
import pdfrw
29 29
import pdfrw.findobjs
30

  
30
import zeep.exceptions
31
import zeep.helpers as zeep_helpers
31 32
from Crypto.Cipher import AES
32

  
33 33
from django.conf import settings
34 34
from django.contrib.postgres.fields import JSONField
35 35
from django.core.files.storage import default_storage
36 36
from django.core.signing import Signer
37
from django.urls import reverse
38 37
from django.db import models
39 38
from django.http import HttpResponse
39
from django.urls import reverse
40 40
from django.utils.encoding import force_text
41
from django.utils.six.moves.urllib import parse as urlparse
41 42
from django.utils.text import slugify
42 43
from django.utils.timezone import now
43 44
from django.utils.translation import ugettext_lazy as _
44
from django.utils.six.moves.urllib import parse as urlparse
45

  
46
import zeep.exceptions
47
import zeep.helpers as zeep_helpers
48 45

  
49 46
from passerelle.base.models import BaseResource
50 47
from passerelle.base.signature import sign_url
51 48
from passerelle.utils.api import endpoint
52 49
from passerelle.utils.jsonresponse import APIError, JSONEncoder
53 50

  
54 51

  
55 52
def cartads_file_location(instance, filename):
passerelle/apps/choosit/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/choosit/migrations/0002_auto_20160316_0528.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('choosit', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/choosit/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('choosit', '0002_auto_20160316_0528'),
11 11
    ]
12 12

  
passerelle/apps/choosit/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('choosit', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/choosit/migrations/0005_choositsmsgateway_default_trunk_prefix.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('choosit', '0004_auto_20160407_0456'),
11 11
    ]
12 12

  
passerelle/apps/choosit/models.py
1 1
# -*- coding: utf-8 -*-
2 2
import json
3
import requests
4 3

  
4
import requests
5 5
from django.db import models
6 6
from django.utils.six import string_types
7 7
from django.utils.translation import ugettext_lazy as _
8 8

  
9 9
from passerelle.sms.models import SMSResource
10 10
from passerelle.utils.jsonresponse import APIError
11 11

  
12 12

  
passerelle/apps/cityweb/cityweb.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18 18
import stat
19
from lxml import etree, objectify as xobject
20 19

  
21
from django.core.files.storage import default_storage
22 20
from django.core.files.base import ContentFile
21
from django.core.files.storage import default_storage
23 22
from django.utils import six
24 23
from django.utils.dateparse import parse_date
25 24
from django.utils.encoding import force_bytes
25
from lxml import etree
26
from lxml import objectify as xobject
26 27

  
27
from passerelle.utils.jsonresponse import APIError
28 28
from passerelle.utils.files import atomic_write
29

  
29
from passerelle.utils.jsonresponse import APIError
30 30

  
31 31
CERTIFICATE_TYPES = [
32 32
    {"id": "NAI", "text": "Naissance"},
33 33
    {"id": "MAR", "text": "Mariage"},
34 34
    {"id": "REC", "text": "Reconnaissance"},
35 35
    {"id": "DEC", "text": "Décès"},
36 36
]
37 37

  
passerelle/apps/cityweb/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18 18

  
19
from django.utils.translation import ugettext_lazy as _
20 19
from django.core.files.storage import default_storage
20
from django.utils.translation import ugettext_lazy as _
21 21

  
22 22
from passerelle.base.models import BaseResource
23 23
from passerelle.compat import json_loads
24 24
from passerelle.utils.api import endpoint
25 25
from passerelle.utils.jsonresponse import APIError
26 26

  
27 27
from .cityweb import (
28
    CivilStatusApplication,
29
    TITLES,
30
    SEXES,
31
    DOCUMENT_TYPES,
32 28
    CERTIFICATE_TYPES,
33 29
    CONCERNED,
30
    DOCUMENT_TYPES,
34 31
    ORIGINS,
32
    SEXES,
33
    TITLES,
34
    CivilStatusApplication,
35 35
)
36 36

  
37 37

  
38 38
class CityWeb(BaseResource):
39 39
    category = _('Civil Status Connectors')
40 40

  
41 41
    class Meta:
42 42
        verbose_name = u"CityWeb - Demande d'acte d'état civil"
passerelle/apps/clicrdv/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = []
10 10

  
11 11
    operations = []
passerelle/apps/clicrdv/models.py
2 2
Datasource for a ClicRDV instance.
3 3

  
4 4
It is a gateway to http://developers.clicrdv.com/fr/rest-api.html
5 5
'''
6 6

  
7 7
import base64
8 8
import datetime
9 9
import json
10
import requests
11 10

  
11
import requests
12 12
from django.conf import settings
13
from django.urls import reverse
14 13
from django.db import models
14
from django.urls import reverse
15 15
from django.utils.dateformat import format as date_format
16 16
from django.utils.dateformat import time_format
17
from django.utils.translation import ugettext_lazy as _
18 17
from django.utils.http import urlquote
18
from django.utils.translation import ugettext_lazy as _
19 19

  
20 20
from passerelle.base.models import BaseResource
21 21
from passerelle.utils.api import endpoint
22 22

  
23 23
CLICRDV_SERVERS = (
24 24
    ('www.clicrdv.com', 'Production (www.clicrdv.com)'),
25 25
    ('sandbox.clicrdv.com', 'SandBox (sandbox.clicrdv.com)'),
26 26
)
passerelle/apps/clicrdv/urls.py
1
from django.views.decorators.csrf import csrf_exempt
2 1
from django.conf.urls import include, url
3

  
4
from passerelle.urls_utils import decorated_includes, required, app_enabled
2
from django.views.decorators.csrf import csrf_exempt
5 3

  
6 4
from passerelle.apps.clicrdv.views import *
5
from passerelle.urls_utils import app_enabled, decorated_includes, required
7 6

  
8 7
urlpatterns = [
9 8
    url(r'^(?P<slug>[\w,-]+)/$', ClicRdvDetailView.as_view(), name='clicrdv-view'),
10 9
    url(
11 10
        r'^(?P<slug>[\w,-]+)/interventions/(?P<intervention_id>\d+)/datetimes/$',
12 11
        DateTimesView.as_view(),
13 12
        name='clicrdv-datetimes',
14 13
    ),
passerelle/apps/clicrdv/views.py
1 1
from django.views.generic.base import View
2
from django.views.generic.detail import SingleObjectMixin, DetailView
2
from django.views.generic.detail import DetailView, SingleObjectMixin
3 3

  
4
from passerelle.compat import json_loads
5 4
import passerelle.utils as utils
6

  
7 5
from passerelle.apps.clicrdv.models import ClicRdv
6
from passerelle.compat import json_loads
8 7

  
9 8

  
10 9
class ClicRdvDetailView(DetailView):
11 10
    model = ClicRdv
12 11

  
13 12

  
14 13
class DateTimesView(View, SingleObjectMixin):
15 14
    """list of free date&times in a intervention
passerelle/apps/cmis/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0005_resourcelog'),
11 11
    ]
12 12

  
passerelle/apps/cmis/models.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18 18
import binascii
19 19
import functools
20
import httplib2
21 20
import re
22 21

  
22
import httplib2
23 23
from cmislib import CmisClient
24
from cmislib.exceptions import CmisException
25
from cmislib.exceptions import ObjectNotFoundException
26
from cmislib.exceptions import PermissionDeniedException
27
from cmislib.exceptions import UpdateConflictException
28
from cmislib.exceptions import InvalidArgumentException
24
from cmislib.exceptions import (
25
    CmisException,
26
    InvalidArgumentException,
27
    ObjectNotFoundException,
28
    PermissionDeniedException,
29
    UpdateConflictException,
30
)
29 31
from django.db import models
30
from django.utils.translation import ugettext_lazy as _
31 32
from django.utils.six import BytesIO
32 33
from django.utils.six.moves.urllib import error as urllib2
34
from django.utils.translation import ugettext_lazy as _
33 35

  
34 36
from passerelle.base.models import BaseResource
35 37
from passerelle.utils.api import endpoint
36 38
from passerelle.utils.jsonresponse import APIError
37 39

  
38

  
39 40
SPECIAL_CHARS = '!#$%&+-^_`~;[]{}+=~'
40 41
FILE_PATH_PATTERN = r'^(/|(/[\w%s]+)+)$' % re.escape(SPECIAL_CHARS)
41 42
FILE_NAME_PATTERN = r'[\w%s\.]+$' % re.escape(SPECIAL_CHARS)
42 43

  
43 44

  
44 45
UPLOAD_SCHEMA = {
45 46
    'type': 'object',
46 47
    'properties': {
passerelle/apps/cmis/views.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from cmislib import CmisClient
18 18
from cmislib.exceptions import ObjectNotFoundException
19

  
20 19
from django.http import Http404
21 20
from django.utils.translation import ugettext_lazy as _
22 21
from django.views.generic import TemplateView
23 22

  
24 23
from .models import CmisConnector
25 24

  
26 25

  
27 26
class CmisTypeView(TemplateView):
passerelle/apps/cryptor/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-03-04 10:25
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
5
import uuid
6

  
6 7
import django.db.models.deletion
8
from django.db import migrations, models
9

  
7 10
import passerelle.apps.cryptor.models
8
import uuid
9 11

  
10 12

  
11 13
class Migration(migrations.Migration):
12 14

  
13 15
    initial = True
14 16

  
15 17
    dependencies = [
16 18
        ('base', '0016_auto_20191002_1443'),
passerelle/apps/cryptor/models.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18 18
import binascii
19 19
import json
20 20
import os
21 21
from uuid import uuid4
22 22

  
23
from Cryptodome.PublicKey import RSA
24
from Cryptodome.Random import get_random_bytes
25 23
from Cryptodome.Cipher import AES, PKCS1_OAEP
26 24
from Cryptodome.Hash import SHA512
27

  
25
from Cryptodome.PublicKey import RSA
26
from Cryptodome.Random import get_random_bytes
28 27
from django.core.exceptions import ValidationError
29 28
from django.core.files.storage import default_storage
30 29
from django.db import models
31 30
from django.http import HttpResponse
32 31
from django.utils.six.moves.urllib_parse import urljoin
33 32
from django.utils.translation import ugettext_lazy as _
34 33

  
35 34
from passerelle.base.models import BaseResource
36 35
from passerelle.utils.api import endpoint
37 36
from passerelle.utils.files import atomic_write
38 37
from passerelle.utils.jsonresponse import APIError
39 38

  
40

  
41 39
FILE_SCHEMA = {
42 40
    "$schema": "http://json-schema.org/draft-04/schema#",
43 41
    "title": "File to encrypt",
44 42
    "description": "",
45 43
    "type": "object",
46 44
    "required": ["file"],
47 45
    "properties": {
48 46
        "file": {
passerelle/apps/csvdatasource/management/commands/change-csv.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import os
18 17
import argparse
18
import os
19 19

  
20 20
from django.core.files import File
21 21
from django.core.management.base import BaseCommand, CommandError
22 22

  
23 23
from passerelle.apps.csvdatasource.models import CsvDataSource
24 24

  
25 25

  
26 26
class Command(BaseCommand):
passerelle/apps/csvdatasource/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/csvdatasource/migrations/0002_csvdatasource_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('csvdatasource', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/csvdatasource/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('csvdatasource', '0002_csvdatasource_log_level'),
11 11
    ]
12 12

  
passerelle/apps/csvdatasource/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('csvdatasource', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/csvdatasource/migrations/0005_csvdatasource__dialect_options.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('csvdatasource', '0004_auto_20160407_0456'),
12 12
    ]
13 13

  
passerelle/apps/csvdatasource/migrations/0006_auto_20160905_1031.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('csvdatasource', '0005_csvdatasource__dialect_options'),
12 12
    ]
13 13

  
passerelle/apps/csvdatasource/migrations/0009_auto_20161109_0353.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('csvdatasource', '0008_auto_20161025_1156'),
11 11
    ]
12 12

  
passerelle/apps/csvdatasource/migrations/0011_auto_20180905_0936.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2018-09-05 14:36
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8 8

  
9 9

  
10 10
class Migration(migrations.Migration):
11 11

  
12 12
    dependencies = [
13 13
        ('csvdatasource', '0010_auto_20170920_0951'),
14 14
    ]
15 15

  
passerelle/apps/csvdatasource/migrations/0016_auto_20200406_1702.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-04-06 15:02
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('csvdatasource', '0015_query_slug_unicity'),
13 13
    ]
14 14

  
passerelle/apps/csvdatasource/migrations/0019_csv_upload_to.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4 4
from django.db import migrations, models
5

  
5 6
import passerelle.apps.csvdatasource.models
6 7

  
7 8

  
8 9
class Migration(migrations.Migration):
9 10

  
10 11
    dependencies = [
11 12
        ('csvdatasource', '0018_text_to_jsonb'),
12 13
    ]
passerelle/apps/csvdatasource/migrations/0020_csv_upload_to.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3

  
3 4
import os
4 5

  
5 6
from django.db import migrations
6 7

  
7 8

  
8 9
def move_files(apps, schema_editor):
9 10
    CsvDataSource = apps.get_model('csvdatasource', 'CsvDataSource')
10 11
    CsvDataSource.get_connector_slug = lambda *args, **kwargs: 'csvdatasource'
passerelle/apps/csvdatasource/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import csv
17 18
import datetime
18 19
import os
19 20
import re
20
import csv
21
from collections import OrderedDict
22 21
import tempfile
22
from collections import OrderedDict
23 23

  
24
import six
25 24
import pytz
26

  
27
from pyexcel_ods import get_data as get_data_ods
28
from pyexcel_xls import get_data as get_data_xls
29

  
30
from django.contrib.postgres.fields import JSONField
31
from django.utils.encoding import force_str, smart_text, force_text
32
from django.utils.timezone import make_aware
25
import six
33 26
from django.conf import settings
34
from django.db import models, transaction
27
from django.contrib.postgres.fields import JSONField
35 28
from django.core.exceptions import ValidationError
29
from django.db import models, transaction
36 30
from django.urls import reverse
37
from django.utils.timezone import now
31
from django.utils.encoding import force_str, force_text, smart_text
32
from django.utils.timezone import make_aware, now
38 33
from django.utils.translation import ugettext_lazy as _
34
from pyexcel_ods import get_data as get_data_ods
35
from pyexcel_xls import get_data as get_data_xls
39 36

  
40 37
from passerelle.base.models import BaseResource
41 38
from passerelle.utils import batch
42
from passerelle.utils.jsonresponse import APIError
43 39
from passerelle.utils.api import endpoint
44 40
from passerelle.utils.conversion import normalize
41
from passerelle.utils.jsonresponse import APIError
45 42

  
46 43
identifier_re = re.compile(r"^[^\d\W]\w*\Z", re.UNICODE)
47 44

  
48 45

  
49 46
code_cache = OrderedDict()
50 47

  
51 48

  
52 49
def get_code(expr):
passerelle/apps/csvdatasource/views.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18 18

  
19 19
from django.http import HttpResponse
20 20
from django.shortcuts import get_object_or_404
21
from django.views.generic import View, UpdateView, CreateView, DeleteView
21
from django.views.generic import CreateView, DeleteView, UpdateView, View
22 22

  
23 23
from .forms import QueryForm
24 24
from .models import CsvDataSource, Query
25 25

  
26 26

  
27 27
class NewQueryView(CreateView):
28 28
    model = Query
29 29
    form_class = QueryForm
passerelle/apps/esirius/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-03-01 14:52
3 3
from __future__ import unicode_literals
4 4

  
5 5
from django.db import migrations, models
6

  
6 7
import passerelle.apps.esirius.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    initial = True
12 13

  
13 14
    dependencies = [
passerelle/apps/esirius/models.py
17 17

  
18 18
import base64
19 19
from copy import deepcopy
20 20
from time import time
21 21
from urllib.parse import urljoin
22 22

  
23 23
from Cryptodome.Cipher import DES
24 24
from Cryptodome.Util.Padding import pad
25

  
26
from django.db import models
27 25
from django.core.exceptions import ValidationError
26
from django.db import models
28 27
from django.utils.encoding import force_bytes
29 28
from django.utils.translation import ugettext_lazy as _
30 29

  
31 30
from passerelle.base.models import BaseResource, HTTPResource
32 31
from passerelle.utils.api import endpoint
33 32
from passerelle.utils.jsonresponse import APIError
34 33

  
35

  
36 34
CREATE_APPOINTMENT_SCHEMA = {
37 35
    '$schema': 'http://json-schema.org/draft-04/schema#',
38 36
    "type": "object",
39 37
    'properties': {
40 38
        'idSys': {'type': 'string', 'pattern': '^[0-9]*$'},
41 39
        'codeRDV': {'type': 'string'},
42 40
        'beginDate': {'type': 'string', 'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'},
43 41
        'beginTime': {'type': 'string', 'pattern': '^[0-9]{2}:[0-9]{2}$'},
passerelle/apps/family/loaders/concerto_fondettes.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import csv
18 18
import datetime
19
from decimal import Decimal
20 19
import json
21 20
import os
22 21
import sys
23 22
import zipfile
23
from decimal import Decimal
24 24

  
25 25
from django.core.exceptions import ValidationError
26
from django.utils.encoding import force_text
27 26
from django.utils import six
27
from django.utils.encoding import force_text
28 28
from django.utils.translation import ugettext_lazy as _
29 29

  
30 30
from ..models import Invoice
31 31

  
32 32

  
33 33
def u(s):
34 34
    return force_text(s, 'iso-8859-15')
35 35

  
passerelle/apps/family/loaders/concerto_orleans.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import os
18 17
import csv
18
import os
19 19
from decimal import Decimal
20 20

  
21
from django.utils.timezone import make_aware, datetime
21
from django.core.exceptions import ValidationError
22
from django.core.files.storage import DefaultStorage
22 23
from django.utils import six, timezone
23 24
from django.utils.encoding import force_text
24
from django.core.exceptions import ValidationError
25
from django.utils.timezone import datetime, make_aware
25 26
from django.utils.translation import ugettext_lazy as _
26
from django.core.files.storage import DefaultStorage
27 27

  
28
from ..models import Family, Adult, Child, Invoice
29
from ..models import dict_cherry_pick, get_datetime, get_date
28
from ..models import Adult, Child, Family, Invoice, dict_cherry_pick, get_date, get_datetime
30 29

  
31 30

  
32 31
def normalize_adult(adult):
33 32
    sex = adult['typ_sexe']
34 33
    if sex == 'G':
35 34
        sex = 'M'
36 35
    return {
37 36
        'external_id': adult['id_per'],
passerelle/apps/family/loaders/opus_fondettes.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import csv
18 18
import datetime
19
from decimal import Decimal
20 19
import json
21 20
import os
22 21
import sys
23 22
import zipfile
23
from decimal import Decimal
24 24

  
25 25
from django.core.exceptions import ValidationError
26
from django.utils.encoding import force_text
27 26
from django.utils import six
27
from django.utils.encoding import force_text
28 28
from django.utils.translation import ugettext_lazy as _
29 29

  
30 30
from ..models import Invoice
31 31

  
32 32

  
33 33
def u(s):
34 34
    return force_text(s, 'iso-8859-15')
35 35

  
passerelle/apps/family/management/commands/import_orleans_data.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import fcntl
17 18
import os
18 19
import sys
19
import zipfile
20 20
import tempfile
21
import fcntl
21
import zipfile
22 22

  
23 23
from django.core.files.base import File
24
from django.core.management.base import BaseCommand, CommandError
25 24
from django.core.files.storage import DefaultStorage
25
from django.core.management.base import BaseCommand, CommandError
26 26

  
27 27
from passerelle.apps.family.models import GenericFamily, Invoice
28 28

  
29 29

  
30 30
class Command(BaseCommand):
31 31
    def add_arguments(self, parser):
32 32
        parser.add_argument(
33 33
            '-a',
passerelle/apps/family/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/apps/family/migrations/0007_auto_20161122_1816.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
5 4
import datetime
5

  
6
from django.db import migrations, models
6 7
from django.utils.timezone import utc
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('family', '0006_invoice_no_online_payment_reason'),
13 14
    ]
passerelle/apps/family/models.py
11 11
# This program is distributed in the hope that it will be useful,
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19
from datetime import date
20 19
import os
21 20
import sys
22 21
import zipfile
23

  
24
import pytz
25

  
26 22
from collections import defaultdict
23
from datetime import date
27 24

  
25
import pytz
28 26
from django.core.exceptions import ValidationError
29 27
from django.core.files.storage import default_storage
28
from django.db import models, transaction
29
from django.http import Http404, HttpResponse
30 30
from django.utils import six
31
from django.utils.timezone import datetime, is_naive, make_aware, now
31 32
from django.utils.translation import ugettext_lazy as _
32
from django.http import Http404, HttpResponse
33
from django.db import models, transaction
34
from django.utils.timezone import make_aware, datetime, now, is_naive
35 33

  
36 34
from passerelle.base.models import BaseResource
37 35
from passerelle.compat import json_loads
38 36
from passerelle.utils.api import endpoint
39 37

  
40 38
SEXES = (
41 39
    ('M', _('Male')),
42 40
    ('F', _('Female')),
passerelle/apps/feeds/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import feedparser
18

  
19 18
from django.db import models
20 19
from django.utils.translation import ugettext_lazy as _
21 20

  
22 21
from passerelle.base.models import BaseResource
23 22
from passerelle.utils.api import endpoint
24 23

  
25 24

  
26 25
class Feed(BaseResource):
passerelle/apps/gdc/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/gdc/migrations/0002_gdc_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('gdc', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/gdc/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('gdc', '0002_gdc_log_level'),
11 11
    ]
12 12

  
passerelle/apps/gdc/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('gdc', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/gdc/urls.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.decorators.csrf import csrf_exempt
18 17
from django.conf.urls import url
19
from .views import GdcDetailView, VoiesView, PostDemandeView, StatusView
18
from django.views.decorators.csrf import csrf_exempt
19

  
20
from .views import GdcDetailView, PostDemandeView, StatusView, VoiesView
20 21

  
21 22
urlpatterns = [
22 23
    url(r'^(?P<slug>[\w,-]+)/$', GdcDetailView.as_view(), name='gdc-view'),
23 24
    url(r'^(?P<slug>[\w,-]+)/voies/(?P<insee>\d+)$', VoiesView.as_view(), name='gdc-voies'),
24 25
    url(r'^(?P<slug>[\w,-]+)/post/demande$', csrf_exempt(PostDemandeView.as_view()), name='gdc-post'),
25 26
    url(r'^(?P<slug>[\w,-]+)/status/(?P<ref>\d+)', StatusView.as_view(), name='gdc-status'),
26 27
]
passerelle/apps/gdc/views.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17

  
18 18
from django.utils.encoding import force_text
19 19
from django.views.generic.base import View
20
from django.views.generic.detail import SingleObjectMixin, DetailView
20
from django.views.generic.detail import DetailView, SingleObjectMixin
21 21

  
22
from passerelle.compat import json_loads
23 22
import passerelle.utils as utils
23
from passerelle.compat import json_loads
24 24
from passerelle.utils.conversion import normalize
25 25

  
26 26
from .models import Gdc, phpserialize, phpserialize_loads
27 27

  
28 28

  
29 29
class GdcCrash(Exception):
30 30
    pass
31 31

  
passerelle/apps/gesbac/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-09-19 15:23
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8

  
8 9
import passerelle.utils.sftp
9 10

  
10 11

  
11 12
class Migration(migrations.Migration):
12 13

  
13 14
    initial = True
14 15

  
15 16
    dependencies = [
passerelle/apps/gesbac/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import csv
18 18
import io
19

  
20 19
from collections import OrderedDict
21 20

  
22 21
from django.contrib.postgres.fields import JSONField
23
from django.db import models, transaction, IntegrityError
22
from django.db import IntegrityError, models, transaction
23
from django.http import Http404
24 24
from django.utils import six
25 25
from django.utils.encoding import force_bytes
26 26
from django.utils.translation import ugettext_lazy as _
27
from django.http import Http404
28 27

  
29 28
from passerelle.base.models import BaseResource
30
from passerelle.utils.api import endpoint, APIError
31 29
from passerelle.utils import SFTPField
32

  
30
from passerelle.utils.api import APIError, endpoint
33 31

  
34 32
CSV_DELIMITER = ';'
35 33
FILES_ENCODING = 'latin-1'
36 34

  
37 35
APPLICANT_SCHEMA = OrderedDict(
38 36
    (
39 37
        (
40 38
            "form_id",
passerelle/apps/jsondatastore/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
import django.contrib.postgres.fields.jsonb
4 5
from django.db import migrations, models
6

  
5 7
import passerelle.apps.jsondatastore.models
6
import django.contrib.postgres.fields.jsonb
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('base', '0005_resourcelog'),
13 14
    ]
14 15

  
passerelle/apps/jsondatastore/models.py
18 18

  
19 19
from django.contrib.postgres.fields import JSONField
20 20
from django.db import models
21 21
from django.template import Context, Template
22 22
from django.utils.translation import ugettext_lazy as _
23 23

  
24 24
from passerelle.base.models import BaseResource
25 25
from passerelle.compat import json_loads
26
from passerelle.utils.api import endpoint, APIError
26
from passerelle.utils.api import APIError, endpoint
27 27
from passerelle.utils.conversion import simplify
28 28

  
29 29

  
30 30
def get_hex_uuid():
31 31
    return uuid.uuid4().hex
32 32

  
33 33

  
34 34
def clean_json_data(data):
passerelle/apps/maelis/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.29 on 2020-09-29 13:56
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    initial = True
12 12

  
13 13
    dependencies = [
14 14
        ('base', '0022_auto_20200715_1033'),
passerelle/apps/maelis/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17

  
18 18
from collections import defaultdict
19

  
20 19
from urllib.parse import urljoin
21 20

  
22 21
import zeep
23
from zeep.wsse.username import UsernameToken
24
from zeep.helpers import serialize_object
25

  
26 22
from django.db import models
27
from django.utils.dateparse import parse_date
28 23
from django.utils import timezone
24
from django.utils.dateparse import parse_date
29 25
from django.utils.translation import ugettext_lazy as _
26
from zeep.helpers import serialize_object
27
from zeep.wsse.username import UsernameToken
30 28

  
31 29
from passerelle.base.models import BaseResource
32 30
from passerelle.utils.api import endpoint
33 31
from passerelle.utils.jsonresponse import APIError
34 32

  
35 33
from . import utils
36 34

  
37

  
38 35
LINK_SCHEMA = {
39 36
    "$schema": "http://json-schema.org/draft-04/schema#",
40 37
    "title": "Maelis",
41 38
    "description": "",
42 39
    "type": "object",
43 40
    "required": ["family_id", "password"],
44 41
    "properties": {
45 42
        "family_id": {
passerelle/apps/maelis/utils.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20
import re
20 21
from copy import copy, deepcopy
21 22
from datetime import datetime
22
from dateutil.relativedelta import relativedelta
23
import re
24 23

  
24
from dateutil.relativedelta import relativedelta
25 25
from django.utils import timezone
26 26
from django.utils.dateparse import parse_date
27 27

  
28 28
from passerelle.utils.jsonresponse import APIError
29 29

  
30 30
DATE_FORMAT = '%Y-%m-%d'
31 31
TIME_FORMAT = '%H:%M:%S'
32 32
DATETIME_FORMAT = DATE_FORMAT + ' ' + TIME_FORMAT
passerelle/apps/mdel/mdel.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import os
18 17
import base64
19 18
import datetime
20
from xml.etree import ElementTree as etree
19
import os
21 20
from xml.dom import minidom
21
from xml.etree import ElementTree as etree
22 22

  
23 23
from dateutil.parser import parse as dateutil_parse
24

  
25
from django.core.files.storage import default_storage
26 24
from django.core.files.base import ContentFile
25
from django.core.files.storage import default_storage
27 26

  
28 27
from passerelle.apps.mdel.utils import ElementFactory
29 28
from passerelle.utils.jsonresponse import APIError
30 29

  
31 30

  
32 31
def get_resource_base_dir():
33 32
    return default_storage.path('mdel')
34 33

  
passerelle/apps/mdel/migrations/0003_auto_20170125_0450.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import datetime
5

  
6
from django.db import migrations, models
6 7
from django.utils.timezone import utc
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('mdel', '0002_auto_20170123_0311'),
13 14
    ]
passerelle/apps/mdel/migrations/0006_auto_20210126_1440.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.29 on 2021-01-26 13:40
3 3
from __future__ import unicode_literals
4 4

  
5 5
from django.db import migrations
6

  
6 7
import passerelle.utils.sftp
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('mdel', '0005_remove_mdel_log_level'),
13 14
    ]
passerelle/apps/mdel/models.py
18 18
import os
19 19

  
20 20
from django.db import models
21 21
from django.utils import six
22 22
from django.utils.translation import ugettext_lazy as _
23 23

  
24 24
from passerelle.base.models import BaseResource
25 25
from passerelle.compat import json_loads
26
from passerelle.utils import SFTPField
26 27
from passerelle.utils.api import endpoint
27 28
from passerelle.utils.files import atomic_write
28 29
from passerelle.utils.jsonresponse import APIError
29
from passerelle.utils import SFTPField
30 30

  
31 31
from . import mdel
32

  
33
from .utils import zipdir, get_file_content_from_zip, parse_date
34

  
32
from .utils import get_file_content_from_zip, parse_date, zipdir
35 33

  
36 34
DEMAND_TYPES = ['ILE-LA', 'RCO-LA', 'AEC-LA']
37 35

  
38 36
STATUS_MAPPING = {
39 37
    '100': 'closed',
40 38
    '20': 'rejected',
41 39
    '19': 'accepted',
42 40
    '17': 'information needed',
passerelle/apps/mdel_ddpacs/abstract.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20
from collections import namedtuple
21 20
import inspect
22 21
import os
23 22
import re
24 23
import xml.etree.ElementTree as ET
25 24
import zipfile
25
from collections import namedtuple
26 26

  
27 27
from django.contrib.postgres.fields import JSONField
28
from django.db import models, IntegrityError, transaction
29
from django.urls import reverse
28
from django.db import IntegrityError, models, transaction
30 29
from django.http import HttpResponse
30
from django.urls import reverse
31
from django.utils import functional, six
31 32
from django.utils.translation import ugettext_lazy as _
32
from django.utils import six, functional
33 33

  
34 34
from passerelle.base.models import BaseResource, SkipJob
35
from passerelle.utils import sftp, xml
35 36
from passerelle.utils.api import endpoint
37
from passerelle.utils.conversion import exception_to_text
36 38
from passerelle.utils.jsonresponse import APIError
37 39
from passerelle.utils.zip import ZipTemplate
38
from passerelle.utils.conversion import exception_to_text
39

  
40
from passerelle.utils import xml, sftp
41 40

  
42 41
'''Base abstract models for implementing MDEL compatible requests.
43 42
'''
44 43

  
45 44
MDELStatus = namedtuple('MDELStatus', ['code', 'slug', 'label'])
46 45

  
47 46
MDEL_STATUSES = map(
48 47
    lambda t: MDELStatus(*t),
passerelle/apps/mdel_ddpacs/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-10-24 08:59
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8

  
8 9
import passerelle.utils.sftp
9 10

  
10 11

  
11 12
class Migration(migrations.Migration):
12 13

  
13 14
    initial = True
14 15

  
15 16
    dependencies = [
passerelle/apps/mdel_ddpacs/migrations/0002_auto_20200504_1402.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-05-04 12:02
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields.jsonb
6 6
from django.db import migrations, models
7

  
7 8
import passerelle.utils.sftp
8 9

  
9 10

  
10 11
class Migration(migrations.Migration):
11 12

  
12 13
    dependencies = [
13 14
        ('mdel_ddpacs', '0001_initial'),
14 15
    ]
passerelle/apps/mdel_ddpacs/models.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20
import xmlschema
20 21
from django.db import models
21
from django.utils.translation import ugettext_lazy as _
22 22
from django.utils import six
23
from django.utils.translation import ugettext_lazy as _
23 24

  
24 25
from passerelle.utils.api import endpoint
25 26
from passerelle.utils.xml import JSONSchemaFromXMLSchema
26 27

  
27
import xmlschema
28

  
29 28
from . import abstract
30 29

  
31 30

  
32 31
class DDPACSSchema(JSONSchemaFromXMLSchema):
33 32
    type_map = {
34 33
        'CiviliteType': 'civilite',
35 34
        '{http://www.w3.org/2001/XMLSchema}double': 'double',
36 35
    }
passerelle/apps/mobyt/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/mobyt/migrations/0002_mobytsmsgateway_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('mobyt', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/mobyt/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('mobyt', '0002_mobytsmsgateway_log_level'),
11 11
    ]
12 12

  
passerelle/apps/mobyt/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('mobyt', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/mobyt/migrations/0005_mobytsmsgateway_default_trunk_prefix.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('mobyt', '0004_auto_20160407_0456'),
11 11
    ]
12 12

  
passerelle/apps/mobyt/models.py
1
import requests
1 2
from django.db import models
2 3
from django.utils.translation import ugettext_lazy as _
3 4

  
4
import requests
5

  
6 5
from passerelle.sms.models import SMSResource
7 6
from passerelle.utils.jsonresponse import APIError
8 7

  
9 8

  
10 9
class MobytSMSGateway(SMSResource):
11 10
    URL = 'http://multilevel.mobyt.fr/sms/batch.php'
12 11
    MESSAGES_QUALITIES = (
13 12
        ('l', _('sms direct')),
passerelle/apps/opendatasoft/forms.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django import forms
18 18

  
19 19
from passerelle.base.forms import BaseQueryFormMixin
20

  
20 21
from . import models
21 22

  
22 23

  
23 24
class QueryForm(BaseQueryFormMixin, forms.ModelForm):
24 25
    class Meta:
25 26
        model = models.Query
26 27
        fields = '__all__'
27 28
        exclude = ['resource']
passerelle/apps/opendatasoft/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-05-15 17:28
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7

  
7 8
import passerelle.utils.templates
8 9

  
9 10

  
10 11
class Migration(migrations.Migration):
11 12

  
12 13
    initial = True
13 14

  
14 15
    dependencies = [
passerelle/apps/opendatasoft/models.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.db import models
18 18
from django.shortcuts import get_object_or_404
19 19
from django.urls import reverse
20 20
from django.utils.six.moves.urllib import parse as urlparse
21 21
from django.utils.translation import ugettext_lazy as _
22 22

  
23
from passerelle.utils.templates import render_to_string, validate_template
24
from passerelle.base.models import BaseResource, BaseQuery
23
from passerelle.base.models import BaseQuery, BaseResource
25 24
from passerelle.utils.api import endpoint
25
from passerelle.utils.templates import render_to_string, validate_template
26 26

  
27 27

  
28 28
class OpenDataSoft(BaseResource):
29 29
    service_url = models.CharField(
30 30
        _('Site URL'),
31 31
        max_length=256,
32 32
        blank=False,
33 33
        help_text=_('URL without ending "api/records/1.0/search/"'),
passerelle/apps/opendatasoft/views.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.generic import UpdateView, CreateView, DeleteView
17
from django.views.generic import CreateView, DeleteView, UpdateView
18 18

  
19 19
from passerelle.base.mixins import ResourceChildViewMixin
20 20

  
21 21
from . import models
22 22
from .forms import QueryForm
23 23

  
24 24

  
25 25
class QueryNew(ResourceChildViewMixin, CreateView):
passerelle/apps/opengis/forms.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from xml.etree import ElementTree as ET
18 18

  
19 19
from django import forms
20 20
from django.utils.translation import ugettext_lazy as _
21 21

  
22 22
from passerelle.base.forms import BaseQueryFormMixin
23

  
23 24
from . import models
24 25

  
25 26

  
26 27
class QueryForm(BaseQueryFormMixin, forms.ModelForm):
27 28
    class Meta:
28 29
        model = models.Query
29 30
        fields = '__all__'
30 31
        exclude = ['resource']
passerelle/apps/opengis/migrations/0005_auto_20180227_1531.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('opengis', '0004_auto_20180219_1613'),
12 12
    ]
13 13

  
passerelle/apps/opengis/migrations/0007_auto_20200401_1032.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-04-08 09:54
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('opengis', '0006_auto_20181118_0807'),
13 13
    ]
14 14

  
passerelle/apps/opengis/migrations/0008_featurecache.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-04-01 09:21
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8 8

  
9 9

  
10 10
class Migration(migrations.Migration):
11 11

  
12 12
    dependencies = [
13 13
        ('opengis', '0007_auto_20200401_1032'),
14 14
    ]
15 15

  
passerelle/apps/opengis/models.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import html
18 18
import math
19 19
import xml.etree.ElementTree as ET
20 20

  
21
import six
22

  
23 21
import pyproj
24

  
22
import six
25 23
from django.contrib.postgres.fields import JSONField
26 24
from django.core.cache import cache
27 25
from django.db import models, transaction
28 26
from django.http import HttpResponse
29 27
from django.shortcuts import get_object_or_404
30 28
from django.template import Context, Template
31 29
from django.urls import reverse
32 30
from django.utils import timezone
33 31
from django.utils.text import slugify
34 32
from django.utils.translation import ugettext_lazy as _
35 33

  
36
from passerelle.base.models import BaseResource, BaseQuery
34
from passerelle.base.models import BaseQuery, BaseResource
37 35
from passerelle.utils.api import endpoint
38 36
from passerelle.utils.conversion import num2deg, simplify
39 37
from passerelle.utils.jsonresponse import APIError
40 38

  
41 39

  
42 40
def build_dict_from_xml(elem):
43 41
    d = {}
44 42
    for child in elem.find('.'):
passerelle/apps/opengis/views.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.generic import UpdateView, CreateView, DeleteView
17
from django.views.generic import CreateView, DeleteView, UpdateView
18 18

  
19 19
from passerelle.base.mixins import ResourceChildViewMixin
20 20

  
21 21
from . import models
22 22
from .forms import QueryForm
23 23

  
24 24

  
25 25
class QueryNew(ResourceChildViewMixin, CreateView):
passerelle/apps/orange/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/apps/orange/migrations/0002_orangesmsgateway_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('orange', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/orange/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('orange', '0002_orangesmsgateway_log_level'),
11 11
    ]
12 12

  
passerelle/apps/orange/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('orange', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/orange/models.py
20 20
# You should have received a copy of the GNU Affero General Public License
21 21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
from django.db import models
23 23
from django.utils.translation import ugettext_lazy as _
24 24

  
25 25
from passerelle.sms.models import SMSResource
26 26
from passerelle.utils.jsonresponse import APIError
27 27

  
28

  
29 28
BASE_API = 'https://contact-everyone.orange-business.com/api/v1.2/'
30 29
URL_TOKEN = BASE_API + 'oauth/token'
31 30
URL_GROUPS = BASE_API + 'groups'
32 31
URL_DIFFUSION = BASE_API + 'groups/%s/diffusion-requests'
33 32

  
34 33

  
35 34
class OrangeError(APIError):
36 35
    pass
passerelle/apps/ovh/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/ovh/migrations/0002_ovhsmsgateway_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('ovh', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/ovh/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('ovh', '0002_ovhsmsgateway_log_level'),
11 11
    ]
12 12

  
passerelle/apps/ovh/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('ovh', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/ovh/migrations/0005_ovhsmsgateway_default_trunk_prefix.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('ovh', '0004_auto_20160407_0456'),
11 11
    ]
12 12

  
passerelle/apps/ovh/models.py
1 1
import hashlib
2 2
import json
3
import requests
4 3
import time
5 4
from datetime import timedelta
6 5
from urllib.parse import urljoin
7 6

  
8
from django.contrib.postgres.fields import ArrayField
7
import requests
9 8
from django.conf import settings
9
from django.contrib.postgres.fields import ArrayField
10 10
from django.core.mail import send_mail
11 11
from django.db import models
12 12
from django.template.loader import render_to_string
13 13
from django.utils import timezone
14 14
from django.utils.encoding import force_text
15 15
from django.utils.translation import ugettext_lazy as _
16 16

  
17 17
from passerelle.sms.models import SMSResource
passerelle/apps/oxyd/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/oxyd/migrations/0002_oxydsmsgateway_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('oxyd', '0001_initial'),
11 11
    ]
12 12

  
passerelle/apps/oxyd/migrations/0003_auto_20160316_0910.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('oxyd', '0002_oxydsmsgateway_log_level'),
11 11
    ]
12 12

  
passerelle/apps/oxyd/migrations/0004_auto_20160407_0456.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('oxyd', '0003_auto_20160316_0910'),
11 11
    ]
12 12

  
passerelle/apps/oxyd/migrations/0005_oxydsmsgateway_default_trunk_prefix.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('oxyd', '0004_auto_20160407_0456'),
11 11
    ]
12 12

  
passerelle/apps/oxyd/models.py
1 1
import requests
2

  
3 2
from django.db import models
4 3
from django.utils.encoding import force_text
5 4
from django.utils.translation import ugettext_lazy as _
6 5

  
7
from passerelle.utils.jsonresponse import APIError
8 6
from passerelle.sms.models import SMSResource
7
from passerelle.utils.jsonresponse import APIError
9 8

  
10 9

  
11 10
class OxydSMSGateway(SMSResource):
12 11
    username = models.CharField(verbose_name=_('Username'), max_length=64)
13 12
    password = models.CharField(verbose_name=_('Password'), max_length=64)
14 13

  
15 14
    TEST_DEFAULTS = {
16 15
        'create_kwargs': {
passerelle/apps/phonecalls/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.17 on 2019-01-21 14:14
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8 8

  
9 9

  
10 10
class Migration(migrations.Migration):
11 11

  
12 12
    initial = True
13 13

  
14 14
    dependencies = [
15 15
        ('base', '0010_loggingparameters_trace_emails'),
passerelle/apps/phonecalls/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.contrib.postgres.fields import JSONField
18 18
from django.db import models
19
from django.utils.http import urlencode
20
from django.utils.timezone import now, timedelta, make_naive
21
from django.utils.translation import ugettext_lazy as _
22 19
from django.http import HttpResponseRedirect
23 20
from django.shortcuts import render
21
from django.utils.http import urlencode
22
from django.utils.timezone import make_naive, now, timedelta
23
from django.utils.translation import ugettext_lazy as _
24 24

  
25 25
from passerelle.base.models import BaseResource
26 26
from passerelle.utils.api import endpoint
27 27

  
28 28

  
29 29
class PhoneCalls(BaseResource):
30 30
    category = _('Telephony')
31 31

  
passerelle/apps/photon/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18
from requests import RequestException
19 18

  
20 19
from django.contrib.postgres.fields import JSONField
21 20
from django.db import models
22
from django.utils.http import urlencode
23
from django.utils.translation import ugettext_lazy as _
24 21
from django.utils import timezone
22
from django.utils.http import urlencode
25 23
from django.utils.six.moves.urllib import parse as urlparse
24
from django.utils.translation import ugettext_lazy as _
25
from requests import RequestException
26 26

  
27 27
from passerelle.base.models import BaseResource
28 28
from passerelle.utils.api import endpoint
29 29
from passerelle.utils.jsonresponse import APIError
30 30

  
31 31

  
32 32
class AddressCacheModel(models.Model):
33 33
    api_id = models.CharField(max_length=32, unique=True)
passerelle/apps/solis/migrations/0003_auto_20171219_0800.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4 4
from django.db import migrations, models
5

  
5 6
import passerelle.apps.solis.models
6 7

  
7 8

  
8 9
class Migration(migrations.Migration):
9 10

  
10 11
    dependencies = [
11 12
        ('solis', '0002_solisapalink_text'),
12 13
    ]
passerelle/apps/solis/migrations/0006_solisrsalink.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-05-09 07:18
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('solis', '0005_remove_solis_log_level'),
13 13
    ]
14 14

  
passerelle/apps/solis/models.py
16 16

  
17 17
import base64
18 18
import copy
19 19
import re
20 20

  
21 21
from django.db import models
22 22
from django.template.loader import get_template
23 23
from django.utils.encoding import force_text
24
from django.utils.translation import ugettext_lazy as _
25 24
from django.utils.http import urlencode
25
from django.utils.translation import ugettext_lazy as _
26 26

  
27 27
from passerelle.base.models import BaseResource
28 28
from passerelle.compat import json_loads
29 29
from passerelle.utils.api import endpoint
30
from passerelle.utils.jsonresponse import APIError
31 30
from passerelle.utils.conversion import simplify, to_pdf
31
from passerelle.utils.jsonresponse import APIError
32 32

  
33 33

  
34 34
def unflat(flatten_dict, separator='_'):
35 35
    """
36 36
    Expand a "flatten" dict:
37 37
    >>> unflat({'foo': 'bar', 'two_foo': 'one', 'two_bar': 'two'})
38 38
    {'foo': 'bar', 'two': {'foo': 'one', 'bar': 'two'}}
39 39
    """
passerelle/apps/sp_fr/fields.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.core.exceptions import ValidationError
18
from django.template import engines, TemplateSyntaxError
19 17
from django import forms
18
from django.core.exceptions import ValidationError
19
from django.template import TemplateSyntaxError, engines
20 20

  
21 21

  
22 22
def validate_django_template(value):
23 23
    try:
24 24
        engines['django'].from_string(value)
25 25
    except TemplateSyntaxError as e:
26 26
        raise ValidationError('invalid template %s' % e)
27 27

  
passerelle/apps/sp_fr/forms.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django import forms
18 18

  
19
from . import models, fields
19
from . import fields, models
20 20

  
21 21

  
22 22
class MappingForm(forms.ModelForm):
23 23
    def __init__(self, *args, **kwargs):
24 24
        super(MappingForm, self).__init__(*args, **kwargs)
25 25
        if self.instance.procedure and self.instance and self.instance.formdef:
26 26
            choices = [('', '--------')] + [(v, v) for v in self.instance.variables]
27 27
            for i, field in enumerate(self.schema_fields()):
passerelle/apps/sp_fr/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-04-19 17:15
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8

  
8 9
import passerelle.apps.sp_fr.models
9 10
import passerelle.utils.sftp
10 11
import passerelle.utils.wcs
11 12

  
12 13

  
13 14
class Migration(migrations.Migration):
14 15

  
15 16
    initial = True
passerelle/apps/sp_fr/models.py
10 10
# This program is distributed in the hope that it will be useful,
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18
import re
18
import base64
19
import collections
20
import datetime
19 21
import os
22
import re
20 23
import stat
21 24
import zipfile
22
import collections
23
import base64
24
import datetime
25

  
26
from lxml import etree as ET
27 25

  
28 26
from django.contrib.postgres.fields import JSONField
29
from django.urls import reverse
30 27
from django.core.files import File
31 28
from django.db import models, transaction
32 29
from django.template import engines
30
from django.urls import reverse
33 31
from django.utils import six
34
from django.utils.translation import ugettext_lazy as _, ugettext
32
from django.utils.translation import ugettext
33
from django.utils.translation import ugettext_lazy as _
34
from lxml import etree as ET
35 35

  
36 36
from passerelle.base.models import BaseResource
37 37
from passerelle.utils.api import endpoint
38
from passerelle.utils.conversion import normalize
38 39
from passerelle.utils.sftp import SFTPField
39 40
from passerelle.utils.wcs import FormDefField, get_wcs_choices
40 41
from passerelle.utils.xml import text_content
41
from passerelle.utils.conversion import normalize
42 42

  
43 43
from .xsd import Schema
44 44

  
45 45
MAX_REQUESTS_PER_ITERATION = 200
46 46

  
47 47
PROCEDURE_DOC = 'DOC'
48 48
PROCEDURE_RCO = 'recensementCitoyen'
49 49
PROCEDURE_DDPACS = 'depotDossierPACS'
passerelle/apps/sp_fr/views.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.generic import UpdateView, CreateView, DeleteView
18
from django.shortcuts import get_object_or_404
19 17
from django.http import HttpResponseRedirect
18
from django.shortcuts import get_object_or_404
19
from django.views.generic import CreateView, DeleteView, UpdateView
20 20

  
21 21
from passerelle.base.mixins import ResourceChildViewMixin
22 22

  
23
from . import models, forms
23
from . import forms, models
24 24

  
25 25

  
26 26
class StayIfChanged(object):
27 27
    has_changed = False
28 28

  
29 29
    def form_valid(self, form):
30 30
        if set(form.changed_data) & set(['procedure', 'formdef']):
31 31
            self.has_changed = True
passerelle/apps/sp_fr/xsd.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18 18

  
19
from django.utils import six
20

  
21 19
import isodate
20
from django.utils import six
22 21
from lxml import etree as ET
23 22
from zeep.utils import qname_attr
24 23

  
25 24

  
26 25
def parse_bool(boolean):
27 26
    return boolean.lower() == 'true'
28 27

  
29 28

  
passerelle/apps/twilio/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
import requests
17
from requests.auth import HTTPBasicAuth
18

  
19 17
from django.db import models
20 18
from django.utils.translation import ugettext_lazy as _
19
from requests.auth import HTTPBasicAuth
21 20

  
22
from passerelle.utils.jsonresponse import APIError
23 21
from passerelle.sms.models import SMSResource
22
from passerelle.utils.jsonresponse import APIError
24 23

  
25 24

  
26 25
class TwilioSMSGateway(SMSResource):
27 26
    hide_description_fields = ['account_sid']
28 27

  
29 28
    account_sid = models.CharField(verbose_name=_('Account Sid'), max_length=64)
30 29
    auth_token = models.CharField(verbose_name=_('Auth Token'), max_length=64)
31 30

  
passerelle/base/admin.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.contrib import admin
18
from django.urls import reverse
19 18
from django.shortcuts import redirect
19
from django.urls import reverse
20 20
from django.urls.exceptions import NoReverseMatch
21 21
from django.views.decorators.cache import never_cache
22 22

  
23
from .models import ApiUser, AccessRight
23
from .models import AccessRight, ApiUser
24 24

  
25 25

  
26 26
@never_cache
27 27
def login(request, *args, **kwargs):
28 28
    try:
29 29
        auth_login_url = reverse('auth_login')
30 30
    except NoReverseMatch:
31 31
        return admin.site.orig_login(request, *args, **kwargs)
passerelle/base/forms.py
1 1
from django import forms
2 2
from django.utils.translation import ugettext_lazy as _
3 3

  
4
from .models import ApiUser, AccessRight, AvailabilityParameters
4
from .models import AccessRight, ApiUser, AvailabilityParameters
5 5

  
6 6

  
7 7
class ApiUserForm(forms.ModelForm):
8 8
    class Meta:
9 9
        model = ApiUser
10 10
        exclude = []
11 11

  
12 12

  
passerelle/base/management/commands/cron.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from __future__ import print_function
18

  
18 19
import traceback
19 20

  
20
from django.core.management.base import BaseCommand, CommandError
21 21
from django.conf import settings
22
from django.core.management.base import BaseCommand, CommandError
22 23

  
23 24
from passerelle.views import get_all_apps
24 25

  
25 26

  
26 27
class Command(BaseCommand):
27 28
    help = 'Execute scheduled commands'
28 29

  
29 30
    def add_arguments(self, parser):
passerelle/base/management/commands/ensure_jsonb.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.apps import apps
18
from django.core.management.base import BaseCommand, CommandError
19 18
from django.contrib.postgres.fields import JSONField
19
from django.core.management.base import BaseCommand, CommandError
20 20
from django.db import connection
21 21

  
22 22

  
23 23
class Command(BaseCommand):
24 24
    help = 'Ensure all JSON fields are of type jsonb'
25 25

  
26 26
    def handle(self, **options):
27 27
        for app in apps.get_models():
passerelle/base/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('contenttypes', '0001_initial'),
11 11
    ]
12 12

  
passerelle/base/migrations/0002_auto_20151009_0326.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/base/migrations/0003_auto_20170116_1656.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/base/migrations/0004_auto_20170117_0326.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0003_auto_20170116_1656'),
11 11
    ]
12 12

  
passerelle/base/migrations/0005_resourcelog.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('base', '0004_auto_20170117_0326'),
12 12
    ]
13 13

  
passerelle/base/migrations/0007_loggingparameters.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2018-11-18 13:16
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('contenttypes', '0002_remove_content_type_name'),
13 13
        ('base', '0006_resourcestatus'),
14 14
    ]
passerelle/base/migrations/0011_auto_20190205_1126.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.17 on 2019-02-05 10:26
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('contenttypes', '0002_remove_content_type_name'),
13 13
        ('base', '0010_loggingparameters_trace_emails'),
14 14
    ]
passerelle/base/migrations/0012_job.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.12 on 2019-02-20 09:00
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7 5
import django.contrib.postgres.fields.jsonb
6
import django.db.models.deletion
7
from django.db import migrations, models
8 8

  
9 9

  
10 10
class Migration(migrations.Migration):
11 11

  
12 12
    dependencies = [
13 13
        ('contenttypes', '0002_remove_content_type_name'),
14 14
        ('base', '0011_auto_20190205_1126'),
15 15
    ]
passerelle/base/migrations/0014_auto_20190820_0914.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-08-20 14:14
3 3
from __future__ import unicode_literals
4 4

  
5 5
from django.db import migrations, models
6

  
6 7
import passerelle.base.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('base', '0013_delete_templatevar'),
13 14
    ]
passerelle/base/migrations/0015_auto_20190921_0347.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.20 on 2019-09-21 08:47
3 3
from __future__ import unicode_literals
4 4

  
5 5
from django.db import migrations, models
6

  
6 7
import passerelle.base.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('base', '0014_auto_20190820_0914'),
13 14
    ]
passerelle/base/migrations/0017_auto_20200310_1806.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2020-03-10 17:06
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations, models
7

  
7 8
import passerelle.base.models
8 9

  
9 10

  
10 11
class Migration(migrations.Migration):
11 12

  
12 13
    dependencies = [
13 14
        ('base', '0016_auto_20191002_1443'),
14 15
    ]
passerelle/base/models.py
1
import base64
1 2
import collections
2 3
import copy
3 4
import datetime
4 5
import inspect
6
import itertools
5 7
import logging
6 8
import os
7 9
import re
8 10
import sys
9 11
import traceback
10
import base64
11
import itertools
12 12
import uuid
13 13

  
14 14
from django import VERSION
15 15
from django.apps import apps
16 16
from django.conf import settings
17
from django.contrib.postgres.fields import JSONField, ArrayField
18
from django.core.exceptions import ValidationError, PermissionDenied
19
from django.urls import reverse
17
from django.contrib.contenttypes import fields
18
from django.contrib.contenttypes.models import ContentType
19
from django.contrib.postgres.fields import ArrayField, JSONField
20
from django.core.exceptions import PermissionDenied, ValidationError
21
from django.core.files.base import ContentFile
20 22
from django.db import connection, models, transaction
21 23
from django.db.models import Q
22 24
from django.forms.models import modelform_factory
23 25
from django.forms.widgets import ClearableFileInput
24 26
from django.test import override_settings
25
from django.utils.text import slugify
26
from django.utils import timezone, six
27
from django.urls import reverse
28
from django.utils import six, timezone
27 29
from django.utils.encoding import force_text
28 30
from django.utils.six.moves.urllib.parse import urlparse
29
from django.utils.translation import ugettext_lazy as _
31
from django.utils.text import slugify
30 32
from django.utils.timezone import now
31
from django.core.files.base import ContentFile
32

  
33
from django.contrib.contenttypes.models import ContentType
34
from django.contrib.contenttypes import fields
35

  
33
from django.utils.translation import ugettext_lazy as _
36 34
from model_utils.managers import InheritanceManager as ModelUtilsInheritanceManager
37 35

  
38 36
import passerelle
39 37
from passerelle.forms import GenericConnectorForm
40 38
from passerelle.utils.api import endpoint
41 39
from passerelle.utils.jsonresponse import APIError
42
from passerelle.utils.sftp import SFTPField, SFTP
40
from passerelle.utils.sftp import SFTP, SFTPField
43 41

  
44 42
KEYTYPE_CHOICES = (
45 43
    ('API', _('API Key')),
46 44
    ('SIGN', _('HMAC Signature')),
47 45
)
48 46

  
49 47
LOGLEVEL_CHOICES = (
50 48
    ('DEBUG', _('Debug')),
passerelle/base/signature.py
1
import datetime
2 1
import base64
3
import hmac
2
import datetime
4 3
import hashlib
4
import hmac
5 5
import random
6 6

  
7 7
from django.utils import six
8 8
from django.utils.encoding import smart_bytes
9 9
from django.utils.http import quote, urlencode
10 10
from django.utils.six.moves.urllib import parse as urlparse
11 11

  
12

  
13 12
'''Simple signature scheme for query strings'''
14 13
# from http://git.entrouvert.org/hobo.git/tree/hobo/signature.py
15 14

  
16 15

  
17 16
def sign_url(url, key, algo='sha256', timestamp=None, nonce=None):
18 17
    parsed = urlparse.urlparse(url)
19 18
    new_query = sign_query(parsed.query, key, algo, timestamp, nonce)
20 19
    return urlparse.urlunparse(parsed[:4] + (new_query,) + parsed[5:])
passerelle/base/templatetags/passerelle.py
17 17

  
18 18
from __future__ import absolute_import, unicode_literals
19 19

  
20 20
import collections
21 21
import json
22 22
import re
23 23

  
24 24
from django import template
25
from django.utils.html import mark_safe, format_html
26
from django.utils.translation import ugettext as _
27
from django.contrib.contenttypes.models import ContentType
28 25
from django.contrib.auth import get_permission_codename
29
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
26
from django.contrib.contenttypes.models import ContentType
27
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
30 28
from django.template.defaultfilters import stringfilter
29
from django.utils.html import format_html, mark_safe
30
from django.utils.translation import ugettext as _
31 31

  
32 32
from passerelle.utils import get_trusted_services
33

  
33 34
from ..models import AccessRight, ResourceLog
34 35

  
35 36
register = template.Library()
36 37

  
37 38

  
38 39
@register.inclusion_tag('passerelle/includes/access-rights-table.html', takes_context=True)
39 40
def access_rights_table(context, resource, permission):
40 41
    resource_type = ContentType.objects.get_for_model(resource)
passerelle/base/urls.py
1 1
from django.conf.urls import url
2 2

  
3 3
from .views import (
4
    AccessRightCreateView,
5
    AccessRightDeleteView,
4 6
    ApiUserCreateView,
5
    ApiUserUpdateView,
6 7
    ApiUserDeleteView,
7 8
    ApiUserListView,
8
    AccessRightDeleteView,
9
    AccessRightCreateView,
9
    ApiUserUpdateView,
10
    ExportSiteView,
11
    ImportSiteView,
10 12
    LoggingParametersUpdateView,
11 13
    ManageAvailabilityView,
12
    ImportSiteView,
13
    ExportSiteView,
14 14
)
15 15

  
16 16
access_urlpatterns = [
17 17
    url(r'^$', ApiUserListView.as_view(), name='apiuser-list'),
18 18
    url(r'^add$', ApiUserCreateView.as_view(), name='apiuser-add'),
19 19
    url(r'^(?P<pk>[\w,-]+)/edit$', ApiUserUpdateView.as_view(), name='apiuser-edit'),
20 20
    url(r'^(?P<pk>[\w,-]+)/delete$', ApiUserDeleteView.as_view(), name='apiuser-delete'),
21 21
    url(r'^(?P<pk>[\w,-]+)/remove$', AccessRightDeleteView.as_view(), name='access-right-remove'),
passerelle/base/views.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18 18
import json
19 19

  
20 20
from dateutil import parser as date_parser
21

  
22 21
from django.conf import settings
23 22
from django.contrib.contenttypes.models import ContentType
24
from django.urls import reverse
25 23
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
26 24
from django.db.models import Q
27 25
from django.forms import models as model_forms
28
from django.views.generic import View, DetailView, ListView, CreateView, UpdateView, DeleteView, FormView
29 26
from django.http import Http404, HttpResponse, HttpResponseRedirect
30 27
from django.shortcuts import get_object_or_404
28
from django.urls import reverse
31 29
from django.utils.timezone import make_aware
32 30
from django.utils.translation import ugettext_lazy as _
31
from django.views.generic import CreateView, DeleteView, DetailView, FormView, ListView, UpdateView, View
33 32

  
34 33
from passerelle.compat import json_loads
35 34

  
36
from .models import ApiUser, AccessRight, LoggingParameters, ResourceStatus, Job
37
from .forms import ApiUserForm, AccessRightForm, AvailabilityParametersForm, ImportSiteForm
35
from ..utils import export_site, get_trusted_services, import_site
38 36
from ..views import GenericConnectorMixin
39
from ..utils import get_trusted_services, import_site, export_site
37
from .forms import AccessRightForm, ApiUserForm, AvailabilityParametersForm, ImportSiteForm
38
from .models import AccessRight, ApiUser, Job, LoggingParameters, ResourceStatus
40 39

  
41 40

  
42 41
class ResourceView(DetailView):
43 42
    template_name = 'passerelle/base/view.html'
44 43

  
45 44
    def get_object(self, queryset=None):
46 45
        try:
47 46
            obj = self.model.objects.get_subclass(slug=self.kwargs['slug'])
passerelle/contrib/dpark/models.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from __future__ import unicode_literals
18 18

  
19
import datetime
20 19
import base64
20
import datetime
21 21

  
22 22
import pytz
23

  
24 23
from django.conf import settings
24
from django.core.cache import cache
25 25
from django.db import models
26 26
from django.utils import six, timezone
27 27
from django.utils.translation import ugettext_lazy as _
28
from django.core.cache import cache
29

  
30 28
from zeep.exceptions import Fault as WebFault
31 29
from zeep.helpers import serialize_object
32 30

  
33 31
from passerelle.base.models import BaseResource
34 32
from passerelle.compat import json_loads
35 33
from passerelle.utils.api import endpoint
36
from passerelle.utils.jsonresponse import APIError
37 34
from passerelle.utils.conversion import to_pdf
35
from passerelle.utils.jsonresponse import APIError
38 36
from passerelle.views import WrongParameter
39 37

  
40 38

  
41 39
class Error(object):
42 40
    def __init__(self, code, msg=None):
43 41
        self.code = code
44 42
        self.msg = msg
45 43

  
passerelle/contrib/fake_family/default_database.py
11 11
# This program is distributed in the hope that it will be useful,
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19
from datetime import datetime, timedelta
20
import random
21 19
import json
20
import random
21
from datetime import datetime, timedelta
22 22

  
23 23
from passerelle.contrib.fake_family import randomnames
24 24

  
25 25

  
26 26
def default_database():
27 27

  
28 28
    now = datetime.now()
29 29

  
passerelle/contrib/fake_family/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('base', '0001_initial'),
12 12
    ]
13 13

  
passerelle/contrib/fake_family/migrations/0002_fakefamily_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('fake_family', '0001_initial'),
11 11
    ]
12 12

  
passerelle/contrib/fake_family/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.contrib.postgres.fields import JSONField
18
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
18 19
from django.urls import reverse
19 20
from django.utils.translation import ugettext_lazy as _
20
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
21 21

  
22 22
from passerelle.base.models import BaseResource
23

  
23 24
from .default_database import default_database
24 25

  
25 26

  
26 27
class FakeFamily(BaseResource):
27 28
    jsondatabase = JSONField(_('Fake Database (JSON)'), blank=True)
28 29

  
29 30
    category = _('Business Process Connectors')
30 31

  
passerelle/contrib/gdema/models.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18 18
import json
19 19
import re
20 20

  
21 21
from django.db import models
22
from django.utils.timezone import get_fixed_timezone, utc, is_naive, make_aware
23 22
from django.utils.dateparse import parse_date, parse_datetime
24 23
from django.utils.six import string_types
24
from django.utils.timezone import get_fixed_timezone, is_naive, make_aware, utc
25 25
from django.utils.translation import ugettext_lazy as _
26 26

  
27 27
from passerelle.base.models import BaseResource
28 28
from passerelle.compat import json_loads
29 29
from passerelle.utils.api import endpoint
30 30
from passerelle.utils.jsonresponse import APIError
31 31

  
32 32
# Only for documentation
passerelle/contrib/greco/models.py
10 10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16 16
import base64
17 17
import re
18

  
19 18
from email.mime.base import MIMEBase
20 19
from email.mime.multipart import MIMEMultipart
21 20
from email.mime.text import MIMEText
22 21

  
23
from suds.client import Client
24
from suds.transport import Reply
25
from suds.transport.http import HttpAuthenticated
26 22
import suds.sudsobject
27

  
23
from django.core.cache import cache
28 24
from django.db import models
29 25
from django.utils import six
30 26
from django.utils.translation import ugettext_lazy as _
31
from django.core.cache import cache
27
from suds.client import Client
28
from suds.transport import Reply
29
from suds.transport.http import HttpAuthenticated
32 30

  
33 31
from passerelle.base.models import BaseResource
34 32
from passerelle.compat import json_loads
35
from passerelle.utils.api import endpoint, APIError
36 33
from passerelle.soap import sudsobject_to_dict
34
from passerelle.utils.api import APIError, endpoint
37 35

  
38
from .formdata import FormData, CREATION_SCHEMA, list_schema_fields
39

  
36
from .formdata import CREATION_SCHEMA, FormData, list_schema_fields
40 37

  
41 38
# taken from https://lsimons.wordpress.com/2011/03/17/stripping-illegal-characters-out-of-xml-in-python/
42 39
_illegal_xml_chars_RE = re.compile(u'[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]')
43 40

  
44 41

  
45 42
def escape_xml_illegal_chars(val, replacement='?'):
46 43
    return _illegal_xml_chars_RE.sub(replacement, val)
47 44

  
passerelle/contrib/grenoble_gru/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from lxml import etree
18

  
19 17
from django.core.cache import cache
20 18
from django.db import models
21
from django.utils.translation import ugettext_lazy as _
22 19
from django.utils import dateparse
23 20
from django.utils.http import urlencode
24
from django.utils.text import slugify
25 21
from django.utils.six.moves.urllib import parse as urlparse
22
from django.utils.text import slugify
23
from django.utils.translation import ugettext_lazy as _
24
from lxml import etree
26 25

  
27 26
from passerelle.base.models import BaseResource
28 27
from passerelle.compat import json_loads
29 28
from passerelle.utils.api import endpoint
30 29
from passerelle.utils.jsonresponse import APIError
31 30
from passerelle.views import WrongParameter
32 31

  
33

  
34 32
RESPONSE_CODES = {
35 33
    '01': _('Success'),
36 34
    '02': _('Remote service error'),
37 35
    '10': _('Authentication failed'),
38 36
    '11': _('Collectivity not defined'),
39 37
    '20': _('Invalid input format'),
40 38
    '21': _('Required field not provided'),
41 39
    '22': _('Unexpected value (referentials)'),
passerelle/contrib/iparapheur/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/contrib/iparapheur/migrations/0002_auto_20160406_1123.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('iparapheur', '0001_initial'),
11 11
    ]
12 12

  
passerelle/contrib/iparapheur/migrations/0003_iparapheur_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('iparapheur', '0002_auto_20160406_1123'),
11 11
    ]
12 12

  
passerelle/contrib/iparapheur/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
import base64
17 17

  
18
from requests.exceptions import ConnectionError
19 18
from django.db import models
19
from django.http import Http404, HttpResponse
20 20
from django.utils.encoding import force_text
21 21
from django.utils.six.moves.urllib import parse
22 22
from django.utils.text import slugify
23 23
from django.utils.translation import ugettext_lazy as _
24
from django.http import HttpResponse, Http404
25

  
24
from requests.exceptions import ConnectionError
26 25
from zeep import Settings
27
from zeep.exceptions import Fault as WebFault, TransportError, XMLSyntaxError
26
from zeep.exceptions import Fault as WebFault
27
from zeep.exceptions import TransportError, XMLSyntaxError
28 28

  
29 29
from passerelle.base.models import BaseResource, HTTPResource
30 30
from passerelle.utils.api import endpoint
31 31
from passerelle.utils.jsonresponse import APIError
32 32

  
33

  
34 33
CREATE_FILE_SCHEMA = {
35 34
    '$schema': 'http://json-schema.org/draft-04/schema#',
36 35
    'title': 'Iparapheur create file',
37 36
    'type': 'object',
38 37
    'required': ['file', 'title', 'type', 'subtype', 'visibility'],
39 38
    'properties': {
40 39
        'file': {
41 40
            'type': 'object',
passerelle/contrib/isere_ens/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from collections import OrderedDict
18 17
import datetime
18
from collections import OrderedDict
19 19

  
20 20
from django.core.cache import cache
21 21
from django.db import models
22 22
from django.utils.formats import date_format
23 23
from django.utils.six.moves.urllib import parse as urlparse
24 24
from django.utils.translation import ugettext_lazy as _
25 25

  
26
from passerelle.base.models import BaseResource, HTTPResource
27
from passerelle.utils.api import endpoint
26 28
from passerelle.utils.conversion import simplify
27 29
from passerelle.utils.jsonresponse import APIError
28
from passerelle.utils.api import endpoint
29
from passerelle.base.models import BaseResource, HTTPResource
30

  
31 30

  
32 31
SITE_BOOKING_SCHOOL_SCHEMA = {
33 32
    "$schema": "http://json-schema.org/draft-04/schema#",
34 33
    "title": "ENS site/booking/school",
35 34
    "description": "",
36 35
    "type": "object",
37 36
    "required": [
38 37
        "code",
passerelle/contrib/iws/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from datetime import datetime
18 17
import json
18
from datetime import datetime
19 19

  
20
import lxml.etree
21
import pkg_resources
20 22
from django.db import models
21 23
from django.utils import dateformat
22 24
from django.utils.translation import ugettext_lazy as _
23
import lxml.etree
24
import pkg_resources
25 25

  
26 26
from passerelle.base.models import BaseResource
27 27
from passerelle.utils.api import endpoint
28 28
from passerelle.utils.conversion import any2bool
29 29
from passerelle.utils.jsonresponse import APIError
30 30

  
31

  
32 31
TYPE_AGENDA = {"DECHET": "DECHETS VERTS", "ENCOMBRANT": "ENCOMBRANTS"}
33 32
C_TYPEPB = {"DECHET": "8006", "ENCOMBRANT": "8008"}
34 33
SYNDIC_C_TYPEPB = {"DECHET": "8007", "ENCOMBRANT": "8009"}
35 34

  
36 35
NS = '{http://isilog.fr}'
37 36

  
38 37
BOOKDATE_SCHEMA = {
39 38
    "$schema": "http://json-schema.org/draft-04/schema#",
passerelle/contrib/lille_kimoce/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17

  
18
from django.core.cache import cache
18 19
from django.db import models
19
from django.utils.translation import ugettext_lazy as _
20 20
from django.utils.six.moves.urllib_parse import urljoin
21
from django.core.cache import cache
21
from django.utils.translation import ugettext_lazy as _
22 22

  
23 23
from passerelle.base.models import BaseResource
24 24
from passerelle.utils.api import endpoint
25 25
from passerelle.utils.http_authenticators import HttpBearerAuth
26 26
from passerelle.utils.jsonresponse import APIError
27 27

  
28

  
29 28
DEMAND_SCHEMA = {
30 29
    '$schema': 'http://json-schema.org/draft-04/schema#',
31 30
    'title': 'KIMOCE',
32 31
    'description': '',
33 32
    'type': 'object',
34 33
    'required': ['category', 'type', 'subtype', 'form_url', 'first_name', 'last_name', 'email'],
35 34
    'properties': {
36 35
        'category': {
passerelle/contrib/mdph13/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.10 on 2019-02-15 09:57
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    initial = True
12 12

  
13 13
    dependencies = [
14 14
        ('base', '0010_loggingparameters_trace_emails'),
passerelle/contrib/mdph13/models.py
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import base64
19 19
import datetime
20 20
import re
21 21

  
22 22
import requests
23

  
24 23
from django.db import models, transaction
25
from django.utils import six, dateparse
24
from django.utils import dateparse, six
26 25
from django.utils.six.moves.urllib import parse as urlparse
27
from django.utils.translation import ugettext_lazy as _
28 26
from django.utils.timezone import now
27
from django.utils.translation import ugettext_lazy as _
29 28

  
30
from passerelle.utils.jsonresponse import APIError, to_json
31
from passerelle.utils.api import endpoint
32 29
from passerelle.base.models import BaseResource, HTTPResource
30
from passerelle.utils.api import endpoint
31
from passerelle.utils.jsonresponse import APIError, to_json
33 32

  
34 33

  
35 34
def json_walker(value, func, path=None):
36 35
    """Walk a JSON structure of objects, arrays and scalar values, call
37 36
    func(value, path) on values."""
38 37
    path = path or []
39 38
    if isinstance(value, dict):
40 39
        for key in value:
passerelle/contrib/nancypoll/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/contrib/nancypoll/migrations/0004_csv_upload_to.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4 4
from django.db import migrations, models
5

  
5 6
import passerelle.contrib.nancypoll.models
6 7

  
7 8

  
8 9
class Migration(migrations.Migration):
9 10

  
10 11
    dependencies = [
11 12
        ('nancypoll', '0003_remove_nancypoll_log_level'),
12 13
    ]
passerelle/contrib/nancypoll/migrations/0005_csv_upload_to.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3

  
3 4
import os
4 5

  
5 6
from django.db import migrations
6 7

  
7 8

  
8 9
def move_files(apps, schema_editor):
9 10
    NancyPoll = apps.get_model('nancypoll', 'NancyPoll')
10 11
    NancyPoll.get_connector_slug = lambda *args, **kwargs: 'nancypoll'
passerelle/contrib/nancypoll/models.py
1 1
import csv
2 2

  
3
from django.db import models
4 3
from django.core.exceptions import ObjectDoesNotExist
4
from django.db import models
5 5
from django.utils import six
6 6
from django.utils.encoding import force_text
7 7
from django.utils.translation import ugettext_lazy as _
8 8

  
9 9
from passerelle.base.models import BaseResource
10 10
from passerelle.utils.api import endpoint
11 11
from passerelle.utils.jsonresponse import APIError
12 12

  
13

  
14 13
COLUMN_NAMES = (
15 14
    'street_start_number, street_end_number,,,street_side,,,,code,id,text,address,,,street_name,,canton,,,'
16 15
)
17 16

  
18 17

  
19 18
def to_unicode(value):
20 19
    return force_text(value, 'utf-8')
21 20

  
passerelle/contrib/planitech/migrations/0002_planitechconnector_custom_fields.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.17 on 2019-01-08 11:22
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations
6 5
import django.contrib.postgres.fields.jsonb
6
from django.db import migrations
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('planitech', '0001_initial'),
13 13
    ]
14 14

  
passerelle/contrib/planitech/migrations/0003_pairing.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.17 on 2019-01-10 11:08
3 3
from __future__ import unicode_literals
4 4

  
5
from django.db import migrations, models
6 5
import django.db.models.deletion
6
from django.db import migrations, models
7 7

  
8 8

  
9 9
class Migration(migrations.Migration):
10 10

  
11 11
    dependencies = [
12 12
        ('planitech', '0002_planitechconnector_custom_fields'),
13 13
    ]
14 14

  
passerelle/contrib/planitech/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import collections
18
from datetime import date, datetime, time, timedelta
19 18
import hashlib
20 19
import json
21 20
import re
22 21
import uuid
22
from datetime import date, datetime, time, timedelta
23 23

  
24 24
from django.contrib.postgres.fields import JSONField
25 25
from django.core.cache import cache
26 26
from django.db import models, transaction
27
from django.utils import dateformat
28
from django.utils import dateparse
27
from django.utils import dateformat, dateparse
29 28
from django.utils.encoding import force_bytes
30 29
from django.utils.six.moves.urllib import parse as urlparse
31 30
from django.utils.translation import ugettext_lazy as _
32 31
from requests.exceptions import RequestException
33 32

  
34 33
from passerelle.base.models import BaseResource
35 34
from passerelle.contrib.planitech import mste
36 35
from passerelle.utils.api import endpoint
37 36
from passerelle.utils.jsonresponse import APIError
38 37

  
39

  
40 38
DEFAULT_MIN_CAPACITY = 0
41 39
DEFAULT_MAX_CAPACITY = 100000
42 40

  
43 41

  
44 42
CREATE_RESERVATION_SCHEMA = {
45 43
    "$schema": "http://json-schema.org/draft-04/schema#",
46 44
    "title": "Planitech createreservation",
47 45
    "description": "",
passerelle/contrib/planitech/mste.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from datetime import datetime
18 17
import calendar
18
from datetime import datetime
19 19

  
20 20
from django.utils import six
21 21

  
22

  
23 22
ENCODE_TOKENS = {
24 23
    'integer': 16,
25 24
    'real': 19,
26 25
    'nil': 0,
27 26
    'true': 1,
28 27
    'false': 2,
29 28
    'emptyString': 3,
30 29
    'emptyData': 4,
passerelle/contrib/rsa13/models.py
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import csv
19 19
from urllib.parse import urljoin
20 20

  
21 21
import requests
22

  
23 22
from django.db import models
24 23
from django.http import HttpResponse
25
from django.utils.translation import ugettext_lazy as _
26 24
from django.utils.timezone import now
25
from django.utils.translation import ugettext_lazy as _
27 26

  
28 27
from passerelle.base.models import BaseResource, HTTPResource
29 28
from passerelle.utils.api import endpoint
30 29
from passerelle.utils.jsonresponse import APIError
31 30

  
32 31
OUI_NON_ENUM = {'enum': ['Oui', 'Non']}
33 32
DATE_SCHEMA = {'type': 'string', 'format': 'date'}
34 33

  
passerelle/contrib/sigerly/models.py
18 18

  
19 19
from django.db import models
20 20
from django.utils.translation import ugettext_lazy as _
21 21

  
22 22
from passerelle.base.models import BaseResource, HTTPResource
23 23
from passerelle.utils.api import endpoint
24 24
from passerelle.utils.jsonresponse import APIError
25 25

  
26

  
27 26
CREATE_SCHEMA = {
28 27
    '$schema': 'http://json-schema.org/draft-04/schema#',
29 28
    "type": "object",
30 29
    'required': ['demandeur', 'id_typeinterv', 'id_urgence', 'elements'],
31 30
    'properties': {
32 31
        'demandeur': {
33 32
            'description': "Nom du demandeur",
34 33
            'type': 'string',
passerelle/contrib/solis_apa/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0002_auto_20151009_0326'),
11 11
    ]
12 12

  
passerelle/contrib/solis_apa/models.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import re
18 17
import json
18
import re
19 19

  
20
from django.db import models
21 20
from django.core.cache import cache
22
from django.urls import reverse
23 21
from django.db import models
22
from django.http import HttpResponse
23
from django.urls import reverse
24 24
from django.utils.six.moves.urllib import parse as urlparse
25 25
from django.utils.translation import ugettext_lazy as _
26
from django.http import HttpResponse
27 26

  
28 27
from passerelle.base.models import BaseResource
29 28
from passerelle.compat import json_loads
30
from passerelle.contrib.solis_apa import conciliation, suivi, integration
29
from passerelle.contrib.solis_apa import conciliation, integration, suivi
31 30
from passerelle.utils.jsonresponse import APIError
32 31

  
33 32
HEADERS = {'Accept': 'application/json', 'Content-Type': 'application/json'}
34 33

  
35 34
APPLICATION = 'AsgTeleprocedureApa14'
36 35

  
37 36

  
38 37
class SolisAPA(BaseResource):
passerelle/contrib/solis_apa/suivi.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import json
18 17
import datetime
18
import json
19 19

  
20 20
PAYLOAD = {
21 21
    "visite": {},
22 22
    "plan-aide": {"DemandeAsg": {"DateDebut": "%(datedebut)s", "DateFin": "%(datefin)s"}},
23 23
    "presentation-commission": {"OrdreJourAsg": {"DateDebut": "%(datedebut)s", "DateFin": "%(datefin)s"}},
24 24
    "decision-commission": {
25 25
        "DemandeAsg": {
26 26
            "EtatDecision": "R",
passerelle/contrib/solis_apa/views.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.views.generic import DetailView as GenericDetailView, View
18
from django.views.generic.detail import SingleObjectMixin
19 17
from django.utils.decorators import method_decorator
20
from django.views.decorators.csrf import csrf_exempt
21 18
from django.utils.translation import ugettext_lazy as _
19
from django.views.decorators.csrf import csrf_exempt
20
from django.views.generic import DetailView as GenericDetailView
21
from django.views.generic import View
22
from django.views.generic.detail import SingleObjectMixin
22 23

  
23 24
import passerelle.utils as utils
24 25

  
25 26
from .models import SolisAPA
26 27

  
27 28

  
28 29
class CommissionTypeNotFound(Exception):
29 30
    http_status = 404
passerelle/contrib/strasbourg_eu/models.py
18 18

  
19 19
from django.db import models
20 20
from django.utils.encoding import force_text
21 21
from django.utils.six.moves.urllib import parse as urlparse
22 22
from django.utils.translation import ugettext_lazy as _
23 23

  
24 24
from passerelle.base.models import BaseResource
25 25
from passerelle.compat import json_loads
26
from passerelle.utils.api import endpoint, APIError
26
from passerelle.utils.api import APIError, endpoint
27 27

  
28 28

  
29 29
class StrasbourgEu(BaseResource):
30 30
    category = _('Misc')
31 31

  
32 32
    liferay_api_url = models.URLField(_('Liferay API URL'), max_length=256)
33 33

  
34 34
    class Meta:
passerelle/contrib/stub_invoices/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18
from decimal import Decimal
19 18
import random
19
from decimal import Decimal
20 20

  
21 21
from django.http import HttpResponse
22
from django.utils.translation import ugettext_lazy as _
23 22
from django.utils import timezone
23
from django.utils.translation import ugettext_lazy as _
24 24

  
25 25
from passerelle.base.models import BaseResource
26 26
from passerelle.utils.api import endpoint
27 27

  
28 28

  
29 29
class StubInvoicesConnector(BaseResource):
30 30
    category = _('Stub Connectors')
31 31

  
passerelle/contrib/tcl/models.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import re
18 18

  
19 19
from django.conf import settings
20 20
from django.db import models, transaction
21
from django.utils.translation import ugettext_lazy as _
22 21
from django.utils import timezone
22
from django.utils.translation import ugettext_lazy as _
23 23

  
24 24
from passerelle.base.models import BaseResource
25 25
from passerelle.utils.api import endpoint
26 26

  
27 27

  
28 28
def get_tcl_data_url(key):
29 29
    if key == 'tclarret':
30 30
        return settings.TCL_GEOJSON_URL_TEMPLATE % key
passerelle/contrib/teamnet_axel/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('base', '0001_initial'),
11 11
    ]
12 12

  
passerelle/contrib/teamnet_axel/migrations/0002_management_billing_regies.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
5 4
import django.contrib.postgres.fields.jsonb
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('teamnet_axel', '0001_initial'),
12 12
    ]
13 13

  
passerelle/contrib/teamnet_axel/migrations/0003_management_log_level.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import models, migrations
4
from django.db import migrations, models
5 5

  
6 6

  
7 7
class Migration(migrations.Migration):
8 8

  
9 9
    dependencies = [
10 10
        ('teamnet_axel', '0002_management_billing_regies'),
11 11
    ]
12 12

  
passerelle/contrib/teamnet_axel/models.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18
from datetime import datetime
19 18
import logging
20 19
import xml.etree.ElementTree as ET
20
from datetime import datetime
21 21

  
22 22
from django.contrib.postgres.fields import JSONField
23 23
from django.db import models
24 24
from django.http import HttpResponse, HttpResponseNotFound
25
from django.utils.translation import ugettext_lazy as _
26 25
from django.utils.encoding import smart_text
26
from django.utils.translation import ugettext_lazy as _
27 27

  
28 28
from passerelle.base.models import BaseResource
29 29
from passerelle.compat import json_loads
30 30
from passerelle.soap import client_to_jsondict
31 31
from passerelle.utils.api import endpoint
32 32
from passerelle.utils.jsonresponse import APIError
33 33
from passerelle.views import WrongParameter
34 34

  
35 35
from . import soap
36
from .utils import normalize_person, normalize_invoice
36
from .utils import normalize_invoice, normalize_person
37 37

  
38 38
logger = logging.getLogger('passerelle.contrib.teamnet_axel')
39 39

  
40 40
ADULT1 = '1'
41 41
ADULT2 = '2'
42 42
CHILD = '3'
43 43

  
44 44
DATE_IN_FORMAT = '%Y-%m-%dT%H:%M:%S'
passerelle/contrib/teamnet_axel/soap.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
# borrowed from https://pypi.python.org/pypi/suds_requests
18 18
# and https://docs.oracle.com/cd/E50245_01/E50253/html/vmprg-soap-example-authentication-python.html
19 19

  
20 20
from django.utils.six import BytesIO
21
from suds.transport.http import HttpAuthenticated
22
from suds.transport import Reply
23 21
from suds.client import Client
22
from suds.transport import Reply
23
from suds.transport.http import HttpAuthenticated
24 24

  
25 25

  
26 26
class Transport(HttpAuthenticated):
27 27
    def __init__(self, model, **kwargs):
28 28
        self.model = model
29 29
        HttpAuthenticated.__init__(self, **kwargs)  # oldstyle class...
30 30

  
31 31
    def get_requests_kwargs(self):
passerelle/contrib/toulouse_axel/migrations/0001_initial.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import django.db.models.deletion
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    initial = True
11 11

  
12 12
    dependencies = [
13 13
        ('base', '0016_auto_20191002_1443'),
passerelle/contrib/toulouse_axel/migrations/0003_auto_20191205_0948.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4
from django.db import migrations, models
5 4
import django.db.models.deletion
5
from django.db import migrations, models
6 6

  
7 7

  
8 8
class Migration(migrations.Migration):
9 9

  
10 10
    dependencies = [
11 11
        ('toulouse_axel', '0002_auto_20191122_0946'),
12 12
    ]
13 13

  
passerelle/contrib/toulouse_axel/models.py
25 25
from django.utils import dateformat
26 26
from django.utils.dates import WEEKDAYS as WEEKDAYS_LABELS
27 27
from django.utils.translation import ugettext_lazy as _
28 28

  
29 29
from passerelle.base.models import BaseResource
30 30
from passerelle.compat import json_loads
31 31
from passerelle.utils.api import endpoint
32 32
from passerelle.utils.jsonresponse import APIError
33
from . import schemas
34
from . import utils
33

  
34
from . import schemas, utils
35 35
from .exceptions import AxelError
36 36

  
37 37
logger = logging.getLogger('passerelle.contrib.toulouse_axel')
38 38

  
39 39
BASE_XSD_PATH = os.path.join(os.path.dirname(__file__), 'xsd')
40 40

  
41 41
WEEKDAYS = {
42 42
    0: 'monday',
passerelle/contrib/toulouse_axel/schemas.py
16 16

  
17 17
import copy
18 18
import datetime
19 19
import os
20 20
import re
21 21
import xml.etree.ElementTree as ET
22 22
from collections import namedtuple
23 23

  
24
from django.utils.encoding import force_text
25

  
26 24
import xmlschema
25
from django.utils.encoding import force_text
27 26

  
28 27
from passerelle.utils.xml import JSONSchemaFromXMLSchema
28

  
29 29
from . import utils
30 30
from .exceptions import AxelError
31 31

  
32 32
BASE_XSD_PATH = os.path.join(os.path.dirname(__file__), 'xsd')
33 33

  
34 34

  
35 35
class AxelSchema(JSONSchemaFromXMLSchema):
36 36
    type_map = {
passerelle/contrib/toulouse_axel/utils.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20
from collections import OrderedDict
21 20
import datetime
22 21
import unicodedata
23 22
import xml.etree.ElementTree as ET
23
from collections import OrderedDict
24 24

  
25 25
import pytz
26

  
27 26
from django.utils.six import string_types
28 27

  
29 28
from passerelle.utils.conversion import normalize
30 29

  
31

  
32 30
boolean_type = {
33 31
    'oneOf': [
34 32
        {'type': 'boolean'},
35 33
        {
36 34
            'type': 'string',
37 35
            'pattern': '[Oo][Uu][Ii]|[Nn][Oo][Nn]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|1|0',
38 36
        },
39 37
    ]
passerelle/plugins.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from django.apps import apps
18 18
from django.conf.urls import include, url
19 19

  
20
from .urls_utils import decorated_includes, required, app_enabled, manager_required
20
from .urls_utils import app_enabled, decorated_includes, manager_required, required
21 21

  
22 22

  
23 23
def register_apps_urls(urlpatterns):
24 24
    """Call get_before_urls and get_after_urls on all apps providing them,
25 25
    add those urls to the given urlpatterns (before or after).
26 26
    """
27 27
    before_urls = []
28 28
    after_urls = []
passerelle/settings.py
1 1
# Django default settings for passerelle project.
2 2

  
3
from django.conf import global_settings
4
import os
5 3
import logging
4
import os
5

  
6
from django.conf import global_settings
6 7

  
7 8
try:
8 9
    from logging.handlers import NullHandler
9 10
except ImportError:
10 11
    # python < 2.7
11 12
    class NullHandler(logging.Handler):
12 13
        def emit(self, record):
13 14
            pass
passerelle/sms/models.py
23 23
from django.utils.translation import ugettext_lazy as _
24 24

  
25 25
from passerelle.base.models import BaseResource
26 26
from passerelle.compat import json_loads
27 27
from passerelle.sms.forms import SMSConnectorForm
28 28
from passerelle.utils.api import endpoint
29 29
from passerelle.utils.jsonresponse import APIError
30 30

  
31

  
32 31
SEND_SCHEMA = {
33 32
    '$schema': 'http://json-schema.org/draft-04/schema#',
34 33
    "type": "object",
35 34
    'required': ['message', 'from', 'to'],
36 35
    'properties': {
37 36
        'message': {
38 37
            'description': 'String message',
39 38
            'type': 'string',
passerelle/soap.py
1
from django.utils.encoding import force_text
2 1
import suds.sudsobject
2
from django.utils.encoding import force_text
3 3

  
4 4

  
5 5
def client_to_jsondict(client):
6 6
    """return description of the client, as dict (for json export)"""
7 7
    res = {}
8 8
    for i, sd in enumerate(client.sd):
9 9
        d = {}
10 10
        d['tns'] = sd.wsdl.tns[1]
passerelle/urls.py
1 1
from django.conf import settings
2 2
from django.conf.urls import include, url
3

  
4 3
from django.contrib import admin
5

  
6 4
from django.contrib.auth.decorators import login_required
7 5
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
8 6
from django.views.static import serve as static_serve
9 7

  
10 8
from .api.urls import urlpatterns as api_urls
9
from .base.urls import access_urlpatterns, import_export_urlpatterns
10
from .base.views import GenericJobView, GenericRestartJobView, GenericViewJobsConnectorView
11
from .plugins import register_apps_urls
12
from .urls_utils import decorated_includes, manager_required
11 13
from .views import (
12
    HomePageView,
13
    ManageView,
14
    ManageAddView,
14
    GenericConnectorView,
15 15
    GenericCreateConnectorView,
16 16
    GenericDeleteConnectorView,
17 17
    GenericEditConnectorView,
18 18
    GenericEndpointView,
19
    GenericConnectorView,
20
    GenericViewLogsConnectorView,
21
    GenericLogView,
22 19
    GenericExportConnectorView,
20
    GenericLogView,
21
    GenericViewLogsConnectorView,
22
    HomePageView,
23
    ManageAddView,
24
    ManageView,
23 25
    login,
24 26
    logout,
25 27
    menu_json,
26 28
)
27
from .base.views import GenericViewJobsConnectorView, GenericJobView, GenericRestartJobView
28
from .urls_utils import decorated_includes, manager_required
29
from .base.urls import access_urlpatterns, import_export_urlpatterns
30
from .plugins import register_apps_urls
31

  
32 29

  
33 30
admin.autodiscover()
34 31

  
35 32
urlpatterns = [
36 33
    url(r'^$', HomePageView.as_view(), name='homepage'),
37 34
    url(r'^manage/$', manager_required(ManageView.as_view()), name='manage-home'),
38 35
    url(r'^manage/menu.json$', manager_required(menu_json), name='menu-json'),
39 36
    url(r'^manage/add$', manager_required(ManageAddView.as_view()), name='add-connector'),
passerelle/urls_utils.py
6 6
from django.contrib.auth.decorators import user_passes_test
7 7
from django.core.exceptions import PermissionDenied
8 8

  
9 9
try:
10 10
    from django.urls import URLPattern, URLResolver
11 11
except ImportError:
12 12
    # django < 2.0 compatibility
13 13
    from django.urls import RegexURLPattern as URLPattern, RegexURLResolver as URLResolver
14
from django.views.debug import technical_404_response
14

  
15 15
from django.http import Http404
16
from django.views.debug import technical_404_response
16 17

  
17 18

  
18 19
class DecoratedURLPattern(URLPattern):
19 20
    def resolve(self, *args, **kwargs):
20 21
        result = super(DecoratedURLPattern, self).resolve(*args, **kwargs)
21 22
        if result:
22 23
            result.func = self._decorate_with(result.func)
23 24
        return result
passerelle/utils/__init__.py
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16 16
from __future__ import absolute_import
17 17

  
18 18
import base64
19
from functools import wraps
20 19
import hashlib
21 20
import re
22
from itertools import islice, chain
23 21
import warnings
24

  
25
from requests import Session as RequestSession, Response as RequestResponse
26
from requests.adapters import HTTPAdapter
27
from requests.structures import CaseInsensitiveDict
28
from urllib3.exceptions import InsecureRequestWarning
22
from functools import wraps
23
from itertools import chain, islice
29 24

  
30 25
from django.conf import settings
26
from django.contrib.contenttypes.models import ContentType
31 27
from django.core.cache import cache
32 28
from django.core.exceptions import PermissionDenied
29
from django.db import transaction
33 30
from django.http import HttpResponse, HttpResponseBadRequest
34
from django.template import Template, Context
31
from django.template import Context, Template
35 32
from django.utils.decorators import available_attrs
36 33
from django.utils.encoding import force_bytes, force_text
37 34
from django.utils.functional import lazy
38 35
from django.utils.html import mark_safe
39 36
from django.utils.six import BytesIO
40 37
from django.views.generic.detail import SingleObjectMixin
41
from django.contrib.contenttypes.models import ContentType
42
from django.db import transaction
38
from requests import Response as RequestResponse
39
from requests import Session as RequestSession
40
from requests.adapters import HTTPAdapter
41
from requests.structures import CaseInsensitiveDict
42
from urllib3.exceptions import InsecureRequestWarning
43 43

  
44 44
from passerelle.base.signature import check_query, check_url
45 45

  
46

  
47 46
mark_safe_lazy = lazy(mark_safe, str)
48 47

  
49 48

  
50 49
def response_for_json(request, data):
51 50
    import json
52 51

  
53 52
    response = HttpResponse(content_type='application/json')
54 53
    json_str = json.dumps(data)
......
325 324
        error_log = getattr(self.resource, 'log_requests_errors', True)
326 325
        log_http_request(
327 326
            self.logger, request=request, response=response, exception=exception, error_log=error_log
328 327
        )
329 328

  
330 329

  
331 330
def export_site(slugs=None):
332 331
    '''Dump passerelle configuration (users, resources and ACLs) to JSON dumpable dictionnary'''
333
    from passerelle.base.models import ApiUser
334
    from passerelle.base.models import BaseResource
332
    from passerelle.base.models import ApiUser, BaseResource
335 333

  
336 334
    d = {}
337 335
    d['apiusers'] = [apiuser.export_json() for apiuser in ApiUser.objects.all()]
338 336
    d['resources'] = resources = []
339 337
    for subclass in BaseResource.__subclasses__():
340 338
        if subclass._meta.abstract:
341 339
            continue
342 340
        for resource in subclass.objects.all():
......
348 346
                break
349 347
    return d
350 348

  
351 349

  
352 350
def import_site(d, if_empty=False, clean=False, overwrite=False, import_users=False):
353 351
    """Load passerelle configuration (users, resources and ACLs) from a dictionnary loaded from
354 352
    JSON
355 353
    """
356
    from passerelle.base.models import ApiUser
357
    from passerelle.base.models import BaseResource
354
    from passerelle.base.models import ApiUser, BaseResource
358 355

  
359 356
    d = d.copy()
360 357

  
361 358
    def is_empty():
362 359
        if import_users:
363 360
            if ApiUser.objects.count():
364 361
                return False
365 362

  
......
402 399
        try:
403 400
            yield chain([next(batchiter)], batchiter)
404 401
        except StopIteration:
405 402
            return
406 403

  
407 404

  
408 405
# legacy import, other modules keep importing to_json from passerelle.utils
409 406
from .jsonresponse import to_json
407
from .sftp import SFTP, SFTPField
410 408
from .soap import SOAPClient, SOAPTransport
411
from .sftp import SFTPField, SFTP
passerelle/utils/conversion.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import codecs
18 18
import math
19 19
import re
20 20
import unicodedata
21 21
import warnings
22 22

  
23
import unidecode
23 24
from django.utils import six
24 25
from django.utils.encoding import force_str, force_text
25 26
from django.utils.six import BytesIO
26

  
27
import unidecode
28 27
from PIL import Image
29 28

  
30 29

  
31 30
def to_pdf(content):
32 31
    if content.startswith((b'%PDF', codecs.BOM + b'%PDF', codecs.BOM_UTF8 + b'%PDF')):
33 32
        return content
34 33
    try:
35 34
        with warnings.catch_warnings():
passerelle/utils/files.py
8 8
# This program is distributed in the hope that it will be useful,
9 9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16
import os.path
17 16
import contextlib
18
import tempfile
19 17
import errno
18
import os.path
19
import tempfile
20 20

  
21 21
from django.core.files.storage import default_storage
22 22

  
23 23

  
24 24
@contextlib.contextmanager
25 25
def atomic_write(filepath, **kwargs):
26 26
    """Return a file descriptor to a temporary file using NamedTemporaryFile
27 27
    which will be atomically renamed to filepath if possible.
passerelle/utils/http_authenticators.py
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import base64
18 18
import hashlib
19 19
import hmac
20 20
import time
21

  
22 21
from uuid import uuid4
23 22

  
24 23
from django.utils.encoding import force_bytes, force_text
25 24
from django.utils.six.moves.urllib import parse as urlparse
26 25
from requests.auth import AuthBase
27 26

  
28 27

  
29 28
class HawkAuth(AuthBase):
passerelle/utils/json.py
30 30
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
31 31

  
32 32
from __future__ import unicode_literals
33 33

  
34 34
from django.utils import six
35 35

  
36 36
from passerelle.utils.validation import is_number
37 37

  
38

  
39 38
FLATTEN_SEPARATOR = '/'
40 39

  
41 40

  
42 41
def unflatten(d, separator=FLATTEN_SEPARATOR):
43 42
    """Transform:
44 43

  
45 44
       {"a/b/0/x": "1234"}
46 45

  
passerelle/utils/jsonresponse.py
1 1
# This module is a modified copy of code of Yasha's Borevich library
2 2
# django-jsonresponse (https://github.com/jjay/django-jsonresponse) distributed
3 3
# under BSD license
4 4

  
5 5
from __future__ import absolute_import
6 6

  
7 7
import datetime
8
import json
9 8
import functools
9
import json
10 10
import logging
11 11
import re
12 12
import time
13 13

  
14
from django.http import HttpResponse, Http404, HttpResponseBadRequest
15
from django.http.response import HttpResponseBase
16 14
from django.conf import settings
17 15
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
18 16
from django.core.serializers.json import DjangoJSONEncoder
19
from django.utils.encoding import force_text
17
from django.http import Http404, HttpResponse, HttpResponseBadRequest
18
from django.http.response import HttpResponseBase
20 19
from django.utils import six
21

  
22
from requests import RequestException, HTTPError
20
from django.utils.encoding import force_text
21
from requests import HTTPError, RequestException
23 22

  
24 23
from passerelle.utils import log_http_request
25 24
from passerelle.utils.conversion import exception_to_text
26 25

  
27

  
28 26
DEFAULT_DEBUG = getattr(settings, 'JSONRESPONSE_DEFAULT_DEBUG', False)
29 27
CALLBACK_NAME = getattr(settings, 'JSONRESPONSE_CALLBACK_NAME', 'callback')
30 28

  
31 29

  
32 30
class APIError(RuntimeError):
33 31
    '''Exception to raise when there is a remote application or business logic error.'''
34 32

  
35 33
    def __init__(self, *args, **kwargs):
passerelle/utils/paginator.py
1
from django.core.paginator import Paginator, Page, EmptyPage
1
from django.core.paginator import EmptyPage, Page, Paginator
2 2
from django.utils.functional import cached_property
3 3
from django.utils.translation import ugettext_lazy as _
4 4

  
5 5

  
6 6
class InfinitePaginator(Paginator):
7 7
    def page(self, number):
8 8
        number = self.validate_number(number)
9 9
        offset = (number - 1) * self.per_page
passerelle/utils/sftp.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from __future__ import absolute_import
18 18

  
19
import os
20
import re
19
import contextlib
21 20
import io
22 21
import json
23
import contextlib
22
import os
23
import re
24 24

  
25
import paramiko
25 26
from django import forms
26 27
from django.core import validators
27 28
from django.db import models
28 29
from django.utils import six
29
from django.utils.encoding import force_text
30
from django.utils.translation import ugettext_lazy as _
30
from django.utils.encoding import force_bytes, force_text
31 31
from django.utils.six.moves.urllib import parse as urlparse
32
from django.utils.encoding import force_bytes
33

  
34
import paramiko
32
from django.utils.translation import ugettext_lazy as _
35 33
from paramiko.dsskey import DSSKey
36 34
from paramiko.ecdsakey import ECDSAKey
37 35

  
38 36
try:
39 37
    from paramiko.ed25519key import Ed25519Key
40 38
except ImportError:
41 39
    Ed25519Key = None
42
from paramiko.rsakey import RSAKey
43 40
from paramiko._version import __version_info__
41
from paramiko.rsakey import RSAKey
44 42

  
45 43

  
46 44
def _load_private_key(content_or_file, password=None):
47 45
    if not hasattr(content_or_file, 'read'):
48 46
        fd = io.TextIOWrapper(io.BytesIO(force_bytes(content_or_file)))
49 47
    else:
50 48
        fd = content_or_file
51 49

  
passerelle/utils/soap.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.utils.six.moves.urllib import parse as urlparse
17 18
from requests import RequestException
18

  
19 19
from zeep import Client
20 20
from zeep.cache import InMemoryCache
21 21
from zeep.transports import Transport
22 22

  
23
from django.utils.six.moves.urllib import parse as urlparse
24

  
25 23
from passerelle.utils.jsonresponse import APIError
26 24

  
27 25

  
28 26
class SOAPError(APIError):
29 27
    pass
30 28

  
31 29

  
32 30
class SOAPClient(Client):
passerelle/utils/templates.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
'''Simplify rendering of template to produce text values.
18 18

  
19 19
Disable autoescaping.
20 20
'''
21 21

  
22 22
from django.core.exceptions import ValidationError
23

  
24
from django.template.backends.django import DjangoTemplates
25 23
from django.template import TemplateSyntaxError
24
from django.template.backends.django import DjangoTemplates
26 25
from django.utils.translation import ugettext as _
27 26

  
28 27

  
29 28
def make_template(template_string):
30 29
    engine = DjangoTemplates(
31 30
        {
32 31
            'NAME': 'django',
33 32
            'DIRS': [],
passerelle/utils/wcs.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
from __future__ import absolute_import
18 18

  
19
import collections
20 19
import base64
20
import collections
21
import contextlib
21 22
import copy
22
import logging
23 23
import datetime
24
import contextlib
25 24
import json
25
import logging
26 26

  
27
import requests
28 27
import isodate
29

  
28
import requests
29
from django import forms
30 30
from django.conf import settings
31
from django.db import models
32 31
from django.core.cache import cache
33
from django import forms
34
from django.utils.six.moves.urllib import parse as urlparse
32
from django.db import models
35 33
from django.utils import six
34
from django.utils.six.moves.urllib import parse as urlparse
36 35

  
37 36
from passerelle.base import signature
38 37

  
39 38

  
40 39
class WcsApiError(Exception):
41 40
    pass
42 41

  
43 42

  
passerelle/utils/xml.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from collections import OrderedDict
18 17
import copy
18
from collections import OrderedDict
19 19

  
20 20
import jsonschema
21 21
import xmlschema
22 22

  
23 23

  
24 24
def text_content(node):
25 25
    """Extract text content from node and all its children. Equivalent to
26 26
    xmlNodeGetContent from libxml."""
passerelle/utils/zip.py
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from __future__ import unicode_literals, absolute_import
17
from __future__ import absolute_import, unicode_literals
18 18

  
19 19
import difflib
20 20
import io
21
import os.path
22 21
import json
22
import os.path
23 23
import re
24 24
import xml.etree.ElementTree as ET
25 25
import zipfile
26 26

  
27
from jsonschema import validate, ValidationError
28

  
29
from django.template import Template, Context, TemplateDoesNotExist, TemplateSyntaxError, engines
30
from django.utils.functional import cached_property
27
from django.template import Context, Template, TemplateDoesNotExist, TemplateSyntaxError, engines
28
from django.template.loader import get_template
31 29
from django.utils.encoding import force_str
30
from django.utils.functional import cached_property
32 31
from django.utils.six import python_2_unicode_compatible
33
from django.template.loader import get_template
32
from jsonschema import ValidationError, validate
34 33

  
35 34
from passerelle.utils.files import atomic_write
36 35

  
37

  
38 36
SCHEMA = {
39 37
    'type': 'object',
40 38
    'required': ['name_template'],
41 39
    'properties': {
42 40
        'name_template': {
43 41
            'type': 'string',
44 42
        },
45 43
        'part_templates': {
passerelle/views.py
16 16

  
17 17
import datetime
18 18
import hashlib
19 19
import inspect
20 20
import json
21 21
import logging
22 22
import uuid
23 23

  
24
from dateutil import parser as date_parser
24 25
from django.apps import apps
26
from django.conf import settings
25 27
from django.conf.urls import url
26
from django.core.cache import cache
27
from django.core.exceptions import PermissionDenied
28 28
from django.contrib.auth import logout as auth_logout
29 29
from django.contrib.auth import views as auth_views
30
from django.core.cache import cache
31
from django.core.exceptions import PermissionDenied
30 32
from django.db import transaction
31 33
from django.db.models import Q
32
from django.http import HttpResponse, HttpResponseRedirect, Http404
34
from django.http import Http404, HttpResponse, HttpResponseRedirect
35
from django.shortcuts import resolve_url
36
from django.urls import reverse
37
from django.utils.encoding import force_bytes, force_text
38
from django.utils.six.moves.urllib.parse import quote
39
from django.utils.timezone import make_aware
40
from django.utils.translation import ugettext_lazy as _
33 41
from django.views.decorators.csrf import csrf_exempt
34 42
from django.views.generic import (
35
    RedirectView,
36
    View,
37
    TemplateView,
38 43
    CreateView,
39 44
    DeleteView,
40
    UpdateView,
41 45
    DetailView,
42 46
    ListView,
47
    RedirectView,
48
    TemplateView,
49
    UpdateView,
50
    View,
43 51
)
44 52
from django.views.generic.detail import SingleObjectMixin
45
from django.conf import settings
46
from django.shortcuts import resolve_url
47
from django.urls import reverse
48
from django.utils.timezone import make_aware
49
from django.utils.translation import ugettext_lazy as _
50
from django.utils.encoding import force_bytes, force_text
51
from django.utils.six.moves.urllib.parse import quote
52

  
53
from dateutil import parser as date_parser
54
from jsonschema import validate, ValidationError
53
from jsonschema import ValidationError, validate
55 54

  
56 55
from passerelle.base.models import BaseResource, ResourceLog
57 56
from passerelle.compat import json_loads
58 57
from passerelle.utils.conversion import normalize
59
from passerelle.utils.jsonresponse import APIError
60 58
from passerelle.utils.json import unflatten
59
from passerelle.utils.jsonresponse import APIError
61 60
from passerelle.utils.paginator import InfinitePaginator
62 61

  
63
from .utils import to_json, is_authorized
64 62
from .forms import ResourceLogSearchForm
63
from .utils import is_authorized, to_json
65 64

  
66 65
if 'mellon' in settings.INSTALLED_APPS:
67 66
    from mellon.utils import get_idps
68 67
else:
69 68

  
70 69
    def get_idps():
71 70
        return []
72 71

  
setup.py
1 1
#!/usr/bin/python
2 2

  
3 3
import os
4 4
import subprocess
5 5
import sys
6
from distutils.cmd import Command
7
from distutils.command.build import build as _build
6 8

  
9
from setuptools import find_packages, setup
7 10
from setuptools.command.install_lib import install_lib as _install_lib
8 11
from setuptools.command.sdist import sdist
9
from distutils.command.build import build as _build
10
from distutils.cmd import Command
11
from setuptools import setup, find_packages
12 12

  
13 13

  
14 14
class eo_sdist(sdist):
15 15
    def run(self):
16 16
        if os.path.exists('VERSION'):
17 17
            os.remove('VERSION')
18 18
        version = get_version()
19 19
        version_file = open('VERSION', 'w')
tests/conftest.py
1
import pytest
2
from httmock import urlmatch, HTTMock, response, remember_called
1
from io import BytesIO
3 2

  
4 3
import django_webtest
5

  
4
import pytest
6 5
from django.contrib.auth.models import User
7
from django.core.files import File
8 6
from django.core.cache import cache
7
from django.core.files import File
9 8
from django.utils import six
10
from io import BytesIO
11

  
9
from httmock import HTTMock, remember_called, response, urlmatch
12 10
from utils import make_resource
13 11

  
14 12
if six.PY2:
15 13
    collect_ignore = ['wcs/']
16 14

  
17 15

  
18 16
@pytest.fixture(autouse=True)
19 17
def media(settings, tmpdir):
......
106 104
def mock_api_adresse_data_gouv_fr_reverse():
107 105
    with HTTMock(api_adresse_data_gouv_fr_reverse):
108 106
        yield None
109 107

  
110 108

  
111 109
@pytest.fixture
112 110
def endpoint_dummy_cache(monkeypatch):
113 111
    from django.core.cache import caches
112

  
114 113
    import passerelle.views
115 114

  
116 115
    monkeypatch.setattr(passerelle.views, 'cache', caches['dummy'])
117 116

  
118 117

  
119 118
@urlmatch()
120 119
def internal_server_error(url, request):
121 120
    return response(500, 'Internal server error')
tests/test_actesweb.py
11 11
# but WITHOUT ANY WARRANTY; exclude even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
from __future__ import unicode_literals
18 18

  
19
import json
20 19
import io
20
import json
21 21
import os
22 22
import shutil
23 23
import stat
24 24

  
25 25
import pytest
26

  
26
import utils
27 27
from django.utils import six
28 28

  
29
import utils
30 29
from passerelle.apps.actesweb.models import ActesWeb
31 30

  
32 31

  
33 32
def get_test_base_dir(name):
34 33
    return os.path.join(os.path.dirname(__file__), 'data', name)
35 34

  
36 35

  
37 36
def get_file_from_test_base_dir(filename):
tests/test_adict.py
1 1
import json
2

  
2 3
import mock
3 4
import pytest
5
import utils
4 6

  
5 7
from passerelle.contrib.adict.models import Adict
6 8

  
7
import utils
8

  
9 9
FAKE_FEATURE_INFO = json.dumps(
10 10
    {
11 11
        'type': 'FeatureCollection',
12 12
        'features': [
13 13
            {
14 14
                'type': 'Feature',
15 15
                'properties': {
16 16
                    'id': 51,
tests/test_airquality.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import freezegun
3 4
import pytest
4 5
import utils
5

  
6
import freezegun
7 6
from httmock import HTTMock, response
8 7

  
9 8
from passerelle.apps.airquality.models import AirQuality
10 9

  
11 10
SAMPLE_RESPONSE = {
12 11
    "licence": "https://opendatacommons.org/licenses/odbl/",
13 12
    "commune": "LYON-1ER-ARRONDISSEMENT",
14 13
    "code_insee": "69381",
tests/test_api.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import mock
18 18
import pytest
19

  
20
from django.urls import reverse
21 19
from django.contrib.contenttypes.models import ContentType
22 20
from django.test import override_settings
21
from django.urls import reverse
22
from test_manager import login
23 23

  
24 24
from passerelle.apps.ovh.models import OVHSMSGateway
25
from passerelle.base.models import ApiUser, AccessRight, Job
26

  
27
from test_manager import login
25
from passerelle.base.models import AccessRight, ApiUser, Job
28 26

  
29 27
pytestmark = pytest.mark.django_db
30 28

  
31 29
API_KEY = '1234'
32 30

  
33 31

  
34 32
@pytest.fixture
35 33
def connector(db):
tests/test_api_access.py
1 1
import re
2 2
import sys
3 3

  
4
from django.contrib.auth.models import User
5
from django.contrib.contenttypes.models import ContentType
6
from django.urls import reverse
7

  
8 4
import pytest
9 5
import utils
10

  
6
from django.contrib.auth.models import User
7
from django.contrib.contenttypes.models import ContentType
11 8
from django.test import override_settings
9
from django.urls import reverse
12 10

  
13
from passerelle.base import signature
14
from passerelle.base.models import ApiUser, AccessRight, ResourceLog
15 11
from passerelle.apps.oxyd.models import OxydSMSGateway
12
from passerelle.base import signature
13
from passerelle.base.models import AccessRight, ApiUser, ResourceLog
16 14

  
17 15
pytestmark = pytest.mark.django_db
18 16

  
19 17

  
20 18
@pytest.fixture
21 19
def oxyd(db):
22 20
    return OxydSMSGateway.objects.create(
23 21
        title='eservices', slug='eservices', username='user', description='oxyd', password='secret'
tests/test_api_entreprise.py
11 11
# This program is distributed in the hope that it will be useful,
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19
import pytest
20 19
import mock
20
import pytest
21 21
import requests
22

  
23
from httmock import urlmatch, HTTMock, response
24

  
25 22
from django.utils import timezone
23
from httmock import HTTMock, response, urlmatch
24
from utils import FakedResponse, make_resource
26 25

  
27 26
from passerelle.apps.api_entreprise.models import APIEntreprise
28 27

  
29
from utils import make_resource, FakedResponse
30

  
31 28
ETABLISSEMENTS_RESPONSE = {
32 29
    "etablissement": {
33 30
        "siege_social": True,
34 31
        "siret": "41816609600051",
35 32
        "naf": "6202A",
36 33
        "libelle_naf": "Conseil en systèmes et logiciels informatiques",
37 34
        "date_mise_a_jour": 1449183600,
38 35
        "tranche_effectif_salarie_etablissement": {
tests/test_api_particulier.py
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19 19
import logging
20
import pytest
21
from httmock import urlmatch, HTTMock, response
22

  
23
from django.urls import reverse
24 20

  
21
import pytest
25 22
import requests
23
from django.urls import reverse
24
from httmock import HTTMock, response, urlmatch
25
from test_manager import login
26
from utils import endpoint_get, make_resource
26 27

  
27 28
from passerelle.apps.api_particulier.models import APIParticulier
28 29
from passerelle.base.models import ResourceLog
29 30

  
30
from utils import make_resource, endpoint_get
31

  
32
from test_manager import login
33

  
34

  
35 31
SVAIR_RESPONSE = {
36 32
    "declarant1": {
37 33
        "nom": "Martin",
38 34
        "nomNaissance": "Martin",
39 35
        "prenoms": "Pierre",
40 36
        "dateNaissance": "22/03/1985",
41 37
    },
42 38
    "declarant2": {
tests/test_arcgis.py
1 1
# -*- coding: utf-8 -*-
2 2
from __future__ import unicode_literals
3 3

  
4 4
import json
5
import pytest
5

  
6 6
import mock
7
import pytest
7 8
import utils
8

  
9 9
from django.contrib.auth.models import User
10 10
from django.contrib.contenttypes.models import ContentType
11 11
from django.core.exceptions import ValidationError
12
from test_manager import login
12 13

  
13
from passerelle.apps.arcgis.models import ArcGIS, validate_where, SqlFormatter, Query
14
from passerelle.base.models import ApiUser, AccessRight
14
from passerelle.apps.arcgis.models import ArcGIS, Query, SqlFormatter, validate_where
15
from passerelle.base.models import AccessRight, ApiUser
15 16
from passerelle.utils import import_site
16 17

  
17
from test_manager import login
18

  
19 18
pytestmark = pytest.mark.django_db
20 19

  
21 20
# from http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/fold/serv/MapServer/1
22 21
STATES = '''{
23 22
   "fieldAliases" : {
24 23
      "OBJECTID" : "OBJECTID",
25 24
      "STATE_NAME" : "STATE_NAME",
26 25
      "STATE_ABBR" : "STATE_ABBR"
tests/test_arcgis_nancy.py
1 1
import os
2 2

  
3
import pytest
4 3
import mock
5

  
6

  
7
from django.urls import reverse
4
import pytest
8 5
from django.contrib.contenttypes.models import ContentType
6
from django.urls import reverse
9 7

  
10 8
from passerelle.apps.arcgis.models import ArcGIS
9
from passerelle.base.models import AccessRight, ApiUser
11 10
from passerelle.compat import json_loads
12
from passerelle.base.models import ApiUser, AccessRight
13

  
14 11

  
15 12
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'nancy_arcgis')
16 13

  
17 14

  
18 15
def get_file_content(filename):
19 16
    with open(os.path.join(TEST_BASE_DIR, filename), 'rb') as fd:
20 17
        return fd.read()
21 18

  
tests/test_arpege_ecp.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import json
4

  
4 5
import mock
5 6
import pytest
6

  
7
import utils
7 8
from django.urls import reverse
8 9

  
9 10
from passerelle.apps.arpege_ecp.models import ArpegeECP
10 11
from passerelle.utils.jsonresponse import APIError
11 12

  
12
import utils
13

  
14 13
FAKE_HELLO_RESPONSE = """{"IsSuccess":true,"CodErreur":null,"LibErreur":null,
15 14
"Data":"InteropAPI v1 (c) Arpège 2017"}"""
16 15

  
17 16
FAKE_LOGIN_OIDC_RESPONSE = """{
18 17
  "IsSuccess": true,
19 18
  "CodErreur": null,
20 19
  "LibErreur": null,
21 20
  "Data": {
tests/test_astregs.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import os
4 3
import logging
5
import mock
6
import pytest
4
import os
7 5
import re
8 6

  
9
from requests.exceptions import ConnectionError
10
from requests import Request
11

  
7
import mock
8
import pytest
9
import utils
12 10
from django.utils.encoding import force_bytes, force_str, force_text
13 11
from django.utils.http import urlencode
12
from requests import Request
13
from requests.exceptions import ConnectionError
14 14

  
15 15
from passerelle.apps.astregs.models import AstreGS, Link
16 16

  
17
import utils
18

  
19 17
BASE_URL = 'https://test-ws-astre-gs.departement06.fr/axis2/services/'
20 18

  
21 19

  
22 20
def get_xml_file(filename):
23 21
    filepath = os.path.join(os.path.dirname(__file__), 'data', 'astregs', filename)
24 22
    with open(filepath, 'rb') as f:
25 23
        return f.read()
26 24

  
tests/test_atal.py
1 1
# coding: utf-8
2 2

  
3 3
import base64
4
from datetime import datetime
5 4
import os
5
from datetime import datetime
6 6

  
7
from django.contrib.contenttypes.models import ContentType
8
from django.utils.http import urlencode
9 7
import mock
10 8
import pytest
9
from django.contrib.contenttypes.models import ContentType
10
from django.utils.http import urlencode
11 11

  
12 12
from passerelle.apps.atal.models import ATALConnector
13
from passerelle.base.models import ApiUser, AccessRight
13
from passerelle.base.models import AccessRight, ApiUser
14 14

  
15 15

  
16 16
def get_file(filename):
17 17
    with open(os.path.join(os.path.dirname(__file__), 'data', 'atal', filename), 'rb') as f:
18 18
        return f.read()
19 19

  
20 20

  
21 21
@pytest.fixture()
tests/test_atos_genesys.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import os
4
import pytest
5 4

  
5
import pytest
6 6
import utils
7

  
8 7
from django.utils.http import urlencode
9 8

  
10
from passerelle.apps.atos_genesys.models import Resource, Link
9
from passerelle.apps.atos_genesys.models import Link, Resource
11 10

  
12 11
FAKE_URL = 'https://sirus.fr/'
13 12

  
14 13

  
15 14
@pytest.fixture
16 15
def genesys(db):
17 16
    return utils.make_resource(
18 17
        Resource, title='Test 1', slug='test1', description='Connecteur de test', webservice_base_url=FAKE_URL
......
216 215
        assert response.json['data']['id_per'] == '4567'
217 216
        assert response.json['data']['dossier']
218 217
        assert response.json['data']['id'] == str(link2.id)
219 218
        assert response.json['data']['text'] == u'%s - John DOE' % link2.id_per
220 219

  
221 220

  
222 221
def test_row_locked_cache(genesys, freezer):
223 222
    import time
223

  
224 224
    from passerelle.apps.atos_genesys.utils import RowLockedCache
225 225

  
226 226
    freezer.move_to('2018-01-01 00:00:00')
227 227
    link = Link.objects.create(resource=genesys, name_id='zob', id_per='4567')
228 228

  
229 229
    class F(object):
230 230
        calls = 0
231 231
        value = 1
tests/test_availability.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import pytest
4
from httmock import all_requests, HTTMock
4
import utils
5
from httmock import HTTMock, all_requests
5 6

  
6 7
from passerelle.apps.feeds.models import Feed
7 8

  
8
import utils
9

  
10 9
FEED_EXAMPLE = u"""<?xml version="1.0" encoding="UTF-8"?>
11 10
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/">
12 11
  <title>Actualités de Strasbourg</title>
13 12
  <link rel="alternate" href="http://www.strasbourg.eu/fr/actualites/-/asset_publisher/lG7u/rss" />
14 13
  <subtitle>Actualités de Strasbourg</subtitle>
15 14
  <entry>
16 15
    <title>30 juin - 1er juillet : conditions de circulation et de stationnement</title>
17 16
    <link rel="alternate" href="http://www.strasbourg.eu/fr/actualites/-/asset_publisher/lG7u/content/id/5722879" />
tests/test_base_adresse.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import datetime
4
import json
4 5
import os
5
import pytest
6

  
6 7
import mock
8
import pytest
7 9
import utils
8
import json
9

  
10
from requests.exceptions import ConnectionError, HTTPError
11

  
12 10
from django.core.management import call_command
13 11
from django.core.management.base import CommandError
14 12
from django.utils.six.moves.urllib.parse import urljoin
13
from requests.exceptions import ConnectionError, HTTPError
15 14

  
16 15
from passerelle.apps.base_adresse.models import (
16
    AddressCacheModel,
17 17
    BaseAdresse,
18
    StreetModel,
19 18
    CityModel,
20 19
    DepartmentModel,
21 20
    RegionModel,
22
    AddressCacheModel,
21
    StreetModel,
23 22
)
24 23

  
25 24
FAKED_CONTENT = json.dumps(
26 25
    {
27 26
        "limit": 1,
28 27
        "attribution": "BAN",
29 28
        "version": "draft",
30 29
        "licence": "ODbL 1.0",
tests/test_cartads_cs.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
from collections import OrderedDict
4 3
import datetime
5 4
import json
6 5
import os
6
from collections import OrderedDict
7 7

  
8 8
import mock
9
from httmock import HTTMock
10 9
import pytest
11

  
10
import utils
12 11
from django.core.files.storage import default_storage
13 12
from django.test import override_settings
13
from httmock import HTTMock
14 14

  
15
from passerelle.apps.cartads_cs.models import CartaDSCS, CartaDSFile, CartaDSDossier
16
from passerelle.compat import json_loads
15
from passerelle.apps.cartads_cs.models import CartaDSCS, CartaDSDossier, CartaDSFile
17 16
from passerelle.base.models import Job
18

  
19
import utils
17
from passerelle.compat import json_loads
20 18

  
21 19

  
22 20
@pytest.fixture
23 21
def connector(db):
24 22
    return utils.make_resource(
25 23
        CartaDSCS,
26 24
        title='Test',
27 25
        slug='test',
tests/test_cityweb.py
11 11
# but WITHOUT ANY WARRANTY; exclude even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
from __future__ import unicode_literals
18 18

  
19
import os
20 19
import json
20
import os
21 21
import shutil
22 22
import stat
23

  
24
import pytest
25
import mock
26
from lxml import etree, objectify as xobject
27 23
import zipfile
28 24

  
25
import mock
26
import pytest
29 27
import utils
28
from django.core.files.storage import default_storage
29
from lxml import etree
30
from lxml import objectify as xobject
30 31

  
31
from passerelle.apps.cityweb.models import CityWeb
32 32
from passerelle.apps.cityweb.cityweb import DateType
33
from passerelle.apps.cityweb.models import CityWeb
33 34
from passerelle.utils.jsonresponse import APIError
34 35

  
35
from django.core.files.storage import default_storage
36

  
37 36

  
38 37
def get_test_base_dir(name):
39 38
    return os.path.join(os.path.dirname(__file__), 'data', name)
40 39

  
41 40

  
42 41
def get_file_from_test_base_dir(filename):
43 42
    path = os.path.join(get_test_base_dir('cityweb'), filename)
44 43
    with open(path, 'r') as fd:
tests/test_clicrdv.py
1 1
import mock
2 2
import pytest
3

  
4
from requests.exceptions import HTTPError
5

  
6 3
from django.contrib.contenttypes.models import ContentType
7 4
from django.utils.six.moves.urllib import parse as urlparse
5
from requests.exceptions import HTTPError
6
from test_manager import login
8 7

  
9
from passerelle.base.models import ApiUser, AccessRight
10 8
from passerelle.apps.clicrdv.models import ClicRdv
11

  
12
from test_manager import login
9
from passerelle.base.models import AccessRight, ApiUser
13 10

  
14 11

  
15 12
@pytest.fixture
16 13
def connector(db):
17 14
    return ClicRdv.objects.create(
18 15
        slug='test', group_id='5242', apikey='test', username='test', password='test'
19 16
    )
20 17

  
tests/test_cmis.py
1 1
import base64
2
import httplib2
3
import xml.etree.ElementTree as ET
4
import mock
5 2
import os
6 3
import re
4
import xml.etree.ElementTree as ET
7 5

  
6
import httplib2
7
import mock
8
import py
9
import pytest
8 10
from cmislib import CmisClient
9
from cmislib.exceptions import CmisException
10
from cmislib.exceptions import ObjectNotFoundException
11
from cmislib.exceptions import PermissionDeniedException
12
from cmislib.exceptions import UpdateConflictException
13
from cmislib.exceptions import InvalidArgumentException
11
from cmislib.exceptions import (
12
    CmisException,
13
    InvalidArgumentException,
14
    ObjectNotFoundException,
15
    PermissionDeniedException,
16
    UpdateConflictException,
17
)
14 18
from django.contrib.contenttypes.models import ContentType
15 19
from django.urls import reverse
16 20
from django.utils.encoding import force_bytes, force_text
17 21
from django.utils.six.moves.urllib import error as urllib2
18
from mock import call, Mock
19
import py
20
import pytest
22
from mock import Mock, call
23
from test_manager import login
21 24

  
22
from passerelle.base.models import ApiUser, AccessRight
23 25
from passerelle.apps.cmis.models import CmisConnector
24

  
25
from test_manager import login
26
from passerelle.base.models import AccessRight, ApiUser
26 27

  
27 28

  
28 29
def b64encode(content):
29 30
    return force_text(base64.b64encode(force_bytes(content)))
30 31

  
31 32

  
32 33
@pytest.fixture()
33 34
def setup(db):
......
412 413
        (urllib2.URLError, "connection error"),
413 414
        (PermissionDeniedException, "permission denied"),
414 415
        (UpdateConflictException, "update conflict"),
415 416
        (InvalidArgumentException, "invalid property"),
416 417
        (CmisException, "cmis binding error"),
417 418
    ],
418 419
)
419 420
def test_wrap_cmis_error(app, setup, monkeypatch, cmis_exc, err_msg):
420
    from passerelle.utils.jsonresponse import APIError
421 421
    from passerelle.apps.cmis.models import wrap_cmis_error
422
    from passerelle.utils.jsonresponse import APIError
422 423

  
423 424
    @wrap_cmis_error
424 425
    def dummy_func():
425 426
        raise cmis_exc("some error")
426 427

  
427 428
    with pytest.raises(APIError) as excinfo:
428 429
        dummy_func()
429 430
    assert str(excinfo.value).startswith(err_msg)
tests/test_cron.py
1 1
import mock
2 2
import pytest
3

  
4 3
from django.core.management import call_command
5 4
from django.core.management.base import CommandError
6 5

  
7 6
from passerelle.apps.base_adresse.models import BaseAdresse
8 7

  
9 8

  
10 9
def test_cron_frequencies(db):
11 10
    for frequency in ('hourly', 'daily', 'weekly', 'monthly'):
tests/test_cryptor.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import base64
4
import pytest
5 4

  
5
import pytest
6
import utils
6 7
from django.contrib.contenttypes.models import ContentType
7 8
from django.core.exceptions import ValidationError
8 9
from django.utils.encoding import force_text
9 10

  
10
from passerelle.apps.cryptor.models import Cryptor, CryptedFile
11
from passerelle.base.models import ApiUser, AccessRight
12

  
13
import utils
11
from passerelle.apps.cryptor.models import CryptedFile, Cryptor
12
from passerelle.base.models import AccessRight, ApiUser
14 13

  
15 14
PUBLIC_KEY = '''-----BEGIN CERTIFICATE-----
16 15
MIICyjCCAbKgAwIBAgIUQQzM2eFYF+LpUR3t2euAjZAwLCEwDQYJKoZIhvcNAQEL
17 16
BQAwDzENMAsGA1UEAwwEemVwbzAeFw0xOTA2MjIyMjMxMTVaFw0yOTA2MTkyMjMx
18 17
MTVaMA8xDTALBgNVBAMMBHplcG8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
19 18
AoIBAQC8BM3xDylze0bOm76IjidyhmFqJlnRvcpbeZVTM7r3qYOHqXFG7/GZL4yd
20 19
2bW5eL6TCUT3gLEgegGYGPwCkGPd1cq9h+2M7zvolGToRCvrBpxH5Vu6iRkEYyWN
21 20
yPhc02EUqYlz1FBBYRgyYHQ4jy0vsPH55g536OKLI4rVykszjwD9p0Kh+T2I1D9Z
tests/test_csv_datasource.py
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19 19
import datetime
20 20
import os
21 21
import time
22
import pytest
23
import mock
24
import six
25 22
import uuid
26 23
from posix import stat_result
27 24
from stat import ST_MTIME
28 25

  
29
from django.core.files import File
30
from django.urls import reverse
26
import mock
27
import pytest
28
import six
29
import webtest
31 30
from django.contrib.contenttypes.models import ContentType
32
from django.test import Client, override_settings
31
from django.core.files import File
33 32
from django.core.management import call_command
33
from django.test import Client, override_settings
34
from django.urls import reverse
34 35
from django.utils.encoding import force_bytes, force_str, force_text
35 36
from django.utils.six import StringIO
36 37
from django.utils.six.moves.urllib.parse import urlencode
37 38
from django.utils.timezone import now
38

  
39
from passerelle.base.models import ApiUser, AccessRight
40
from passerelle.compat import json_loads
41
from passerelle.apps.csvdatasource.models import CsvDataSource, Query, TableRow
42

  
43 39
from test_manager import login
44 40

  
45
import webtest
41
from passerelle.apps.csvdatasource.models import CsvDataSource, Query, TableRow
42
from passerelle.base.models import AccessRight, ApiUser
43
from passerelle.compat import json_loads
46 44

  
47 45
data = """121;69981;DELANOUE;Eliot;H
48 46
525;6;DANIEL WILLIAMS;Shanone;F
49 47
253;67742;MARTIN;Sandra;F
50 48
511;38142;MARCHETTI;Lucie;F
51 49
235;22;MARTIN;Sandra;F
52 50
620;52156;ARNAUD;Mathis;H
53 51
902;36;BRIGAND;Coline;F
tests/test_dpark.py
1 1
# -*- coding: utf-8 -*-
2 2
import base64
3
import mock
4 3
import os
5
import pytest
6 4
import xml.etree.ElementTree as ET
7 5

  
8
from django.utils.encoding import force_text
9 6
import httmock
10

  
11
from zeep.exceptions import TransportError, Fault as WebFault
12

  
7
import mock
8
import pytest
9
from django.utils.encoding import force_text
13 10
from utils import make_resource
11
from zeep.exceptions import Fault as WebFault
12
from zeep.exceptions import TransportError
14 13

  
15 14
from passerelle.contrib.dpark.models import DPark, Pairing
16 15
from passerelle.utils.jsonresponse import APIError
17 16

  
18

  
19 17
SLUG = 'test'
20 18
WSDL_URL = 'https://example.net/dpark?wsdl'
21 19
OPERATIONAL_URL = 'https://example.net/dpark'
22 20

  
23 21
with open(os.path.join(os.path.dirname(__file__), 'data/dpark.awws.wsdl')) as f:
24 22
    WSDL_CONTENT = f.read()
25 23

  
26 24
with open(os.path.join(os.path.dirname(__file__), 'data/small.jpg'), 'rb') as f:
tests/test_ensure_jsonbfields.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import pytest
4

  
5 4
from django.core.files import File
6 5
from django.core.management import call_command
7 6
from django.db import connection
8 7
from django.utils.six import BytesIO
9 8

  
10 9
from passerelle.apps.csvdatasource.models import CsvDataSource
11 10
from passerelle.contrib.teamnet_axel.models import TeamnetAxel
12 11

  
tests/test_esirius.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import json
18

  
18 19
import httmock
19 20
import pytest
21
import utils
22
from test_manager import login
20 23

  
21 24
from passerelle.apps.esirius.models import ESirius
22 25
from passerelle.utils.jsonresponse import APIError
23 26

  
24
from test_manager import login
25
import utils
26

  
27

  
28 27
CREATE_APPOINTMENT_PAYLOAD = {
29 28
    'beginDate': '2021-02-24',
30 29
    'beginTime': '16:40',
31 30
    'endDate': '2021-02-24',
32 31
    'endTime': '17:00',
33 32
    'comment': 'commentaire',
34 33
    'isoLanguage': 'fr',
35 34
    'needsConfirmation': 'False',
tests/test_fake_family.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import json
4 4

  
5
import pytest
5 6
from django.urls import reverse
6 7

  
7
import pytest
8 8
from passerelle.contrib.fake_family.models import FakeFamily
9 9

  
10 10
pytestmark = pytest.mark.django_db
11 11

  
12 12

  
13 13
def test_init_fake_family():
14 14
    fake = FakeFamily.objects.create()
15 15
    jsondb = fake.jsondatabase
tests/test_family.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import pytest
4
import os
5
from uuid import uuid4
6
import zipfile
7 3
import logging
4
import os
8 5
import shutil
6
import zipfile
7
from uuid import uuid4
9 8

  
9
import pytest
10
from django.contrib.contenttypes.models import ContentType
10 11
from django.core.exceptions import ValidationError
11 12
from django.core.files import File
13
from django.core.files.storage import default_storage
14
from django.core.management import call_command
15
from django.core.management.base import CommandError
12 16
from django.urls import reverse
13 17
from django.utils import timezone
14 18
from django.utils.http import urlencode
15
from django.core.files import File
16
from django.core.management import call_command
17
from django.core.management.base import CommandError
18
from django.core.files.storage import default_storage
19

  
20
from passerelle.apps.family.models import GenericFamily, Family, FamilyLink
21
from passerelle.apps.family.models import Invoice, Adult, Child, DATETIME_FORMAT
22

  
23
from django.core.files import File
24
from django.contrib.contenttypes.models import ContentType
25

  
26
from passerelle.base.models import ApiUser, AccessRight
27 19

  
20
from passerelle.apps.family.models import (
21
    DATETIME_FORMAT,
22
    Adult,
23
    Child,
24
    Family,
25
    FamilyLink,
26
    GenericFamily,
27
    Invoice,
28
)
29
from passerelle.base.models import AccessRight, ApiUser
28 30

  
29 31
pytestmark = pytest.mark.django_db
30 32

  
31 33
nameid = 'foobarnameid'
32 34
API_KEY = 'family'
33 35

  
34 36

  
35 37
@pytest.fixture
tests/test_feeds.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import mock
4 4
import pytest
5
import utils
5 6

  
6 7
from passerelle.apps.feeds.models import Feed
7 8

  
8
import utils
9

  
10 9
FEED_EXAMPLE = u"""<?xml version="1.0" encoding="UTF-8"?>
11 10
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/">
12 11
  <title>Actualités de Strasbourg</title>
13 12
  <link rel="alternate" href="http://www.strasbourg.eu/fr/actualites/-/asset_publisher/lG7u/rss" />
14 13
  <subtitle>Actualités de Strasbourg</subtitle>
15 14
  <entry>
16 15
    <title>30 juin - 1er juillet : conditions de circulation et de stationnement</title>
17 16
    <link rel="alternate" href="http://www.strasbourg.eu/fr/actualites/-/asset_publisher/lG7u/content/id/5722879" />
tests/test_gdema.py
1 1
# -*- coding: utf-8 -*-
2 2
import json
3
import pytest
3

  
4 4
import mock
5
import pytest
5 6
import utils
6

  
7 7
from django.contrib.contenttypes.models import ContentType
8 8

  
9
from passerelle.base.models import AccessRight, ApiUser
9 10
from passerelle.contrib.gdema.models import Gdema
10
from passerelle.base.models import ApiUser, AccessRight
11

  
12 11

  
13 12
SERVICES = '[{"AdminService":"ADMINISTRATEUR DIV - Transports et D\xc3\xa9placements","CommuneService":null,"Id":"16151","Label":"DMT - Mobilité et transports","Typology":[]},{"AdminService":"ADMINISTRATEUR DEP ADMINISTRATION","CommuneService":null,"Id":"10173","Label":"DESPU - Administration Direction environnement et services publics urbains","Typology":[{"Text":"Maintenance Cie","Value":"13067"},{"Text":"Sensibilisation en milieu scolaire","Value":"14948"},{"Text":"Demandes diverses","Value":"11532"},{"Text":"Demande de stage compostage","Value":"12992"},{"Text":"Pr\xc3\xa9sence de d\xc3\xa9chets verts","Value":"20432"}]},{"AdminService":"ADMINISTRATEUR DED3","CommuneService":null,"Id":"10426","Label":"DEE - Périscolaire et éducatif","Typology":[{"Text":"Activités périscolaires","Value":"10804"},{"Text":"Garderie","Value":"10805"},{"Text":"Restauration scolaire","Value":"10806"},{"Text":"Restauration scolaire \\/ Nutrition","Value":"11180"},{"Text":"Restauration scolaire \\/ Abonnements \\/cantine et r\xc3\xa9gie","Value":"10807"},{"Text":"Projets éducatifs en temps scolaire","Value":"10808"},{"Text":"Autres","Value":"10809"}]}]'
14 13

  
15 14
CIVILITY = (
16 15
    '[{"Text":"Monsieur","Value":"1"},{"Text":"Madame","Value":"2"},{"Text":"Mademoiselle","Value":"3"}]'
17 16
)
18 17

  
19 18
REQUEST = r'{"AnswerToProvide":true,"AssigmentServiceName":"DEPE - Projets et maintenance du patrimoine","AssigmentStructure":"Cellule Travaux","AssociationId":0,"ClosingDate":"/Date(1306314926000+0200)/","Confidential":false,"DataEntryService":"Education","Description":"contrôle de toutes les portes extérieures des classes - gonds faibles pour le poids de la porte(N° 11353 v1)","DesiredResponseDate":null,"ExpectedDate":null,"ExpectedInterventionDate":null,"Files":[],"Handler":{"CUSStreetCode":null,"Cedex":null,"CellPhone":null,"Civility":null,"CivilityId":0,"Fax":null,"Firstname":null,"Information":null,"Lastname":"ANONYME","Mail":null,"Organization":0,"Phone":null,"SectionCode":null,"SectionLetter":null,"Street":null,"StreetLetter":null,"StreetNumber":null,"StructureLabel":null,"StructureShortLabel":null,"Title":null,"TitleId":0,"Town":null,"TownLabel":null,"ZipCode":null},"Id":1,"InputChannel":"Courrier","Localization":{"AdditionnalInformation":null,"CUSStreetCode":"2075","ElectedDistrict":"006","JobSector":null,"Other":"(sous-localisation : Bâtiment)","SectionCode":"1","SectionLetter":"_","Site":"Conseil","SiteId":1790,"Street":"RUE DE LA PLACE","StreetLetter":null,"StreetNumber":"2","TerritorialSector":"105","Town":"482","TownLabel":"STRASBOURG","ZipCode":"67000"},"Origin":2,"OriginLabel":"Usager","Priority":2,"PriorityLabel":"Normal","ReceptDate":"/Date(1165964400000+0100)/","Refused":false,"ReleaseDate":null,"Response":false,"ResponseFinal":true,"ResponseIntermediate":false,"Responses":[{"Date":"/Date(1306274400000+0200)/","OutputChannel":"Service X","Resume":"Intervention réalisée","SibeliusReference":null,"SignatureName":"UC","Type":2,"TypeLabel":"Finale"}],"SibeliusReference":null,"SiteCode":null,"SiteName":"Conseil","Sleeping":null,"State":64,"StateLabel":"Cloturée","Structure":"Cellule Travaux","Syscreationdate":"/Date(1165186800000+0100)/","Sysmodificationdate":"/Date(1306314926000+0200)/","Typology":{"Id":11168,"Label":"Maintenance"}}'
tests/test_generic_endpoint.py
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20 20
import copy
21
import os
22 21
import json
22
import os
23 23
import random
24 24
import warnings
25 25

  
26 26
import mock
27 27
import pytest
28

  
29 28
import utils
30

  
31 29
from django.contrib.contenttypes.models import ContentType
32 30
from django.urls import reverse
31
from test_manager import login
33 32

  
34
from passerelle.apps.arcgis.models import ArcGIS
35 33
from passerelle.apps.api_particulier.models import APIParticulier
36
from passerelle.base.models import ResourceLog, ProxyLogger, BaseResource, HTTPResource, LoggingParameters
37
from passerelle.base.models import ResourceStatus
34
from passerelle.apps.arcgis.models import ArcGIS
38 35
from passerelle.apps.mdel.models import MDEL
36
from passerelle.base.models import (
37
    BaseResource,
38
    HTTPResource,
39
    LoggingParameters,
40
    ProxyLogger,
41
    ResourceLog,
42
    ResourceStatus,
43
)
39 44
from passerelle.contrib.stub_invoices.models import StubInvoicesConnector
40 45
from passerelle.utils.api import endpoint
41 46

  
42
from test_manager import login
43

  
44 47

  
45 48
@pytest.fixture
46 49
def mdel(db):
47 50
    return utils.setup_access_rights(MDEL.objects.create(slug='test'))
48 51

  
49 52

  
50 53
@pytest.fixture
51 54
def arcgis(db):
......
668 671
    # to the other
669 672
    json_res = app.get('/stub-invoices/fake/httpcall').json
670 673
    assert json_res['cookie1'] is None
671 674
    assert json_res['cookie2'] == 'foo=bar'
672 675

  
673 676

  
674 677
def test_https_warnings(app, db, monkeypatch, httpbin_secure, relax_openssl):
675 678
    from requests.exceptions import SSLError
679

  
676 680
    from passerelle.apps.arcgis.models import ArcGIS
677 681

  
678 682
    resource = utils.make_resource(ArcGIS, base_url='https://example.com/', slug='gis', verify_cert=True)
679 683
    with pytest.raises(SSLError):
680 684
        resource.requests.get(httpbin_secure.join('/get/'))
681 685
    resource.verify_cert = False
682 686
    with warnings.catch_warnings():
683 687
        warnings.simplefilter('error')
tests/test_gesbac.py
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU Affero General Public License for more details.
15 15
#
16 16
# You should have received a copy of the GNU Affero General Public License
17 17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18

  
19 19
import datetime
20
import pytest
21 20

  
22
from django.utils.timezone import now
21
import pytest
23 22
from django.utils.encoding import force_bytes, force_str, force_text
23
from django.utils.timezone import now
24 24
from utils import make_resource
25 25

  
26
from passerelle.apps.gesbac.models import Form, Gesbac
26 27
from passerelle.utils import SFTP
27
from passerelle.apps.gesbac.models import Gesbac, Form
28 28

  
29 29

  
30 30
@pytest.fixture
31 31
def resource(db, sftpserver):
32 32
    return make_resource(
33 33
        Gesbac,
34 34
        slug='test',
35 35
        title='Gesbac',
tests/test_grandlyon_streetsections.py
1
import pytest
1 2
from django.contrib.contenttypes.models import ContentType
2

  
3 3
from httmock import HTTMock
4
import pytest
5 4

  
6
from passerelle.base.models import ApiUser, AccessRight
5
from passerelle.base.models import AccessRight, ApiUser
7 6
from passerelle.contrib.grandlyon_streetsections.models import (
8 7
    GrandLyonStreetSections,
9 8
    StreetSection,
10 9
    normalize_street,
11 10
)
12 11

  
13 12

  
14 13
@pytest.fixture()
tests/test_greco.py
8 8
# This program is distributed in the hope that it will be useful,
9 9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16
from base64 import b64encode
17 16
import copy
18 17
import os
19
import pytest
20
import mock
21
import utils
22 18
import xml.etree.ElementTree as ET
19
from base64 import b64encode
23 20

  
21
import mock
22
import pytest
23
import utils
24 24
from django.contrib.contenttypes.models import ContentType
25 25
from django.urls import reverse
26 26
from django.utils.encoding import force_str
27 27

  
28
from passerelle.base.models import ApiUser, AccessRight
28
from passerelle.base.models import AccessRight, ApiUser
29 29
from passerelle.contrib.greco.models import Greco
30 30

  
31 31
pytestmark = pytest.mark.django_db
32 32

  
33 33

  
34 34
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'greco')
35 35
WSDL_FILENAME = os.path.join(TEST_BASE_DIR, 'greco.wsdl')
36 36

  
tests/test_grenoble_gru.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import json
19 19
import os
20

  
20 21
import mock
21 22
import pytest
22 23
import six
23

  
24 24
import utils
25

  
26 25
from django.urls import reverse
27 26

  
28 27
from passerelle.contrib.grenoble_gru.models import GrenobleGRU
29 28

  
30 29

  
31 30
@pytest.fixture
32 31
def setup(db):
33 32
    return utils.setup_access_rights(
tests/test_import_export.py
1 1
# -*- coding: utf-8 -*-
2
import sys
3 2
import json
4 3
import os
5
import pytest
4
import sys
6 5
import tempfile
7 6

  
7
import pytest
8
from django.contrib.contenttypes.models import ContentType
8 9
from django.core.files import File
9
from django.urls import reverse
10 10
from django.core.management import call_command
11
from django.contrib.contenttypes.models import ContentType
12 11
from django.test import Client
12
from django.urls import reverse
13 13
from django.utils import timezone
14 14
from django.utils.encoding import force_bytes, force_text
15 15
from django.utils.six import BytesIO, StringIO
16 16

  
17 17
from passerelle.apps.base_adresse.models import BaseAdresse
18 18
from passerelle.apps.ovh.models import OVHSMSGateway
19
from passerelle.base.models import ApiUser, AccessRight
19
from passerelle.base.models import AccessRight, ApiUser
20 20
from passerelle.compat import json_loads
21
from passerelle.utils import import_site, export_site
21
from passerelle.utils import export_site, import_site
22 22

  
23 23
data = """121;69981;DELANOUE;Eliot;H
24 24
525;6;DANIEL WILLIAMS;Shanone;F
25 25
253;67742;MARTIN;Sandra;F
26 26
511;38142;MARCHETTI;Lucie;F
27 27
235;22;MARTIN;Sandra;F
28 28
620;52156;ARNAUD;Mathis;H
29 29
902;36;BRIGAND;Coline;F
......
39 39
4809;75;COROLLER;Maelys;F
40 40
5427;117;KANTE;Aliou;H
41 41
116642;118;ZAHMOUM;Yaniss;H
42 42
216352;38;Dupont;Benoît;H
43 43
"""
44 44

  
45 45
data_bom = force_text(data, 'utf-8').encode('utf-8-sig')
46 46

  
47
from passerelle.apps.csvdatasource.models import CsvDataSource, Query
48 47
from passerelle.apps.bdp.models import Bdp
48
from passerelle.apps.csvdatasource.models import CsvDataSource, Query
49 49

  
50 50
pytestmark = pytest.mark.django_db
51 51

  
52 52
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'csvdatasource')
53 53

  
54 54

  
55 55
def get_file_content(filename):
56 56
    return open(os.path.join(TEST_BASE_DIR, filename), 'rb').read()
tests/test_iparapheur.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import pytest
4
import mock
5
import uuid
6
import os
7 3
import base64
4
import os
5
import uuid
8 6
import xml.etree.ElementTree as ET
9
from dateutil import parser
10
from requests import Response
11 7

  
12
from requests.exceptions import ConnectionError
13
from django.urls import reverse
8
import mock
9
import pytest
10
from dateutil import parser
14 11
from django.contrib.contenttypes.models import ContentType
12
from django.urls import reverse
15 13
from django.utils import timezone
16 14
from django.utils.encoding import force_bytes
15
from requests import Response
16
from requests.exceptions import ConnectionError
17 17

  
18
from passerelle.base.models import ApiUser, AccessRight
18
from passerelle.base.models import AccessRight, ApiUser
19 19
from passerelle.contrib.iparapheur.models import IParapheur
20 20

  
21 21
pytestmark = pytest.mark.django_db
22 22

  
23 23
BASE_URL = 'https://secure-iparapheur.demonstrations.adullact.org:443/ws-iparapheur'
24 24
WSDL_URL = '%s?wsdl' % BASE_URL
25 25
API_KEY = 'iparapheur'
26 26
SOAP_NAMESPACES = {
tests/test_isere_ens.py
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18

  
19 19
import json
20 20
import os
21

  
21 22
import mock
22 23
import pytest
23

  
24 24
import utils
25

  
26 25
from django.urls import reverse
27 26

  
28 27
from passerelle.contrib.isere_ens.models import IsereENS
29 28
from passerelle.utils.jsonresponse import APIError
30 29

  
31 30

  
32 31
@pytest.fixture
33 32
def setup(db):
tests/test_iws.py
1
import pytest
1 2
from django.contrib.contenttypes.models import ContentType
2 3
from mock import Mock
3
import pytest
4 4

  
5
from passerelle.base.models import ApiUser, AccessRight
5
from passerelle.base.models import AccessRight, ApiUser
6 6
from passerelle.contrib.iws.models import IWSConnector
7 7

  
8 8

  
9 9
@pytest.fixture()
10 10
def setup(db):
11 11
    api = ApiUser.objects.create(username='all', keytype='', key='')
12 12
    conn = IWSConnector.objects.create(
13 13
        wsdl_url='http://example.com/iws?wsdl',
tests/test_jobs.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import datetime
4 4
import os
5 5

  
6
from django.core.management import call_command
7

  
6
import isodate
8 7
import mock
9 8
import pytest
10

  
11 9
import utils
10
from django.core.management import call_command
11
from test_base_adresse import StreetModel, base_adresse
12 12

  
13
import isodate
14

  
15

  
16
from passerelle.base.models import Job, SkipJob, ResourceLog
17

  
18
from test_base_adresse import base_adresse, StreetModel
13
from passerelle.base.models import Job, ResourceLog, SkipJob
19 14

  
20 15

  
21 16
@mock.patch('passerelle.utils.Request.get')
22 17
def test_jobs(mocked_get, app, base_adresse, freezer):
23 18
    Job.objects.all().delete()  # remove jobs automatically added at connector creation
24 19
    filepath = os.path.join(os.path.dirname(__file__), 'data', 'update_streets_test.gz')
25 20
    with open(filepath, 'rb') as ban_file:
26 21
        mocked_get.return_value = utils.FakedResponse(content=ban_file.read(), status_code=200)
tests/test_jsondatastore.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import pytest
4

  
5 4
from django.contrib.contenttypes.models import ContentType
6 5
from django.core.serializers.json import DjangoJSONEncoder
7 6

  
8
from passerelle.apps.jsondatastore.models import JsonDataStore, JsonData
9
from passerelle.base.models import ApiUser, AccessRight
7
from passerelle.apps.jsondatastore.models import JsonData, JsonDataStore
8
from passerelle.base.models import AccessRight, ApiUser
10 9

  
11 10

  
12 11
@pytest.fixture
13 12
def jsondatastore(db):
14 13
    datastore = JsonDataStore.objects.create(slug='foobar')
15 14
    api = ApiUser.objects.create(username='all', keytype='', key='')
16 15
    obj_type = ContentType.objects.get_for_model(datastore)
17 16
    AccessRight.objects.create(
tests/test_jsonresponse.py
1 1
import logging
2
import pytest
3 2

  
4
from django.test.client import RequestFactory
5
from django.http import Http404
3
import pytest
6 4
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
5
from django.http import Http404
6
from django.test.client import RequestFactory
7 7

  
8 8
from passerelle.compat import json_loads
9 9
from passerelle.utils import to_json
10 10

  
11 11

  
12 12
class WrappedException(Exception):
13 13
    pass
14 14

  
tests/test_lille_kimoce.py
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18

  
19 19
import json
20 20
import os
21

  
21 22
import mock
22 23
import pytest
23

  
24 24
import utils
25

  
26 25
from django.urls import reverse
27 26

  
28 27
from passerelle.contrib.lille_kimoce.models import Kimoce
29 28
from passerelle.utils.jsonresponse import APIError
30 29

  
31 30

  
32 31
@pytest.fixture
33 32
def setup(db):
tests/test_lille_urban_card.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
from httmock import HTTMock
4 3
import json
4

  
5 5
import mock
6 6
import pytest
7
import utils
8
from httmock import HTTMock
7 9

  
8 10
from passerelle.compat import json_loads
9 11
from passerelle.contrib.lille_urban_card.models import LilleUrbanCard
10 12
from passerelle.utils.jsonresponse import APIError
11 13

  
12
import utils
13

  
14 14

  
15 15
@pytest.fixture
16 16
def connector(db):
17 17
    return utils.setup_access_rights(
18 18
        LilleUrbanCard.objects.create(
19 19
            slug='test', base_url='http://localhost', username='test', password='secret'
20 20
        )
21 21
    )
tests/test_maelis.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3 3
import json
4
import mock
5 4
import os
6
import pytest
7 5

  
6
import mock
7
import pytest
8
import utils
8 9
from django.test import override_settings
9 10
from django.utils.dateparse import parse_date
10 11

  
11
from passerelle.apps.maelis.models import Maelis, Link
12
from passerelle.apps.maelis.models import Link, Maelis
12 13
from passerelle.apps.maelis.utils import (
14
    decompose_event,
13 15
    get_school_year,
14
    week_boundaries_datetimes,
15 16
    month_range,
16
    decompose_event,
17
    week_boundaries_datetimes,
17 18
)
18

  
19 19
from passerelle.utils.jsonresponse import APIError
20 20

  
21
import utils
22

  
23 21
pytestmark = pytest.mark.django_db
24 22

  
25 23
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'maelis')
26 24

  
27 25

  
28 26
def get_xml_file(filename):
29 27
    with open(os.path.join(TEST_BASE_DIR, filename), 'rb') as desc:
30 28
        return desc.read()
tests/test_manager.py
1 1
import datetime
2 2
import re
3 3
import uuid
4 4

  
5
from webtest import Upload
6

  
5
import freezegun
6
import pytest
7 7
from django.contrib.contenttypes.models import ContentType
8 8
from django.core.files import File
9 9
from django.utils.six import StringIO
10 10
from django.utils.timezone import now
11
from webtest import Upload
11 12

  
12
import freezegun
13
import pytest
14

  
15
from passerelle.base.models import ApiUser, AccessRight, ResourceStatus, Job, ResourceLog
16 13
from passerelle.apps.csvdatasource.models import CsvDataSource, Query
17 14
from passerelle.apps.photon.models import Photon
15
from passerelle.base.models import AccessRight, ApiUser, Job, ResourceLog, ResourceStatus
18 16

  
19 17
pytestmark = pytest.mark.django_db
20 18

  
21 19

  
22 20
def login(app, username='admin', password='admin'):
23 21
    login_page = app.get('/login/')
24 22
    login_form = login_page.forms[0]
25 23
    login_form['username'] = username
tests/test_mdel.py
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a.deepcopy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
from __future__ import unicode_literals
18 18

  
19
import shutil
20
import os
21 19
import base64
22 20
import copy
21
import os
22
import shutil
23 23
import zipfile
24

  
25 24
from xml.etree import ElementTree as etree
26
from lxml import etree as letree
27 25

  
28 26
import pytest
27
import utils
28
from lxml import etree as letree
29 29

  
30
from passerelle.apps.mdel.mdel import AttachedFile, Description, Message, get_resource_base_dir
30 31
from passerelle.apps.mdel.models import MDEL, Demand
31
from passerelle.apps.mdel.mdel import Message, Description, AttachedFile, get_resource_base_dir
32 32
from passerelle.apps.mdel.utils import parse_date
33 33
from passerelle.compat import json_loads
34 34
from passerelle.utils import SFTP
35 35

  
36
import utils
37

  
38 36
AEC_XSD = 'ActeEtatCivil-V1.A.xsd'
39 37
ILE_XSD = 'ILE_v1.1.xsd'
40 38

  
41 39

  
42 40
def get_mdel_base_dir():
43 41
    return os.path.join(os.path.dirname(__file__), 'data', 'mdel')
44 42

  
45 43

  
tests/test_mdel_ddpacs.py
18 18
from __future__ import unicode_literals
19 19

  
20 20
import io
21 21
import logging
22 22
import os
23 23

  
24 24
import pytest
25 25
import utils
26

  
27 26
import xmlschema
28 27

  
29
from passerelle.apps.mdel_ddpacs.models import Resource, Demand
30

  
28
from passerelle.apps.mdel_ddpacs.models import Demand, Resource
31 29
from passerelle.utils import json, sftp
32
from passerelle.utils.zip import diff_zip, ZipTemplate
30
from passerelle.utils.zip import ZipTemplate, diff_zip
33 31

  
34 32

  
35 33
def build_response_zip(**kwargs):
36 34
    zip_template = ZipTemplate(os.path.abspath('tests/data/mdel_ddpacs/response_manifest.json'), ctx=kwargs)
37 35
    return zip_template.name, zip_template.render_to_bytes()
38 36

  
39 37

  
40 38
@pytest.fixture(autouse=True)
tests/test_mdph13.py
10 10
# This program is distributed in the hope that it will be useful,
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18
import json
19 18
import base64
20 19
import datetime
20
import json
21 21
import logging
22 22

  
23
import requests
24
import requests.exceptions
25

  
26 23
import httmock
27 24
import pytest
28

  
25
import requests
26
import requests.exceptions
29 27
import utils
30 28

  
29
from passerelle.contrib.mdph13.models import Link, MDPH13Resource
31 30
from passerelle.utils.jsonresponse import APIError
32
from passerelle.contrib.mdph13.models import MDPH13Resource, Link
33 31

  
34 32
NAME_ID = 'xyz'
35 33
FILE_NUMBER = '1234'
36 34
DOB = datetime.date(1993, 5, 4)
37 35
DOB_ISOFORMAT = '1993-05-04'
38 36
EMAIL = 'john.doe@example.com'
39 37
SECRET = 'secret'
40 38
IP = '88.34.56.56'
tests/test_misc.py
1 1
import datetime
2
import pytest
3
from mock import patch
4 2

  
3
import pytest
5 4
from django.contrib.contenttypes.models import ContentType
6 5
from django.core.files import File
7 6
from django.db import connection
8 7
from django.db.migrations.executor import MigrationExecutor
9 8
from django.urls import reverse
10 9
from django.utils import timezone
11 10
from django.utils.six import StringIO
11
from mock import patch
12
from test_manager import login
12 13

  
13
from passerelle.base.models import ResourceLog
14
from passerelle.apps.opengis.models import OpenGIS
15 14
from passerelle.apps.clicrdv.models import ClicRdv
16

  
17
from test_manager import login
15
from passerelle.apps.opengis.models import OpenGIS
16
from passerelle.base.models import ResourceLog
18 17

  
19 18

  
20 19
def test_get_description_url_fields(db):
21 20
    connector = OpenGIS(slug='plop', wms_service_url='http://www.example.net')
22 21
    assert 'http://www.example.net' in [x[1] for x in connector.get_description_fields()]
23 22

  
24 23
    connector = OpenGIS(slug='plop', wms_service_url='http://username:secret@www.example.net')
25 24
    assert 'http://***:***@www.example.net' in [x[1] for x in connector.get_description_fields()]
......
83 82
    resp.form.submit()
84 83
    connector.daily()
85 84
    assert ResourceLog.objects.all().count() == 1
86 85

  
87 86

  
88 87
@pytest.fixture
89 88
def email_handler():
90 89
    import logging
90

  
91 91
    from django.utils.log import AdminEmailHandler
92 92

  
93 93
    root = logging.getLogger()
94 94
    handler = AdminEmailHandler(include_html=True)
95 95
    handler.level = logging.ERROR
96 96
    root.handlers.append(handler)
97 97
    try:
98 98
        yield
tests/test_nancypoll.py
1 1
import pytest
2

  
3
from django.core.files import File
4
from django.urls import reverse
5 2
from django.contrib.contenttypes.models import ContentType
3
from django.core.files import File
6 4
from django.test import Client
5
from django.urls import reverse
7 6
from django.utils.six import StringIO
8 7

  
9
from passerelle.base.models import ApiUser, AccessRight
10

  
8
from passerelle.base.models import AccessRight, ApiUser
11 9
from passerelle.compat import json_loads
12 10
from passerelle.contrib.nancypoll.models import NancyPoll
13 11

  
14 12
data = """
15 13
0,999,,,S,A,Z,,34,28,ECOLE MATERNELLE DIDION,16 RUE SAINT THIEBAUT,,JOFFRE,BOULEVARD JOFFRE,4,NANCY 1,0,1083,1
16 14
0,121,,,I,A,Z,,46,3,GYMNASE MARTINY,10 RUE VICTOR,,LOBAU,BOULEVARD LOBAU,2,NANCY  3,0,1083,1
17 15
0,999,,,I,A,Z,,28,37,ECOLE MATERNELLE CHARLEMAGNE,RUE DU CHANOINE BLAISE,,BLANC,RUE DU CHEMIN BLANC,4,NANCY 1,0,1083,1
18 16
0,999,,,P,A,Z,,22,39,ECOLE MATERNELLE DE BUTHEGNEMONT,45 RUE ANNE FERIET,,BLANC,RUE DU CHEMIN BLANC,4,NANCY 1,0,1083,1
tests/test_okina.py
1 1
# -*- coding: utf-8 -*-
2 2
import json
3
import pytest
3

  
4 4
import mock
5
import pytest
5 6
import utils
6

  
7 7
from django.contrib.contenttypes.models import ContentType
8 8

  
9 9
from passerelle.apps.okina.models import Okina
10
from passerelle.base.models import ApiUser, AccessRight
11

  
10
from passerelle.base.models import AccessRight, ApiUser
12 11

  
13 12
CITIES = '''[ {
14 13
  "city" : 83355,
15 14
  "cityObject" : {
16 15
    "id" : 83355,
17 16
    "insee" : "36005",
18 17
    "nameCity" : "ARDENTES",
19 18
    "zipCode" : "36120",
tests/test_opendatasoft.py
10 10
# This program is distributed in the hope that it will be useful,
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18
import mock
19 18
import json
20
import pytest
21 19

  
20
import mock
21
import pytest
22 22
import utils
23

  
24 23
from django.contrib.auth.models import User
24
from test_manager import login
25 25

  
26 26
from passerelle.apps.opendatasoft.models import OpenDataSoft, Query
27 27
from passerelle.utils import import_site
28 28

  
29
from test_manager import login
30

  
31 29
pytestmark = pytest.mark.django_db
32 30

  
33 31

  
34 32
FAKED_CONTENT_Q_SEARCH = json.dumps(
35 33
    {
36 34
        "nhits": 76,
37 35
        "parameters": {
38 36
            "dataset": "referentiel-adresse-test",
tests/test_opengis.py
1 1
import json
2

  
2 3
import mock
3 4
import pytest
4

  
5
import utils
5 6
from django.contrib.auth.models import User
6 7
from django.core.management import call_command
8
from test_manager import login
7 9

  
8
from passerelle.apps.opengis.models import OpenGIS, Query, FeatureCache
10
from passerelle.apps.opengis.models import FeatureCache, OpenGIS, Query
9 11
from passerelle.base.models import Job
10 12
from passerelle.utils import import_site
11 13

  
12
from test_manager import login
13

  
14
import utils
15

  
16 14
pytestmark = pytest.mark.django_db
17 15

  
18 16
FAKE_FEATURE_INFO = '''<?xml version="1.0" encoding="UTF-8"?>
19 17
<msGMLOutput
20 18
      xmlns:gml="http://www.opengis.net/gml"
21 19
      xmlns:xlink="http://www.w3.org/1999/xlink"
22 20
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
23 21
  <cad_cadastre.cadparcelle_layer>
tests/test_orange.py
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import json
19 19

  
20 20
import httmock
21 21
import pytest
22

  
23 22
from django.contrib.contenttypes.models import ContentType
24 23
from django.utils.encoding import force_text
25 24

  
26
from passerelle.apps.orange.models import OrangeSMSGateway, OrangeError
27

  
28
from passerelle.base.models import ApiUser, AccessRight, Job
25
from passerelle.apps.orange.models import OrangeError, OrangeSMSGateway
26
from passerelle.base.models import AccessRight, ApiUser, Job
29 27
from passerelle.utils.jsonresponse import APIError
30 28

  
31

  
32 29
NETLOC = 'contact-everyone.orange-business.com'
33 30
JSON_HEADERS = {'content-type': 'application/json'}
34 31
PAYLOAD = {
35 32
    'message': 'hello',
36 33
    'from': '+33699999999',
37 34
    'to': ['+33688888888', '+33677777777'],
38 35
}
39 36

  
tests/test_phonecalls.py
1
import pytest
2
import utils
3 1
import re
4 2

  
3
import pytest
4
import utils
5 5
from django.contrib.contenttypes.models import ContentType
6 6
from django.utils.timezone import now, timedelta
7 7

  
8
from passerelle.apps.phonecalls.models import PhoneCalls, Call
9
from passerelle.base.models import ApiUser, AccessRight
8
from passerelle.apps.phonecalls.models import Call, PhoneCalls
9
from passerelle.base.models import AccessRight, ApiUser
10 10

  
11 11

  
12 12
@pytest.fixture
13 13
def phonecalls(db):
14 14
    phonecalls = PhoneCalls.objects.create(slug='test')
15 15
    apikey = ApiUser.objects.create(username='all', keytype='API', key='123')
16 16
    obj_type = ContentType.objects.get_for_model(phonecalls)
17 17
    AccessRight.objects.create(
tests/test_photon.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18
from httmock import urlmatch, HTTMock, response, remember_called
19 18
import json
19

  
20 20
import mock
21 21
import pytest
22 22
import utils
23

  
24
from requests.exceptions import HTTPError
25

  
26 23
from django.core.management import call_command
24
from httmock import HTTMock, remember_called, response, urlmatch
25
from requests.exceptions import HTTPError
27 26

  
28
from passerelle.apps.photon.models import Photon, AddressCacheModel
29

  
27
from passerelle.apps.photon.models import AddressCacheModel, Photon
30 28

  
31 29
CONTENT = {
32 30
    "features": [
33 31
        {
34 32
            "geometry": {"coordinates": [4.8522272, 45.7587414], "type": "Point"},
35 33
            "properties": {
36 34
                "city": "Lyon 3ème Arrondissement",
37 35
                "country": "France",
tests/test_planitech.py
1 1
import collections
2 2
from datetime import datetime
3 3

  
4
from django.contrib.contenttypes.models import ContentType
5
from django.core.cache import cache
6
from httmock import urlmatch, HTTMock
7 4
import mock
8 5
import pytest
9 6
import requests
7
from django.contrib.contenttypes.models import ContentType
8
from django.core.cache import cache
9
from httmock import HTTMock, urlmatch
10 10

  
11
from passerelle.base.models import ApiUser, AccessRight
11
from passerelle.base.models import AccessRight, ApiUser
12 12
from passerelle.contrib.planitech import mste
13
from passerelle.contrib.planitech.models import PlanitechConnector, Pairing, get_extensions
13
from passerelle.contrib.planitech.models import Pairing, PlanitechConnector, get_extensions
14 14
from passerelle.utils.jsonresponse import APIError
15 15

  
16 16

  
17 17
def assert_mste(data, ref_data):
18 18
    """skip CRC verification"""
19 19
    assert len(data) == len(ref_data)
20 20
    for i in range(len(data)):
21 21
        if i != 2:
tests/test_proxylogger.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import logging
4 3
import datetime
5 4
import itertools
5
import logging
6 6

  
7 7
import pytest
8
from httmock import HTTMock
9

  
8
import utils
10 9
from django.core.exceptions import ValidationError
11
from django.utils.six import PY2
12 10
from django.utils.log import AdminEmailHandler
11
from django.utils.six import PY2
12
from httmock import HTTMock
13
from test_availability import down_mock, up_mock
13 14

  
14
from passerelle.base.models import ProxyLogger, ResourceLog
15 15
from passerelle.apps.feeds.models import Feed
16
from passerelle.base.models import ProxyLogger, ResourceLog
16 17
from passerelle.contrib.stub_invoices.models import StubInvoicesConnector
17 18
from passerelle.utils.api import endpoint
18 19
from passerelle.utils.jsonresponse import APIError
19 20

  
20
from test_availability import down_mock, up_mock
21
import utils
22

  
23 21

  
24 22
@pytest.fixture
25 23
def connector():
26 24
    connector, created = Feed.objects.get_or_create(slug='some-slug')
27 25
    connector.set_log_level('DEBUG')
28 26
    connector.url = 'http://example.net/'
29 27
    connector.save()
30 28
    return connector
tests/test_requests.py
1 1
import logging
2 2

  
3
import pytest
4
import mohawk
5 3
import mock
4
import mohawk
5
import pytest
6 6
import requests
7

  
8
from httmock import urlmatch, HTTMock, response
9

  
7
import utils
10 8
from django.test import override_settings
9
from httmock import HTTMock, response, urlmatch
10
from utils import FakedResponse
11 11

  
12
from passerelle.utils import Request, CaseInsensitiveDict, log_http_request
12
from passerelle.utils import CaseInsensitiveDict, Request, log_http_request
13 13
from passerelle.utils.http_authenticators import HawkAuth
14
import utils
15
from utils import FakedResponse
16 14

  
17 15

  
18 16
class MockFileField(object):
19 17
    def __init__(self, path):
20 18
        self.path = path
21 19

  
22 20

  
23 21
class MockResource(object):
tests/test_rsa13.py
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import functools
19 19
import json
20 20
from urllib.parse import parse_qs
21 21

  
22 22
import httmock
23 23
import pytest
24

  
25 24
import utils
26 25

  
27 26
from passerelle.contrib.rsa13.models import RSA13Resource
28 27

  
29 28

  
30 29
@pytest.fixture
31 30
def rsa13(db):
32 31
    return utils.make_resource(
tests/test_sigerly.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import json
18 18
import os
19 19

  
20 20
import httmock
21 21
import pytest
22

  
23
from passerelle.contrib.sigerly.models import Sigerly
24

  
25 22
import utils
26 23

  
24
from passerelle.contrib.sigerly.models import Sigerly
27 25

  
28 26
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'sigerly')
29 27

  
30 28

  
31 29
@pytest.fixture
32 30
def connector(db):
33 31
    return utils.setup_access_rights(
34 32
        Sigerly.objects.create(slug='test', base_url='https://sigerly.example.net')
tests/test_sms.py
8 8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
import isodate
17 16
import json
18 17
import logging
18

  
19
import isodate
19 20
import mock
20 21
import pytest
21
from requests import RequestException
22

  
22
import utils
23 23
from django.conf import settings
24 24
from django.contrib.contenttypes.models import ContentType
25 25
from django.urls import reverse
26 26
from django.utils.translation import ugettext as _
27
from requests import RequestException
28
from test_manager import login
27 29

  
28 30
from passerelle.apps.choosit.models import ChoositSMSGateway
29 31
from passerelle.apps.ovh.models import OVHSMSGateway
30
from passerelle.base.models import ApiUser, AccessRight, Job, ResourceLog
31
from passerelle.sms.models import SMSResource, SMSLog
32
from passerelle.base.models import AccessRight, ApiUser, Job, ResourceLog
33
from passerelle.sms.models import SMSLog, SMSResource
32 34
from passerelle.utils.jsonresponse import APIError
33 35

  
34
from test_manager import login
35

  
36
import utils
37

  
38 36
pytestmark = pytest.mark.django_db
39 37

  
40 38
klasses = SMSResource.__subclasses__()
41 39

  
42 40

  
43 41
def test_clean_numbers():
44 42
    connector = OVHSMSGateway()
45 43
    assert connector.clean_numbers(['+ 33 12']) == ['003312']
tests/test_soap.py
8 8
# This program is distributed in the hope that it will be useful,
9 9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16
from django.utils.encoding import force_bytes
17
import pytest
18 16
import mock
17
import pytest
19 18
import requests
19
from django.utils.encoding import force_bytes
20 20
from zeep import Settings
21
from zeep.exceptions import TransportError, XMLParseError
21 22
from zeep.plugins import Plugin
22
from zeep.exceptions import XMLParseError, TransportError
23 23

  
24 24
from passerelle.utils.soap import SOAPClient
25 25

  
26

  
27 26
WSDL = 'tests/data/soap.wsdl'
28 27

  
29 28

  
30 29
class FooPlugin(Plugin):
31 30
    pass
32 31

  
33 32

  
34 33
class BarPlugin(Plugin):
tests/test_solis.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import pytest
4 3
import mock
4
import pytest
5 5
import utils
6

  
7 6
from django.contrib.contenttypes.models import ContentType
8 7
from django.core.files import File
9 8
from django.utils.six import StringIO
10 9

  
11 10
from passerelle.apps.solis.models import Solis, SolisAPALink, SolisRSALink, unflat
12
from passerelle.base.models import ApiUser, AccessRight
11
from passerelle.base.models import AccessRight, ApiUser
13 12

  
14 13
NAMEID = 'bebe'
15 14
APATOKEN = '''{"token":"1c2562e6-b0a9-4bcf-b669-e33a42397147","endDate":"2017-10-11T10:22:40.342"}'''
16 15
APATOKEN_403 = '''[{"logref":"db15cb8a-4d05-4e4f-b4e1-44ec39dc11e3","message":"Erreur d'authentification m\xc3\xa9tier ASG APA: Code confidentiel non valide pour l'individu 2823255","links":[]}]'''
17 16
APAINFOS = {
18 17
    'exportDonneesIndividu': '{"individu":{"civilite":"Mme","nomUsuel":"PYPPENNE","nomNaissance":"NPYNEZ","prenom":"Pecile","dateNaissance":"1922-12-17","contact":{"telephone":"0344480774","mail":""},"adresse":{"complementDestinataire":"compl dest","numeroLieu":"38","natureLieu":null,"nomLieu":"RUE MARTIN","complementLieu":"MARPA LES NACRES - APPARTEMENT 9","finLieu":"fin adresse","codePostal":"80370","commune":"BERNAVILLE"},"tutelles":{"tutelle":[{"type":"Organisme","identite":"Association Tut\xc3\xa9laire de la  Somme","mesure":null,"natureAccord":"Juridique","dateEffet":"2014-01-01","dateFin":null,"adresse":{"numeroLieu":"21","natureLieu":null,"nomLieu":"RUE SULLY","complementLieu":"BP 11660","finLieu":"","codePostal":"80016","commune":"AMIENS","cedex":"1"}},{"type":"Individu/Particulier","identite":"Ehmet TYEP","mesure":"Curatelle simple","natureAccord":"Juridique","dateEffet":"2017-01-01","dateFin":"2017-12-31","adresse":{"numeroLieu":"89","natureLieu":null,"nomLieu":"AVENUE LEON BLUM","complementLieu":"","finLieu":"","codePostal":"80100","commune":"ABBEVILLE","cedex":""}},{"type":"Individu/Particulier","identite":"Esg TYTEYP PE PEPPOXE OEX","mesure":null,"natureAccord":null,"dateEffet":null,"dateFin":null,"adresse":{"numeroLieu":"1","natureLieu":null,"nomLieu":"BOULEVARD DU PORT","complementLieu":"CAD","finLieu":"","codePostal":"80000","commune":"AMIENS","cedex":""}}]},"apa":{"classotheque":"05-2834","centreAutonomie":"Centre Autonomie nord ouest"}}}',
19 18
    'consultationDeMesDroits': '{"demandeAsg":[{"demande":{"indexDemande":42,"type":"Allocation Personnalis\xc3\xa9e Autonomie","nature":"Domicile"},"droit":{"dateDebut":"2017-01-05","dateFin":"2019-01-31"},"complementDossier":{"dateDepot":"2016-11-15","dateArrivee":"2016-11-16","dateDossierComplet":"2016-11-17"},"gir":{"type":"Synth\xc3\xa8se","gir":3,"dateEvaluation":"2017-02-01"},"suivi":{"instructeur":{"civilite":"madame","nom":"ZEPEQPE","prenom":"EPOZOE","telephone":"0344974383","mail":"e.zepeqpe@xoppe.pp"},"dateDecision":"2017-01-05"},"bilan":{"pourcentageTM":2.1973443031311035},"prestationAccordeeAsg":[{"prestation":"Accueil de jour GIR 1-2","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":null,"quantitatif":null},"quantite":0,"montant":{"accorde":0,"participation":0,"verse":0},"attributaire":{"type":"Tuteur","identite":"Association Tut\xc3\xa9laire de la  Somme"}},{"prestation":"Articles d\'hygi\xc3\xa8ne forfait 45\xc2\x80","periode":{"dateEffet":"2017-01-05","dateFin":null},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":45,"quantitatif":"Mois"},"quantite":1,"montant":{"accorde":45,"participation":1.68,"verse":43.32},"attributaire":{"type":"B\xc3\xa9n\xc3\xa9ficiaire","identite":"PYPPENNE Pecile"}},{"prestation":"Petite structure","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Etablissement","identite":"MARPA LES NACRES","tarif":null,"quantitatif":null},"quantite":0,"montant":{"accorde":440.42,"participation":7.68,"verse":432.74},"attributaire":{"type":"Etablissement","identite":"MARPA LES NACRES"}},{"prestation":"Aide humaine prestataire","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Prestataire","identite":"COMMUNAUTE DE COMMUNES DU TERRITOIRE NORD PICARDIE BERNAVILLE","tarif":19,"quantitatif":"Heure(s)"},"quantite":45.5,"montant":{"accorde":864.5,"participation":18.93,"verse":845.57},"attributaire":{"type":"Prestataire","identite":"COMMUNAUTE DE COMMUNES DU TERRITOIRE NORD PICARDIE BERNAVILLE"}},{"prestation":"Articles d\'hygi\xc3\xa8ne forfait 90\xc2\x80","periode":{"dateEffet":"2017-01-05","dateFin":null},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":90,"quantitatif":"Mois"},"quantite":1,"montant":{"accorde":90,"participation":3.35,"verse":86.65},"attributaire":{"type":"B\xc3\xa9n\xc3\xa9ficiaire","identite":"PYPPENNE Pecile"}}]}]}',
20 19
    'suiviDemandeEnInstruction': '{"demandeAsg":[]}',
tests/test_solis_afi_mss.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import json
18 18
import os
19 19

  
20 20
import mock
21 21
import pytest
22

  
23 22
import utils
24 23

  
25 24
from passerelle.contrib.solis_afi_mss.models import SolisAfiMss
26 25
from passerelle.utils.jsonresponse import APIError
27 26

  
28 27

  
29 28
@pytest.fixture
30 29
def connector(db):
tests/test_solis_apa.py
1 1
import copy
2
import os
3 2
import json
3
import os
4 4
from decimal import Decimal
5 5

  
6 6
import mock
7 7
import pytest
8

  
9
from django.urls import reverse
10 8
from django.contrib.contenttypes.models import ContentType
9
from django.urls import reverse
11 10

  
12
from passerelle.base.models import ApiUser, AccessRight
13
from passerelle.contrib.solis_apa.models import SolisAPA
11
from passerelle.base.models import AccessRight, ApiUser
14 12
from passerelle.contrib.solis_apa import integration
15

  
13
from passerelle.contrib.solis_apa.models import SolisAPA
16 14

  
17 15
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'solis_apa')
18 16

  
19 17

  
20 18
def json_get_data(filename):
21 19
    with open(os.path.join(TEST_BASE_DIR, filename)) as fd:
22 20
        return json.load(fd)
23 21

  
tests/test_strasbourg_eu.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
from httmock import all_requests, HTTMock
4 3
import pytest
5

  
4
import utils
6 5
from django.contrib.contenttypes.models import ContentType
6
from httmock import HTTMock, all_requests
7 7

  
8
from passerelle.base.models import AccessRight, ApiUser
8 9
from passerelle.contrib.strasbourg_eu.models import StrasbourgEu
9
from passerelle.base.models import ApiUser, AccessRight
10

  
11
import utils
12 10

  
13 11
INTERESTS_EXAMPLE = u"""{
14 12
    "interests": [
15 13
        {
16 14
            "id": "275305",
17 15
            "name": "Centre d'intérêt 2",
18 16
            "description": "Centre d'intérêt 2",
19 17
            "typeId": "275302",
tests/test_tcl.py
1 1
import copy
2 2

  
3
from django.utils.six.moves.urllib import parse as urlparse
4 3
import mock
5 4
import pytest
6

  
7
from passerelle.contrib.tcl.models import Tcl, Line, Stop
8

  
9 5
import utils
6
from django.utils.six.moves.urllib import parse as urlparse
7

  
8
from passerelle.contrib.tcl.models import Line, Stop, Tcl
10 9

  
11 10
LIGNE_BUS = {
12 11
    "values": [
13 12
        {
14 13
            "indice": "",
15 14
            "last_update_fme": "2017-06-27 06:01:10",
16 15
            "infos": "",
17 16
            "couleur": "164 203 38",
tests/test_teamnet_axel.py
1
from requests.exceptions import ConnectionError
2 1
import mock
3 2
import pytest
4

  
5 3
import utils
4
from requests.exceptions import ConnectionError
6 5

  
7
from passerelle.contrib.teamnet_axel.models import TeamnetAxel
8
from passerelle.contrib.teamnet_axel.models import Link
6
from passerelle.contrib.teamnet_axel.models import Link, TeamnetAxel
9 7
from passerelle.utils.jsonresponse import APIError
10 8

  
11 9

  
12 10
@pytest.fixture
13 11
def setup(db):
14 12
    return utils.make_resource(
15 13
        TeamnetAxel,
16 14
        **{
tests/test_toulouse_axel.py
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
from __future__ import unicode_literals
19 19

  
20
from contextlib import contextmanager
21 20
import copy
22 21
import datetime
23 22
import decimal
24 23
import json
25
import mock
26 24
import os
27 25
import xml.etree.ElementTree as ET
28

  
29
from django.core.cache import cache
26
from contextlib import contextmanager
30 27

  
31 28
import freezegun
29
import jsonschema
30
import mock
32 31
import pytest
32
import utils
33 33
import xmlschema
34
import jsonschema
34
from django.core.cache import cache
35 35

  
36
from passerelle.contrib.toulouse_axel.exceptions import AxelError
37
from passerelle.contrib.toulouse_axel.models import (
38
    Link,
39
    Lock,
40
    ToulouseAxel,
41
)
42 36
from passerelle.contrib.toulouse_axel import schemas
37
from passerelle.contrib.toulouse_axel.exceptions import AxelError
38
from passerelle.contrib.toulouse_axel.models import Link, Lock, ToulouseAxel
43 39
from passerelle.contrib.toulouse_axel.utils import (
44
    situation_familiale_mapping,
45 40
    csp_mapping,
46 41
    lien_parente_mapping,
47
    type_regime_mapping,
48 42
    regime_mapping,
43
    situation_familiale_mapping,
44
    type_regime_mapping,
49 45
    upperize,
50 46
)
51 47
from passerelle.utils.jsonresponse import APIError
52 48
from passerelle.utils.soap import SOAPError
53
import utils
54 49

  
55 50

  
56 51
@pytest.fixture
57 52
def resource(db):
58 53
    return utils.make_resource(
59 54
        ToulouseAxel, slug='test', wsdl_url='http://example.net/AXEL_WS/AxelWS.php?wsdl'
60 55
    )
61 56

  
tests/test_toulouse_axel_schema.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18 18

  
19
from passerelle.contrib.toulouse_axel.schemas import AxelSchema
20

  
21 19
import pytest
22 20
import xmlschema
23 21

  
22
from passerelle.contrib.toulouse_axel.schemas import AxelSchema
23

  
24 24
XSD_BASE_DIR = os.path.join(
25 25
    os.path.dirname(os.path.abspath(__file__)), '../passerelle/contrib/toulouse_axel/xsd'
26 26
)
27 27

  
28 28

  
29 29
@pytest.mark.parametrize('date_type', ['DATEREQUIREDType', 'DATEType'])
30 30
def test_date_mapping(date_type):
31 31
    xsd = """<?xml version="1.0" encoding="utf-8" ?>
tests/test_toulouse_axel_utils.py
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import datetime
18

  
18 19
import pytest
19 20

  
20 21
from passerelle.contrib.toulouse_axel.utils import (
21
    parse_datetime,
22 22
    encode_datetime,
23 23
    get_booking,
24 24
    get_reference_year_from_date,
25 25
    get_week_dates_from_date,
26 26
    json_date_format,
27
    parse_datetime,
27 28
)
28 29

  
29 30

  
30 31
def test_parse_datetime():
31 32
    # wrong format
32 33
    assert parse_datetime('foo') is None
33 34
    assert parse_datetime('2019-12-12') is None
34 35
    assert parse_datetime('2019-12-12T12:01:72') is None
tests/test_utils_files.py
10 10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 11
# GNU Affero General Public License for more details.
12 12
#
13 13
# You should have received a copy of the GNU Affero General Public License
14 14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15

  
16 16
import os
17 17

  
18
import pytest
18 19
from django.core.files.storage import default_storage
19 20
from django.utils.encoding import force_bytes
20
import pytest
21 21

  
22 22
from passerelle.utils.files import atomic_write
23 23

  
24 24

  
25 25
def test_atomic_write(tmpdir):
26 26
    target_dir = tmpdir.mkdir('target')
27 27
    filepath = str(target_dir.join('test'))
28 28

  
tests/test_utils_json.py
24 24
# This program is distributed in the hope that it will be useful,
25 25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26 26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 27
# GNU Affero General Public License for more details.
28 28
#
29 29
# You should have received a copy of the GNU Affero General Public License
30 30
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
31 31

  
32
import pytest
33

  
34 32
import jsonschema
33
import pytest
35 34

  
36
from passerelle.utils.json import flatten, unflatten, flatten_json_schema, FLATTEN_SEPARATOR as SEP
35
from passerelle.utils.json import FLATTEN_SEPARATOR as SEP
36
from passerelle.utils.json import flatten, flatten_json_schema, unflatten
37 37

  
38 38

  
39 39
def test_unflatten_base():
40 40
    assert unflatten('') == ''
41 41
    assert unflatten('a') == 'a'
42 42
    assert unflatten([]) == []
43 43
    assert unflatten([1]) == [1]
44 44
    assert unflatten({}) == {}
tests/test_utils_sftp.py
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18 18

  
19 19
import pytest
20

  
21 20
from django.core.files.uploadedfile import SimpleUploadedFile
22 21
from django.db import models
23 22
from django.utils.encoding import force_text
24 23

  
25
from passerelle.utils.sftp import SFTP, SFTPFormField, SFTPField
24
from passerelle.utils.sftp import SFTP, SFTPField, SFTPFormField
26 25

  
27 26

  
28 27
@pytest.fixture
29 28
def ssh_key():
30 29
    with open(os.path.join(os.path.dirname(__file__), 'ssh_key'), 'rb') as fd:
31 30
        yield fd.read()
32 31

  
33 32

  
tests/test_utils_xml.py
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU Affero General Public License for more details.
13 13
#
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import xml.etree.ElementTree as ET
18 18

  
19
import xmlschema
20

  
21 19
import jsonschema
20
import xmlschema
22 21

  
23
from passerelle.utils.xml import to_json, text_content, JSONSchemaFromXMLSchema
24
from passerelle.utils.json import flatten_json_schema, flatten, unflatten
22
from passerelle.utils.json import flatten, flatten_json_schema, unflatten
23
from passerelle.utils.xml import JSONSchemaFromXMLSchema, text_content, to_json
25 24

  
26 25

  
27 26
def test_text_content():
28 27
    root = ET.fromstring('<root>aa<b>bb</b>cc</root>')
29 28
    assert text_content(root) == 'aabbcc'
30 29

  
31 30

  
32 31
def test_to_json():
tests/test_utils_zip.py
22 22
import uuid
23 23
import zipfile
24 24

  
25 25
import pytest
26 26

  
27 27
from passerelle.utils.zip import (
28 28
    ZipTemplate,
29 29
    ZipTemplateDoesNotExist,
30
    ZipTemplateSyntaxError,
31 30
    ZipTemplateError,
31
    ZipTemplateSyntaxError,
32 32
)
33 33

  
34 34

  
35 35
@pytest.fixture
36 36
def templates_path(tmpdir, settings):
37 37
    path = tmpdir.mkdir('templates')
38 38
    settings.TEMPLATES = settings.TEMPLATES[:]
39 39
    settings.TEMPLATES[0] = settings.TEMPLATES[0].copy()
tests/test_vivaticket.py
1 1
# -*- coding: utf-8 -*-
2 2
import mock
3 3
import pytest
4
import utils
4 5

  
5 6
from passerelle.apps.vivaticket.models import VivaTicket
6

  
7 7
from passerelle.utils.jsonresponse import APIError
8 8

  
9
import utils
10

  
11 9
ERROR_RESPONSE = """{
12 10
  "Message": "Une erreur s’est produite."
13 11
}"""
14 12

  
15 13
KEY_RESPONSE = """{
16 14
  "Key": "86569D0CA1B1CBEF8D77DD5BDC9F5CBAE5C99074",
17 15
  "ReturnCode": 0,
18 16
  "Error": null
tests/utils.py
1 1
import json
2 2

  
3
import mock
4 3
import httmock
5

  
4
import mock
6 5
from django.contrib.contenttypes.models import ContentType
7 6
from django.urls import reverse
8 7
from django.utils.six.moves.urllib import parse as urlparse
9 8

  
10
from passerelle.base.models import ApiUser, AccessRight
9
from passerelle.base.models import AccessRight, ApiUser
11 10
from passerelle.compat import json_loads
12 11

  
13 12

  
14 13
def generic_endpoint_url(connector, endpoint, slug='test'):
15 14
    return reverse('generic-endpoint', kwargs={'connector': connector, 'slug': slug, 'endpoint': endpoint})
16 15

  
17 16

  
18 17
def setup_access_rights(obj):
tests/wcs/conftest.py
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18

  
19
import pickle
20
import sys
21
import time
19
import contextlib
22 20
import os
23
import shutil
21
import pickle
24 22
import random
23
import shutil
25 24
import socket
25
import sys
26 26
import tempfile
27
import contextlib
27
import time
28 28

  
29
from django.utils.six.moves import configparser as ConfigParser
29
import httmock
30 30
import psycopg2
31 31
import pytest
32
import httmock
32
from django.utils.six.moves import configparser as ConfigParser
33 33

  
34 34

  
35 35
def find_free_tcp_port():
36 36
    with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
37 37
        s.bind(('', 0))
38 38
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
39 39
        return s.getsockname()[1]
40 40

  
......
328 328
    def wcs_init_01_setup_auth(self):
329 329
        from quixote import get_publisher
330 330

  
331 331
        get_publisher().cfg['identification'] = {'methods': ['password']}
332 332
        get_publisher().cfg['debug'] = {'display_exceptions': 'text'}
333 333
        get_publisher().write_cfg()
334 334

  
335 335
    def wcs_init_02_create_user(self):
336
        from quixote import get_publisher
337 336
        from qommon.ident.password_accounts import PasswordAccount
337
        from quixote import get_publisher
338 338

  
339 339
        pub = get_publisher()
340 340
        Role = pub.role_class
341 341
        User = pub.user_class
342 342
        user = User()
343 343
        user.name = 'foo bar'
344 344
        user.email = 'foo@example.net'
345 345
        user.store()
......
361 361
        account = PasswordAccount(id='admin')
362 362
        account.set_password('admin')
363 363
        account.user_id = user.id
364 364
        account.store()
365 365

  
366 366
    def wcs_init_03_create_data(self):
367 367
        import datetime
368 368
        import random
369

  
369 370
        from quixote import get_publisher
370 371

  
372
        from wcs import fields
371 373
        from wcs.categories import Category
372 374
        from wcs.formdef import FormDef
373
        from wcs import fields
374 375

  
375 376
        pub = get_publisher()
376 377
        Role = pub.role_class
377 378
        User = pub.user_class
378 379
        cat = Category()
379 380
        cat.name = 'Catégorie'
380 381
        cat.description = ''
381 382
        cat.store()
tests/wcs/test_conftest.py
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18 18
import pytest
19

  
20
from django.utils.six.moves.urllib import parse as urlparse
21 19
import requests
20
from django.utils.six.moves.urllib import parse as urlparse
22 21

  
23 22

  
24 23
def test_wcs_fixture(wcs_host):
25 24
    assert wcs_host.url.startswith('http://127.0.0.1:')
26 25
    requests.get(wcs_host.url)
27 26
    response = requests.get(urlparse.urljoin(wcs_host.url, '/api/categories/'))
28 27
    assert response.json()['data'][0]['title'] == u'Catégorie'
29 28

  
tests/wcs/test_sp_fr.py
10 10
# This program is distributed in the hope that it will be useful,
11 11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 13
# GNU Affero General Public License for more details.
14 14
#
15 15
# You should have received a copy of the GNU Affero General Public License
16 16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17

  
18
import pytest
19 18
import mock
19
import pytest
20
import utils
20 21

  
21 22
from passerelle.apps.sp_fr.models import Resource
22 23
from passerelle.utils.sftp import SFTP
23
from passerelle.utils.wcs import get_wcs_choices, FormDefRef
24

  
25
import utils
26

  
24
from passerelle.utils.wcs import FormDefRef, get_wcs_choices
27 25

  
28 26
DUMMY_CONTENT = {
29 27
    'DILA': {
30 28
        'a.zip': 'a',
31 29
    }
32 30
}
33 31

  
34 32

  
35
-