conflit réglé merge master et regionalisation
[auf_rh_dae.git] / project / rh / catalogues.py
CommitLineData
105dd778
OL
1# -*- encoding: utf-8 -*-
2
3from django.db.models import Q
e949324b 4
105dd778 5from auf.django.references import models as ref
4ba84959
EMS
6
7from project.rh import models as rh
8
105dd778
OL
9
10class Pays(object):
ad1eb1db 11 fk_key = "code"
105dd778 12
4ba84959
EMS
13 def get_query(self, q, request):
14 pays = ref.Pays.objects.filter(
15 Q(nom__icontains=q) | Q(code__icontains=q)
16 )
105dd778
OL
17 return pays
18
19 def format_result(self, pays):
20 return unicode(pays)
21
22 def format_item(self, pays):
23 return self.format_result(pays)
24
25 def get_objects(self, ids):
26 return ref.Pays.objects.filter(code__in=ids)
27
28
29class Implantation(object):
30
4ba84959
EMS
31 def get_query(self, q, request):
32 implantations = ref.Implantation.objects.filter(
33 Q(nom__icontains=q) | Q(nom_court__icontains=q) |
34 Q(nom_long__icontains=q) | Q(region__nom__icontains=q)
35 )
105dd778
OL
36 return implantations
37
38 def format_result(self, implantation):
94af2307
OL
39 statut = implantation.statut
40 if implantation.statut == 0:
94ecd5bb 41 statut = u"Jamais ouverte OU fermée"
94af2307
OL
42 if implantation.statut == 1:
43 statut = u"Ouverte"
44 if implantation.statut == 2:
45 statut = u"Fermée"
46 if implantation.statut == 3:
94ecd5bb 47 statut = u"Ouverte imminente"
94af2307
OL
48
49 return u"%s (%s) [%s]" % (implantation.nom, implantation.id, statut)
105dd778
OL
50
51 def format_item(self, implantation):
52 return self.format_result(implantation)
53
54 def get_objects(self, ids):
55 return ref.Implantation.objects.filter(id__in=ids)
56
4ba84959 57
105dd778
OL
58class TypePoste(object):
59
4ba84959
EMS
60 def get_query(self, q, request):
61 typepostes = rh.TypePoste.objects.filter(
62 Q(nom__icontains=q) | Q(nom_feminin__icontains=q) |
63 Q(categorie_emploi__nom__icontains=q)
64 )
105dd778
OL
65 return typepostes
66
67 def format_result(self, typeposte):
68 return unicode(typeposte)
69
70 def format_item(self, typeposte):
71 return self.format_result(typeposte)
72
73 def get_objects(self, ids):
74 return rh.TypePoste.objects.filter(id__in=ids)
75
4ba84959 76
105dd778
OL
77class Poste(object):
78
4ba84959
EMS
79 def get_query(self, q, request):
80 postes = rh.Poste.objects.filter(
81 Q(nom__icontains=q) | Q(type_poste__nom__icontains=q) |
82 Q(rh_dossiers__employe__nom__icontains=q) |
83 Q(rh_dossiers__employe__prenom__icontains=q)
84 ).distinct()
105dd778
OL
85 return postes
86
87 def format_result(self, poste):
88 return unicode(poste)
89
90 def format_item(self, poste):
91 return self.format_result(poste)
92
93 def get_objects(self, ids):
94 return rh.Poste.objects.filter(id__in=ids)
95
4ba84959 96
105dd778
OL
97class ValeurPoint(object):
98
4ba84959
EMS
99 def get_query(self, q, request):
100 points = rh.ValeurPoint.objects \
101 .select_related('devise', 'implantation') \
102 .filter(
103 Q(devise__code__icontains=q) |
104 Q(implantation__nom__icontains=q)
105 )
105dd778
OL
106 return points
107
108 def format_result(self, point):
109 return unicode(point)
110
111 def format_item(self, point):
112 return self.format_result(point)
113
114 def get_objects(self, ids):
115 return rh.ValeurPoint.objects.filter(id__in=ids)
0b0545bd 116
4ba84959 117
0b0545bd
OL
118class Employe(object):
119
4ba84959
EMS
120 def get_query(self, q, request):
121 employes = rh.Employe.objects.filter(
122 Q(nom__icontains=q) | Q(prenom__icontains=q) |
123 Q(nom_affichage__icontains=q)
124 )
0b0545bd
OL
125 return employes
126
127 def format_result(self, employe):
128 return unicode(employe)
129
130 def format_item(self, employe):
131 return self.format_result(employe)
132
133 def get_objects(self, ids):
134 return rh.Employe.objects.filter(id__in=ids)
135
4ba84959 136
0b0545bd
OL
137class Dossier(object):
138
4ba84959
EMS
139 def get_query(self, q, request):
140 dossiers = rh.Dossier.objects.filter(
141 Q(poste__nom=q) | Q(poste__type_poste__nom=q) |
142 Q(employe__nom__icontains=q) | Q(employe__prenom__icontains=q) |
143 Q(employe__nom_affichage__icontains=q)
144 )
0b0545bd
OL
145 return dossiers
146
147 def format_result(self, dossier):
148 return unicode(dossier)
149
150 def format_item(self, dossier):
151 return self.format_result(dossier)
152
153 def get_objects(self, ids):
154 return rh.Dossier.objects.filter(id__in=ids)