formation
This commit is contained in:
parent
b7c9de1955
commit
859ff16e3e
|
@ -0,0 +1,10 @@
|
|||
Metadata-Version: 1.0
|
||||
Name: passerelle-reunion-unicite
|
||||
Version: 0
|
||||
Summary: UNKNOWN
|
||||
Home-page: UNKNOWN
|
||||
Author: CR Reunion
|
||||
Author-email: nicolas.clain@cr-reunion.fr
|
||||
License: UNKNOWN
|
||||
Description: UNKNOWN
|
||||
Platform: UNKNOWN
|
|
@ -0,0 +1,7 @@
|
|||
setup.py
|
||||
passerelle-reunion-unicite/__init__.py
|
||||
passerelle-reunion-unicite/models.py
|
||||
passerelle_reunion_unicite.egg-info/PKG-INFO
|
||||
passerelle_reunion_unicite.egg-info/SOURCES.txt
|
||||
passerelle_reunion_unicite.egg-info/dependency_links.txt
|
||||
passerelle_reunion_unicite.egg-info/top_level.txt
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
passerelle-reunion-unicite
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-10-16 11:17
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passerelle_reunion_unicite', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='db_host',
|
||||
field=models.CharField(blank=True, max_length=128, verbose_name='Hostname/ip de la base de donn\xe9es'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='db_name',
|
||||
field=models.CharField(blank=True, max_length=128, verbose_name='Nom de la base'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='db_pass',
|
||||
field=models.CharField(blank=True, max_length=128, verbose_name='Mot de passe'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='db_port',
|
||||
field=models.IntegerField(default=5432, verbose_name='Port'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='db_user',
|
||||
field=models.CharField(blank=True, max_length=128, verbose_name='Utilisateur'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='form_id',
|
||||
field=models.IntegerField(default=-1, verbose_name='Id du formulaire'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.18 on 2019-10-16 11:18
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passerelle_reunion_unicite', '0002_auto_20191016_1317'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='unicityreunionconnector',
|
||||
name='form_id',
|
||||
field=models.IntegerField(default=0, verbose_name='Id du formulaire'),
|
||||
),
|
||||
]
|
|
@ -1,14 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from passerelle.base.models import BaseResource
|
||||
|
||||
from passerelle.utils.api import endpoint
|
||||
from passerelle.utils.jsonresponse import APIError
|
||||
import psycopg2
|
||||
|
||||
class UnicityReunionConnector(BaseResource):
|
||||
|
||||
form_id = models.CharField(max_length=128, verbose_name=_('Id du formulaire'))
|
||||
form_id = models.IntegerField(default=0, verbose_name=_(u'Id du formulaire'))
|
||||
db_host = models.CharField(blank=True, max_length=128, verbose_name=_(u'Hostname/ip de la base de données'))
|
||||
db_port = models.IntegerField(default=5432, verbose_name=_(u'Port'))
|
||||
db_user = models.CharField(blank=True, max_length=128, verbose_name=_(u'Utilisateur'))
|
||||
db_pass = models.CharField(blank=True, max_length=128, verbose_name=_(u'Mot de passe'))
|
||||
db_name = models.CharField(blank=True, max_length=128, verbose_name=_(u'Nom de la base'))
|
||||
|
||||
category = 'Divers'
|
||||
|
||||
class Meta:
|
||||
verbose_name = u'Connecteur unicity réunion'
|
||||
|
||||
@endpoint(description=_(u'Vérifier s\'il y a déjà une demande pour le siren pour cette année'),
|
||||
perm='can_access',
|
||||
parameters={
|
||||
'siren': {'description': _(u'SIREN'),
|
||||
'example_value': u'77567227216096'},
|
||||
'annee': {'description': _(u'Année')}
|
||||
}
|
||||
)
|
||||
def doublon_par_siren_annee(self, request, siren, annee):
|
||||
try:
|
||||
connection = psycopg2.connect(
|
||||
user = self.db_user,
|
||||
password = self.db_pass,
|
||||
host = self.db_host,
|
||||
port = self.db_port,
|
||||
database = self.db_name
|
||||
)
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT f_siren FROM wcs_view_1_cheques_numeriques WHERE status != 'draft' AND f_siren=%s AND f_annee=%s", (siren, annee))
|
||||
record = cursor.fetchone()
|
||||
except psycopg2.Error as e:
|
||||
raise APIError(e)
|
||||
finally:
|
||||
if(connection):
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
return {'data': record}
|
||||
|
||||
|
|
Reference in New Issue