class MaterielSerializer(Serializer): id = IntField() type_mat = IntField(preparefn=lambda x: x['id']) label = Field() reference = Field() disponible = IntField() utilisateur_actuel = Field()
class AffectationSerializer(Serializer): id = IntField() id_materiel = IntField() type_affectation = IntField() utilisateur = Field() date_affectation = DateField(default=datetime.datetime.now()) date_retour = DateField() observations = Field()
class DemandeSerializer(Serializer): id = IntField() num_intv = Field() dem_date = DateField() dem_objet = Field() dem_loc_libelle = Field() rea_date = DateField() rea_annulation = IntField(default=0, serializefn=lambda x: x == 1, preparefn=lambda x: 1 if x else 2)
class AgentSerializer(Serializer): ''' serialise une partie des données de la fiche pour un affichage en liste ''' id = IntField() nom = Field() prenom = Field() intitule_poste = Field() service_id = IntField() arrivee = DateField() depart = DateField()
class SubvSerializer(Serializer): ''' Serialize une partie des données pour un affichage résumé en liste ''' id = Field() meta_id = Field() pet_nom = Field() sa_massif = IntField() sa_commission = IntField() dec_date_bureau = DateField() dec_echeance = DateField() pai_reste_du = FloatField() meta_statut = IntField()
class SubvTemplateSerializer(Serializer): id = IntField() name = Field() label = Field() public = Field(preparefn=lambda x: 1 if x == 'true' else 0, serializefn=lambda x: x == 1) path = Field()
class DemandeFullSerializer(DemandeSerializer): dem_localisation = IntField() dem_loc_commune = Field() dem_details = Field() dem_delai = Field() dem_fichiers = FileField() dmdr_contact_nom = Field() dmdr_service = IntField() dmdr_contact_email = Field( serializefn=(lambda val: [item for item in val.split(',') if item]), preparefn=lambda val: ','.join(val)) plan_date = Field() plan_commentaire = Field() rea_duree = IntField(default=0) rea_nb_agents = IntField(default=0) rea_commentaire = Field() rea_fichiers = FileField()
class AgentDetailSerializer(AgentSerializer): ''' serialise la totalité de la fiche pour un affichage détaillé ''' id_agent = IntField() desc_mission = Field() notif_list = Field( serializefn=(lambda val: [item for item in val.split(',') if item]), preparefn=lambda val: ','.join(val)) type_contrat = IntField() lieu = IntField() logement = IntField() # TH ref 10 categorie = IntField() # TH ref 38 referent = Field() gratification = Field() temps_travail = IntField() # TH ref 33 temps_travail_autre = Field() residence_administrative = Field() convention_signee = Field() bureau = Field() observations = Field() meta_create = DateField(default=str(datetime.date.today())) meta_update = DateField(default=None) meta_createur_fiche = Field() materiel = MultipleField(serializefn=lambda val: [item.id for item in val]) fichiers = FileField()
class EquipementSerializer(Serializer): ''' Serialisation d'un objet Equipement ''' id = IntField() ip_addr = Field() label = Field() equip_type = Field() status = Field() stats = Field( serializefn=lambda x: json.loads(x) if x else [], preparefn=json.dumps ) last_up = DateField() commentaires = Field() evts = MultipleField( serializefn=lambda x: [ EvtEquipementSerializer(evt).serialize() for evt in reversed(x) ] if x else [] )
class SubvFullSerializer(SubvSerializer): meta_createur = Field() meta_createur_mail = Field() meta_observations = Field() # Petitionnaire pet_civ = Field() pet_adresse = Field() pet_adresse2 = Field() pet_cpostal = Field() pet_commune = Field() pet_telephone = Field() pet_mobile = Field() pet_mail = Field() # Suivi administratif sa_service = IntField() sa_instructeur = Field() sa_tel_instr = Field() sa_mail_instr = Field() sa_axe_charte = IntField() sa_id_action = Field() sa_nature = Field() sa_date_commission = DateField() # Subvention sub_objet = Field() sub_commune = Field() sub_zc = IntField(default=0) sub_ctr_patri = IntField() sub_montant = FloatField(default=0) sub_cout_total = FloatField(default=0) sub_taux = FloatField(default=0) sub_date_rcpt = DateField() sub_dem_pc = DateField() sub_date_ar = DateField() # Décision dec_date_notif = DateField() dec_num_delib = Field() dec_refus_ajourn = IntField() dec_motif_refus = Field() dec_conditions = Field() dec_montant = FloatField(default=0) dec_tva = IntField(default=0) dec_taux = FloatField(default=0) dec_compte = IntField() dec_code_ug = IntField() dec_operation = IntField() dec_num_ej = Field() dec_date_retour = DateField() dec_relance = DateField() dec_dem_prorogation_date = DateField() dec_bur_prorogation_date = DateField() dec_numdel_prorogation = Field() dec_prorogation = DateField() dec_motif_ajourn = Field() dec_bur_ajourn_date = DateField() dec_numdel_ajourn = Field() dec_courrier_ajourn = DateField() # Paiement pai_date_recept_demande = DateField() pai_accpt1_montant = FloatField() pai_accpt1_date = DateField() pai_accpt1_dp = Field() pai_accpt2_montant = FloatField() pai_accpt2_date = DateField() pai_accpt2_dp = Field() pai_accpt3_montant = FloatField() pai_accpt3_date = DateField() pai_accpt3_dp = Field() pai_accpt4_montant = FloatField() pai_accpt4_date = DateField() pai_accpt4_dp = Field() pai_accpt5_montant = FloatField() pai_accpt5_date = DateField() pai_accpt5_dp = Field() pai_total_verse = FloatField() pai_mnt_annule = FloatField() sub_fichiers = FileField() dec_fichiers = FileField() pai_fichiers = FileField()
class TypeMaterielSerializer(Serializer): id = IntField() label = Field() observations = Field()
class ChangelogSerializer(Serializer): id = IntField() entity_id = IntField() author = Field() change_type = IntField() change_date = DateField()
class UserSerializer(Serializer): id = IntField() name = Field()
class ThesaurusSerializer(Serializer): id = Field() id_ref = Field() label = Field() menu = IntField(serializefn=lambda x: bool(x))
class EvtEquipementSerializer(Serializer): id = IntField() equip_id = IntField() evt_type = IntField() evt_date = DateField()