From e49ac9470f3f7691955bcfb54323bbd6d50b9690 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Caissy Date: Fri, 10 Feb 2012 15:26:42 -0600 Subject: [PATCH] Normalisation de la liste pour employes, dossiers et postes --- project/rh/admin.py | 65 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/project/rh/admin.py b/project/rh/admin.py index 68fdbc5..2ecc1f1 100644 --- a/project/rh/admin.py +++ b/project/rh/admin.py @@ -274,6 +274,8 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad search_fields = ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin') list_display = ( '_id', + '_apercu', + '_nom', '_poste', '_employe', '_date_debut', @@ -281,6 +283,7 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad '_date_modification', 'user_modification', ) + list_display_links = ('_nom',) list_filter = ( 'poste__implantation__region', 'poste__implantation', @@ -329,20 +332,26 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad ): return True - def _id(self, d): + def _id(self, obj): + return obj.id + _id.short_description = u"#" + _id.admin_order_field = "id" + + def _nom(self, obj): + return "%d : %s %s" % \ + (obj.date_debut.year, obj.employe.nom.upper(), obj.employe.prenom) + _nom.allow_tags = True + _nom.short_description = u"Dossier" + + + def _apercu(self, d): apercu_link = u"""""" % \ (reverse('dossier_apercu', args=(d.id,)), settings.STATIC_URL, ) - link = u"""%s %s""" % \ - (apercu_link, - reverse('admin:rh_dossier_change', args=(d.id,)), - d.id, - ) - return link - _id.allow_tags = True - _id.short_description = u"Dossier #" - _id.admin_order_field = 'id' + return apercu_link + _apercu.allow_tags = True + _apercu.short_description = u"" def _date_debut(self, obj): @@ -384,7 +393,7 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad return u"""%s%s""" % \ (view, edit_link, style, employe) _employe.allow_tags = True - _employe.short_description = u"Employé (NOM Prénom [code])" + _employe.short_description = u"Employé" _employe.admin_order_field = "employe__nom" def save_formset(self, request, form, formset, change): @@ -410,7 +419,8 @@ class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad search_fields = ('id', 'nom', 'prenom', 'nom_affichage', ) ordering = ('nom', ) form = EmployeAdminForm - list_display = ('_apercu', '_nom', '_dossiers', '_date_modification', 'user_modification', ) + list_display = ('_id', '_apercu', '_nom', '_dossiers', '_date_modification', 'user_modification', ) + list_display_links = ('_nom',) list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', 'rh_dossiers__date_debut', 'rh_dossiers__date_fin') date_borne_gauche = 'rh_dossiers__date_debut' date_borne_droite = 'rh_dossiers__date_fin' @@ -435,16 +445,20 @@ class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, ad (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL) _apercu.allow_tags = True _apercu.short_description = u"" - _apercu.admin_order_field = "" def _nom(self, obj): edit_link = reverse('admin:rh_employe_change', args=(obj.id,)) return u"""%s""" % \ - (edit_link, obj) + (edit_link, "%s %s" % (obj.nom.upper(), obj.prenom)) _nom.allow_tags = True - _nom.short_description = u"Employé (NOM Prénom [code])" + _nom.short_description = u"Employé" _nom.admin_order_field = "nom" + def _id(self, obj): + return obj.id + _id.short_description = u"#" + _id.admin_order_field = "id" + def _date_modification(self, obj): return date(obj.date_modification) if obj.date_modification is not None else "(aucune)" _date_modification.short_description = u'date modification' @@ -545,6 +559,7 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, admi 'rh_dossiers__employe__prenom', ) list_display = ( + '_id', '_apercu', '_nom', '_occupe_par', @@ -565,6 +580,7 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, admi 'date_fin', 'vacant', ) + list_display_links = ('_nom',) fieldsets = AUFMetadataAdminMixin.fieldsets + ( (None, { 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste', @@ -625,20 +641,23 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin, ProtectRegionMixin, admi (reverse('poste_apercu', args=(poste.id,)), settings.STATIC_URL, ) - edit_link = u"""%s""" % \ - (reverse('admin:rh_poste_change', args=(poste.id,)), - poste.id, - ) - return view_link + edit_link + return view_link _apercu.allow_tags = True - _apercu.short_description = 'Poste __#' - _apercu.admin_order_field = 'id' + _apercu.short_description = '' + + def _id(self, obj): + return "%s" % obj.id + _id.short_description = '#' + _id.admin_order_field = 'id' def _service(self, obj): return obj.service def _nom(self, poste): - return poste.nom + return """%s""" % \ + (reverse('admin:rh_poste_change', args=(poste.id,)), + poste.nom + ) _nom.allow_tags = True _nom.short_description = u'Nom' _nom.admin_order_field = 'nom' -- 1.7.10.4