poste etat decorateur
[auf_rh_dae.git] / project / dae / catalogues.py
CommitLineData
3121c13c
OL
1# -*- encoding: utf-8 -*-
2
03b395db 3from rh_v1 import models as rh
3121c13c
OL
4from django.db.models import Q
5
6class Responsable(object):
7
8 def get_query(self,q,request):
03b395db 9 return rh.Poste.objects.filter(
3121c13c
OL
10 Q(poste1__complement1__icontains=q) |
11 Q(type_poste__nom__icontains=q) |
12 Q(poste1__employe__nom__icontains=q) |
13 Q(poste1__employe__prenom__icontains=q)
14 ).distinct()
15
16 def format_result(self, poste):
17 dossiers = poste.poste1.all().order_by("-id")
18 complement1 = ""
19 employe = ""
20 if len(dossiers) > 0:
21 complement1 = dossiers[0].complement1
22 employe = unicode(dossiers[0].employe)
23 return "[%s] %s %s (%s) (%s)" % (poste.implantation.id, poste.type_poste.nom, complement1, poste.id, employe)
24
25 def format_item(self, poste):
26 """ the display of a currently selected object in the area below the search box. html is OK """
27 return self.format_result(poste)
28
29 def get_objects(self, ids):
30 """ given a list of ids, return the objects ordered as you would like them on the admin page.
31 this is for displaying the currently selected items (in the case of a ManyToMany field)
32 """
03b395db
OL
33 return rh.Poste.objects.filter(pk__in=ids)
34
35class Dossier(object):
36
37 def get_query(self,q,request):
38 return rh.Dossier.objects.filter(
39 Q(complement1__icontains=q) |
40 Q(poste1__type_poste__nom__icontains=q) |
41 Q(poste2__type_poste__nom__icontains=q) |
42 Q(employe__nom__icontains=q) |
43 Q(employe__prenom__icontains=q)
44 ).distinct()
45
46 def format_result(self, dossier):
47 return dossier.__unicode__()
48
49 def format_item(self, dossier):
50 """ the display of a currently selected object in the area below the search box. html is OK """
51 return self.format_result(dossier)
52
53 def get_objects(self, ids):
54 """ given a list of ids, return the objects ordered as you would like them on the admin page.
55 this is for displaying the currently selected items (in the case of a ManyToMany field)
56 """
57 return rh.Dossier.objects.filter(pk__in=ids)