79d6e66215b29d51e0f3acea1fd071025056f51a
[auf_rh_dae.git] / project / rh / catalogues.py
1 # -*- encoding: utf-8 -*-
2
3 from django.db.models import Q
4 from auf.django.references import models as ref
5 import models as rh
6
7 class Pays(object):
8
9 def get_query(self,q,request):
10 pays = ref.Pays.objects.filter(Q(nom__icontains=q) | Q(code__icontains=q))
11 return pays
12
13 def format_result(self, pays):
14 return unicode(pays)
15
16 def format_item(self, pays):
17 return self.format_result(pays)
18
19 def get_objects(self, ids):
20 return ref.Pays.objects.filter(code__in=ids)
21
22
23 class Implantation(object):
24
25 def get_query(self,q,request):
26 f = Q(nom__icontains=q) | Q(nom_court__icontains=q) | Q(nom_long__icontains=q) | Q(region__nom__icontains=q)
27 implantations = ref.Implantation.objects.filter(f)
28 return implantations
29
30 def format_result(self, implantation):
31 return unicode(implantation)
32
33 def format_item(self, implantation):
34 return self.format_result(implantation)
35
36 def get_objects(self, ids):
37 return ref.Implantation.objects.filter(id__in=ids)
38
39 class TypePoste(object):
40
41 def get_query(self,q,request):
42 f = Q(nom__icontains=q) | Q(nom_feminin__icontains=q) | Q(famille_emploi__nom__icontains=q)
43 typepostes = rh.TypePoste.objects.filter(f)
44 return typepostes
45
46 def format_result(self, typeposte):
47 return unicode(typeposte)
48
49 def format_item(self, typeposte):
50 return self.format_result(typeposte)
51
52 def get_objects(self, ids):
53 return rh.TypePoste.objects.filter(id__in=ids)
54
55 class Poste(object):
56
57 def get_query(self,q,request):
58 f = Q(nom__icontains=q) | Q(type_poste__nom__icontains=q)
59 postes = rh.Poste.objects.filter(f)
60 return postes
61
62 def format_result(self, poste):
63 return unicode(poste)
64
65 def format_item(self, poste):
66 return self.format_result(poste)
67
68 def get_objects(self, ids):
69 return rh.Poste.objects.filter(id__in=ids)
70
71 class ValeurPoint(object):
72
73 def get_query(self,q,request):
74 f = Q(devise__code__icontains=q) | Q(implantation__nom__icontains=q)
75 points = rh.ValeurPoint.objects.select_related('devise', 'implantation').filter(f)
76 return points
77
78 def format_result(self, point):
79 return unicode(point)
80
81 def format_item(self, point):
82 return self.format_result(point)
83
84 def get_objects(self, ids):
85 return rh.ValeurPoint.objects.filter(id__in=ids)