From 58a6fc435e10582c548bc40caf985758194b5921 Mon Sep 17 00:00:00 2001 From: Josue Kouka Date: Tue, 23 May 2017 00:40:49 +0200 Subject: [PATCH 4/4] add cityweb element types --- passerelle/contrib/cityweb/cityweb.py | 169 ++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 passerelle/contrib/cityweb/cityweb.py diff --git a/passerelle/contrib/cityweb/cityweb.py b/passerelle/contrib/cityweb/cityweb.py new file mode 100644 index 0000000..6e5f492 --- /dev/null +++ b/passerelle/contrib/cityweb/cityweb.py @@ -0,0 +1,169 @@ +# Copyright (C) 2017 Entr'ouvert +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +class CWBaseException(Exception): + pass + + +class CWBaseType(object): + + def serialize(self): + pass + + def save(self, location): + pass + + +class CWBSimpleType(CWBaseType): + + def __ini__(self, value): + if value not in self.values: + raise CWBaseException('Value must be in %s' % self.values) + + +class CWBComplexType(CWBaseType): + pass + + +################################### +# SIMPLE TYPES +################################### + +class EventKind(CWBSimpleType): + name = 'natureEvenement' + values = ['NAIS', 'DEC', 'MAR', 'REC'] + + +class Sexe(CWBSimpleType): + name = 'sexe' + values = ['M', 'F', 'NA'] + + +class Gender(CWBSimpleType): + name = 'genre' + values = ['M', 'Mme', 'Mlle'] + + +class DocumentKind(CWBSimpleType): + name = 'natureDocument' + values = ['CPI', 'EXTAF', 'EXTSF', 'EXTPL'] + + +class Concerned(CWBSimpleType): + name = 'typeInteresse' + values = ['reconnu', 'auteur'] + + +class Canal(CWBSimpleType): + name = 'oeigineEC' + values = ['internet', 'guichet', 'courrier'] + + +class Date(CWBaseType): + name = 'dateCivique' + + +################################### +# COMPLEX TYPES +################################### + +class Name(CWBComplexType): + name = 'noms' + + def __init__(self, last_name=None, preferred_name=None, usage=None): + self.nomDeFamille = last_name + self.nomUsage = preferred_name + self.typeUsage = usage + + +class PlaceType(CWBComplexType): + name = 'lieu' + + def __init__(self, city=None, district=None, country=None): + self.ville = city + self.province = district + self.pays = country + + +class Address(CWBComplexType): + name = 'adresse' + + def __init__(self, address1=None, address2=None, zip_code=None, place=None, mail=None, tel=None): + self.ligneAdr1 = address1 + self.ligneAdr2 = address2 + self.codePostal = zip_code + self.lieu = place + self.mail = mail + self.tel = tel + + +class EventDate(CWBComplexType): + name = 'dateEvenement' + + def __init__(self, start=None, end=None): + self.dateDebut = start + self.dateFin = end + + +class Event(CWBComplexType): + name = 'evenement' + + def __init__(self, concerned, partner, event_kind, concerned_kind, date, place): + self.interesse = concerned + self.conjoint = partner + self.natureEvenement = event_kind + self.typeInteresse = concerned_kind + self.dateEvenement = date + self.lieuEvenement = place + + +class Person(CWBComplexType): + name = 'individu' + + def __init__(self, names=None, first_names=None, title=None, address=None, sex=None, + father=None, mother=None, birth=None): + self.noms = names + self.prenoms = first_names + self.genre = title + self.adresse = address + self.sexe = sex + self.pere = father + self.mere = mother + self.naissance = birth + + +class Applicant(CWBComplexType): + name = 'demandeur' + + def __init__(self, kind, person): + self.qualiteDemandeur = kind + self.individu = person + + +class CivilStatusApplication(CWBaseType): + name = 'demandeEtatCivil' + + def __init__(self, application_id, applicant, document_kind, copies, datetime, event, + reason, canal, comment): + self.identifiant = application_id + self.demandeur = applicant + self.natureDocument = document_kind + self.nbExemplaire = copies + self.dateDemande = datetime + self.evenement = event + self.motif = reason + self.origine = canal + self.commentaire = comment -- 2.11.0