def list(kw): if kw == 'employe': return zip(Employe.get_employes(), Employe.get_employes()) + [ (u'interim', u'Intérimaires') ] elif kw == 'affaire': return zip(Affaire.get_affaire(), map(str, Affaire.get_affaire())) elif kw == 'week': current_monday = dates.get_current_start_date() l_dates = pd.DatetimeIndex( start=current_monday - pd.Timedelta(days=30), end=current_monday + pd.Timedelta(days=6), freq='w') return [str((t + pd.Timedelta(days=1)).date()) for t in l_dates] elif kw == 'heures': return zip(range(1000), range(1000)) else: return []
def list(kw): d_month = { 1: 'Janvier {}', 2: 'Fevrier {}', 3: 'Mars {}', 4: 'Avril {}', 5: 'Mai {}', 6: 'Juin {}', 7: 'Juillet {}', 8: 'Aout {}', 9: 'Septembre {}', 10: 'Octobre {}', 11: 'Novembre {}', 12: 'Decembre {}' } if kw == 'client': return zip(Client.get_clients(), Client.get_clients()) elif kw == 'contact': return Contact.get_contact('client_commande', return_id=True) elif kw == 'responsable': return zip(Employe.get_employes(**{'categorie': 'charge affaire'}), Employe.get_employes(**{'categorie': 'charge affaire'})) elif kw == 'base_prix': d = pd.Timestamp.now().date() l_dates = pd.DatetimeIndex(start=d - pd.Timedelta(days=95), end=d + pd.Timedelta(days=95), freq='M') return [(d_month[t.month].format(t.year), d_month[t.month].format(t.year)) for t in l_dates] else: return []
def list(id_, **kwlist): if id_ == 'responsable': return zip(Employe.get_employes(**{'categorie': 'charge affaire'}), Employe.get_employes(**{'categorie': 'charge affaire'})) elif id_ == 'devis': return zip(Devis.get_devis(), Devis.get_devis()) elif id_ == 'chantier': kwargs = kwlist.get('chantier', {}) return Chantier.get_chantier(return_id=True, **kwargs) elif id_ == 'contact_chantier_client': return Contact.get_contact('client_chantier', return_id=True, **kwlist.get('contact', {})) elif id_ == 'contact_facturation_client': return Contact.get_contact('client_administration', return_id=True, **kwlist.get('contact', {})) elif id_ == 'contact_chantier_interne': return zip(Employe.get_employes(**{'categorie': 'chantier'}), Employe.get_employes(**{'categorie': 'chantier'})) else: return []
def test_request(self): """ python -m unittest tests.models.employe.TestEmploye.test_request """ l_client = Employe.get_employes(path=self.path) self.assertEqual(len(l_client), 1) self.assertEqual(l_client[0], "Jean Dujardin") # Test from index instance method test_employe = Employe.from_index_({'nom': 'Dujardin', 'prenom': 'Jean'}, path=self.path) for k, v in self.d_init[0].items(): if k not in [sch.name for sch in BaseModel.l_hfields]: self.assertEqual(test_employe.__getattribute__(k), v)