1 # -*- encoding: utf-8 -*-
3 from django
.db
.models
import Q
4 from auf
.django
.references
import models
as ref
10 def get_query(self
,q
,request
):
11 pays
= ref
.Pays
.objects
.filter(Q(nom__icontains
=q
) |
Q(code__icontains
=q
))
14 def format_result(self
, pays
):
17 def format_item(self
, pays
):
18 return self
.format_result(pays
)
20 def get_objects(self
, ids
):
21 return ref
.Pays
.objects
.filter(code__in
=ids
)
24 class Implantation(object):
26 def get_query(self
,q
,request
):
27 f
= Q(nom__icontains
=q
) |
Q(nom_court__icontains
=q
) |
Q(nom_long__icontains
=q
) |
Q(region__nom__icontains
=q
)
28 implantations
= ref
.Implantation
.objects
.filter(f
)
31 def format_result(self
, implantation
):
32 statut
= implantation
.statut
33 if implantation
.statut
== 0:
34 statut
= u
"Jamais ouverte OU fermée"
35 if implantation
.statut
== 1:
37 if implantation
.statut
== 2:
39 if implantation
.statut
== 3:
40 statut
= u
"Ouverte imminente"
42 return u
"%s (%s) [%s]" % (implantation
.nom
, implantation
.id, statut
)
44 def format_item(self
, implantation
):
45 return self
.format_result(implantation
)
47 def get_objects(self
, ids
):
48 return ref
.Implantation
.objects
.filter(id__in
=ids
)
50 class TypePoste(object):
52 def get_query(self
,q
,request
):
53 f
= Q(nom__icontains
=q
) |
Q(nom_feminin__icontains
=q
) |
Q(famille_emploi__nom__icontains
=q
)
54 typepostes
= rh
.TypePoste
.objects
.filter(f
)
57 def format_result(self
, typeposte
):
58 return unicode(typeposte
)
60 def format_item(self
, typeposte
):
61 return self
.format_result(typeposte
)
63 def get_objects(self
, ids
):
64 return rh
.TypePoste
.objects
.filter(id__in
=ids
)
68 def get_query(self
,q
,request
):
69 f
= Q(nom__icontains
=q
) |
Q(type_poste__nom__icontains
=q
) |
Q(rh_dossiers__employe__nom__icontains
=q
) |
Q(rh_dossiers__employe__prenom__icontains
=q
)
70 postes
= rh
.Poste
.objects
.filter(f
).distinct()
73 def format_result(self
, poste
):
76 def format_item(self
, poste
):
77 return self
.format_result(poste
)
79 def get_objects(self
, ids
):
80 return rh
.Poste
.objects
.filter(id__in
=ids
)
82 class ValeurPoint(object):
84 def get_query(self
,q
,request
):
85 f
= Q(devise__code__icontains
=q
) |
Q(implantation__nom__icontains
=q
)
86 points
= rh
.ValeurPoint
.objects
.select_related('devise', 'implantation').filter(f
)
89 def format_result(self
, point
):
92 def format_item(self
, point
):
93 return self
.format_result(point
)
95 def get_objects(self
, ids
):
96 return rh
.ValeurPoint
.objects
.filter(id__in
=ids
)
98 class Employe(object):
100 def get_query(self
,q
,request
):
101 f
= Q(nom__icontains
=q
) |
Q(prenom__icontains
=q
) |
Q(nom_affichage__icontains
=q
)
102 employes
= rh
.Employe
.objects
.filter(f
)
105 def format_result(self
, employe
):
106 return unicode(employe
)
108 def format_item(self
, employe
):
109 return self
.format_result(employe
)
111 def get_objects(self
, ids
):
112 return rh
.Employe
.objects
.filter(id__in
=ids
)
114 class Dossier(object):
116 def get_query(self
,q
,request
):
117 f
= Q(poste__nom
=q
) |
Q(poste__type_poste__nom
=q
) |
Q(employe__nom__icontains
=q
) |
Q(employe__prenom__icontains
=q
) |
Q(employe__nom_affichage__icontains
=q
)
118 dossiers
= rh
.Dossier
.objects
.filter(f
)
121 def format_result(self
, dossier
):
122 return unicode(dossier
)
124 def format_item(self
, dossier
):
125 return self
.format_result(dossier
)
127 def get_objects(self
, ids
):
128 return rh
.Dossier
.objects
.filter(id__in
=ids
)