dossiers: add more details to school for a new socialisation schedule

Fixes #4149
This commit is contained in:
Jérôme Schneider 2014-06-18 14:59:06 +02:00
parent 66d9afe6e6
commit 3355038a89
3 changed files with 29 additions and 5 deletions

View File

@ -34,9 +34,6 @@ class PatientRecordLookup(CalebasseLookup):
return chain(qs, closed)
def format_match(self,obj):
return self.format_item_display(texte)
def get_result(self, obj):
return self.format_item_display(obj)

View File

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import itertools
from calebasse.lookups import CalebasseLookup
from calebasse.personnes.models import Worker
from calebasse.ressources.models import Service
from calebasse.ressources.models import Service, School
class FakeGroup:
pk = None
@ -56,3 +57,28 @@ class WorkerOrGroupLookup(CalebasseLookup):
class AllWorkerOrGroupLookup(WorkerOrGroupLookup):
enabled = False
class SchoolLookup(CalebasseLookup):
model = School
search_field = 'name'
def get_result(self, obj):
return self.format_item_display(obj)
def format_match(self, obj):
return self.format_item_display(obj)
def format_item_display(self, obj):
text = ''
if obj.school_type.name != 'Inconnu':
text = unicode(obj.school_type) + ' ' + obj.name
else:
text = obj.name
if obj.address:
text += " - " + obj.address
if obj.private:
text += " (Privé)"
else:
text += " (Public)"
return text

View File

@ -235,7 +235,8 @@ AJAX_LOOKUP_CHANNELS = {
#'patientrecord' : {'model':'dossiers.PatientRecord', 'search_field':'display_name'}
#'coordinators' : {'model':'dossiers.PatientRecord', 'search_field':'display_name'}
'patientrecord' : ('calebasse.dossiers.lookups', 'PatientRecordLookup'),
'school' : {'model':'ressources.School', 'search_field':'name'},
#'school' : {'model':'ressources.School', 'search_field':'name'},
'school' : ('calebasse.ressources.lookups', 'SchoolLookup'),
'addresses' : ('calebasse.dossiers.lookups', 'PatientAddressLookup'),
'worker-or-group' : ('calebasse.ressources.lookups', 'WorkerOrGroupLookup'),
'all-worker-or-group' : ('calebasse.ressources.lookups', 'AllWorkerOrGroupLookup'),