from .models import ( Agent, AgentDetail, RelAgentFichier) from .serializers import ( AgentSerializer, AgentDetailSerializer ) AgentDetailSerializer.fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('recrutement', __name__) register_module('/recrutement', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'nom', 'prenom', 'intitule_poste', ( 'service_id', load_ref(_db, Thesaurus, 'label') ), 'arrivee', 'depart', 'desc_mission',
from server import db as _db from core.models import Fichier, prepare_fichiers from core.routes import upload_file, get_uploaded_file, delete_uploaded_file from core.thesaurus.models import Thesaurus from core.utils import (json_resp, send_mail, csv_response, register_module, registered_funcs) from core.utils.serialize import load_ref, ValidationError from core.utils.rtf import render_rtf from .models import (Agent, AgentDetail, RelAgentFichier) from .serializers import (AgentSerializer, AgentDetailSerializer) AgentDetailSerializer.fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('recrutement', __name__) register_module('/recrutement', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'nom', 'prenom', 'intitule_poste', ('service_id', load_ref(_db, Thesaurus, 'label')), 'arrivee', 'depart', 'desc_mission', ('type_contrat', load_ref(_db, Thesaurus, 'label')), ('service_id', load_ref(_db, Thesaurus, 'label')), ('lieu', load_ref(_db, Thesaurus, 'label')), ('categorie', load_ref(_db, Thesaurus, 'label')), ('temps_travail', load_ref(_db, Thesaurus, 'label')), 'referent', 'temps_travail_autre', 'residence_administrative', ('logement', load_ref(_db, Thesaurus, 'label')), 'convention_signee', 'gratification', 'bureau', 'observations'
from core.refgeo.models import RefGeoCommunes, RefGeoBatiment from core.utils import (json_resp, csv_response, send_mail, register_module, registered_funcs) from core.utils.serialize import load_ref, ValidationError from .models import TravauxBatiment from .serializers import (TravauxBatimentSerializer, TravauxBatimentFullSerializer) TravauxBatimentFullSerializer.dem_fichiers.preparefn = prepare_fichiers(_db) TravauxBatimentFullSerializer.plan_fichiers.preparefn = prepare_fichiers(_db) TravauxBatimentFullSerializer.rea_fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('travaux_batiments', __name__) register_module('/travaux_batiments', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'dem_date', ('dem_commune', load_ref(_db, RefGeoCommunes, 'nom_commune')), ('dem_designation', load_ref(_db, RefGeoBatiment, 'designation')), ('dmdr_service', load_ref(_db, Thesaurus, 'label')), 'dmdr_contact_nom', 'dem_importance_travaux', ('dem_type_travaux', load_ref(_db, Thesaurus, 'label')), 'dem_description_travaux', ('plan_service', load_ref(_db, Thesaurus, 'label')), 'plan_entreprise', 'plan_date', 'plan_commentaire', 'rea_date', 'rea_duree', 'rea_commentaire' ]
) from .models import Demande from .serializers import ( DemandeSerializer, DemandeFullSerializer) from core.utils.serialize import load_ref, ValidationError DemandeFullSerializer.dem_fichiers.preparefn = prepare_fichiers(_db) DemandeFullSerializer.rea_fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('interventions', __name__) register_module('/interventions', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'num_intv', ( 'dem_objet', load_ref(_db, Thesaurus, 'label') ), 'dem_date', ( 'dem_localisation', load_ref(_db, Thesaurus, 'label')
from core.thesaurus.models import Thesaurus from core.utils import (json_resp, csv_response, send_mail, register_module, registered_funcs) from core.utils.serialize import ValidationError, load_ref, format_phone from .models import DemandeSubvention, SubvTemplate from .serializers import (SubvSerializer, SubvFullSerializer, SubvTemplateSerializer) from .utils import render, montant2txt SubvFullSerializer.sub_fichiers.preparefn = prepare_fichiers(_db) SubvFullSerializer.dec_fichiers.preparefn = prepare_fichiers(_db) SubvFullSerializer.pai_fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('subventions', __name__) register_module('/subventions', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'meta_createur', 'meta_createur_mail', 'meta_id', 'meta_statut', 'meta_observations', 'pet_nom', 'pet_civ', 'pet_adresse', 'pet_adresse2', 'pet_cpostal', 'pet_commune',
from flask import Blueprint, request, Response from server import db from core.utils import (json_resp, register_module, registered_funcs) from core.utils.serialize import ValidationError from .models import (TypeMateriel, Materiel, Affectation) from .serializers import (TypeMaterielSerializer, MaterielSerializer, MaterielFullSerializer, AffectationSerializer) routes = Blueprint('materiel', __name__) register_module('/materiel', routes) check_auth = registered_funcs['check_auth'] @routes.route('/') @json_resp @check_auth(groups=['admin-tizoutis']) def get_materiels(): ''' retourne la liste du matériel ''' params = request.args.getlist('itemType') req = db.session.query(Materiel) if len(params): req = req.filter(Materiel.type_mat.in_(params)) res = req.all() return [MaterielSerializer(mat).dump() for mat in res] return []
from server import db as _db from core.models import Fichier, prepare_fichiers, get_chrono, amend_chrono from core.thesaurus.models import Thesaurus from core.utils import (json_resp, csv_response, send_mail, register_module, registered_funcs) from .models import Demande from .serializers import (DemandeSerializer, DemandeFullSerializer) from core.utils.serialize import load_ref, ValidationError DemandeFullSerializer.dem_fichiers.preparefn = prepare_fichiers(_db) DemandeFullSerializer.rea_fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('interventions', __name__) register_module('/interventions', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'num_intv', ('dem_objet', load_ref(_db, Thesaurus, 'label')), 'dem_date', ('dem_localisation', load_ref(_db, Thesaurus, 'label')), 'dem_details', ('dmdr_service', load_ref(_db, Thesaurus, 'label')), 'dem_delai', 'dem_loc_commune', 'dem_loc_libelle', 'rea_duree', 'dmdr_contact_nom', 'plan_commentaire', 'plan_date', 'rea_date', 'rea_nb_agents', 'rea_commentaire' ] def get_demande_encours(annee_deb, annee_fin):
from core.utils.serialize import load_ref, ValidationError from .models import TravauxBatiment from .serializers import ( TravauxBatimentSerializer, TravauxBatimentFullSerializer) TravauxBatimentFullSerializer.dem_fichiers.preparefn = prepare_fichiers(_db) TravauxBatimentFullSerializer.plan_fichiers.preparefn = prepare_fichiers(_db) TravauxBatimentFullSerializer.rea_fichiers.preparefn = prepare_fichiers(_db) routes = Blueprint('travaux_batiments', __name__) register_module('/travaux_batiments', routes) check_auth = registered_funcs['check_auth'] csv_fields = [ 'id', 'dem_date', ( 'dem_commune', load_ref(_db, RefGeoCommunes, 'nom_commune') ), ( 'dem_designation', load_ref(_db, RefGeoBatiment, 'designation') ),
import uuid from functools import wraps from flask import (Blueprint, request, g, Response) from sqlalchemy.orm.exc import NoResultFound import config from server import get_app, db as _db from core.utils import (json_resp, register_module, registered_funcs) from . import models, utils from .serializers import UserSerializer, UserFullSerializer from .exc import InvalidAuthError routes = Blueprint('auth', __name__) register_module('/auth', routes) @routes.route('/login', methods=['POST']) @json_resp def login_view(): ''' Connexion de l'utilisateur ''' login = request.json['login'].strip() passwd = request.json['passwd'].strip() try: user = utils.check_user_login(login, passwd) userdata = json.dumps(user.as_dict()) token = uuid.uuid4().hex
from sqlalchemy.orm.exc import NoResultFound import config from server import get_app, db as _db from core.utils import ( json_resp, register_module, registered_funcs) from . import models, utils from .serializers import UserSerializer, UserFullSerializer from .exc import InvalidAuthError routes = Blueprint('auth', __name__) register_module('/auth', routes) @routes.route('/login', methods=['POST']) @json_resp def login_view(): ''' Connexion de l'utilisateur ''' login = request.json['login'].strip() passwd = request.json['passwd'].strip() try: user = utils.check_user_login(login, passwd) userdata = json.dumps(user.as_dict()) token = uuid.uuid4().hex
import json import datetime import atexit from flask import Blueprint, request from server import db as _db, get_app from core.utils import json_resp, register_module from core.utils.serialize import ValidationError from .models import Equipement, EquipementSerializer routes = Blueprint('superv', __name__) register_module('/supervision', routes) app = get_app() if app.config.get('ENABLE_SUPERVISION', False): from .tools import Scanner, shutdown_fn scan = Scanner() atexit.register(shutdown_fn, scan) @routes.route('/') @json_resp def sup_index(): fields = ['id', 'ip_addr', 'label', 'equip_type', 'last_up', 'status'] conn = _db.engine.connect() results = conn.execute('select %s from sup_equipement' % ', '.join(fields)) out = [] for item in results:
from flask import Blueprint from server import db from sqlalchemy.exc import StatementError from core.refgeo import models from core.utils import json_resp, register_module routes = Blueprint('rg_routes', __name__) register_module('/refgeo', routes) @routes.route('/commune') @json_resp def get_communes(): try: com_list = db.session.query(models.RefGeoCommunes).all() out = [] for item in com_list: out.append({'id': item.id, 'label': item.nom_commune}) return out except StatementError: db.session.rollback() return [], 400 @routes.route('/commune/id/<id_com>') @json_resp def get_one_commune(id_com): result = db.session.query(models.RefGeoCommunes).get(int(id_com)) if not result:
from flask import Blueprint from server import db from sqlalchemy.exc import StatementError from core.refgeo import models from core.utils import json_resp, register_module routes = Blueprint('rg_routes', __name__) register_module('/refgeo', routes) @routes.route('/commune') @json_resp def get_communes(): try: com_list = db.session.query(models.RefGeoCommunes).all() out = [] for item in com_list: out.append({'id': item.id, 'label': item.nom_commune}) return out except StatementError: _db.session.rollback() return [], 400 @routes.route('/commune/id/<id_com>') @json_resp def get_one_commune(id_com): result = db.session.query(models.RefGeoCommunes).get(int(id_com)) if not result: return [], 404
Commune, Correspondant, Entreprise, RelationEntite) from .serializers import ( EntiteSerializer, CommuneSerializer, CorrespondantSerializer, EntrepriseSerializer ) from .utils import format_vcard routes = Blueprint('annuaire', __name__) register_module('/annuaire', routes) check_auth = registered_funcs['check_auth'] TYPES_E = { 'entite': Entite, 'commune': Commune, 'correspondant': Correspondant, 'entreprise': Entreprise } SERIALIZERS_E = { 'entite': EntiteSerializer, 'commune': CommuneSerializer, 'correspondant': CorrespondantSerializer, 'entreprise': EntrepriseSerializer
from server import db as _db from core.utils import (json_resp, csv_response, vcard_response, register_module, registered_funcs) from core.utils.serialize import ValidationError # from core.models import record_changes, load_changes, ChangeType from .models import (Entite, Commune, Correspondant, Entreprise, RelationEntite) from .serializers import (EntiteSerializer, CommuneSerializer, CorrespondantSerializer, EntrepriseSerializer) from .utils import format_vcard routes = Blueprint('annuaire', __name__) register_module('/annuaire', routes) check_auth = registered_funcs['check_auth'] TYPES_E = { 'entite': (Entite, EntiteSerializer), 'commune': (Commune, CommuneSerializer), 'correspondant': (Correspondant, CorrespondantSerializer), 'entreprise': (Entreprise, EntrepriseSerializer) } FIELDS_E = { 'entite': ['id', 'nom', 'observations'], 'commune': [ 'id', 'nom', 'adresse', 'adresse2', 'code_postal', 'telephone', 'email', 'site_internet'
''' from flask import Blueprint, request from server import db as _db from sqlalchemy.exc import StatementError from core.thesaurus import models from core.utils import ( json_resp, register_module, registered_funcs ) routes = Blueprint('th_routes', __name__) register_module('/thesaurus', routes) check_auth = registered_funcs['check_auth'] @routes.route('/') @json_resp @check_auth(groups=['admin-tizoutis']) def th_index(): th_list = _db.session.query(models.Thesaurus).all() return [ models.ThesaurusSerializer(item).dump() for item in th_list ]