conflit réglé merge master et regionalisation
[auf_rh_dae.git] / project / rh / admin.py
index 0d4f547..4d63671 100644 (file)
@@ -1,25 +1,28 @@
 # -*- encoding: utf-8 -*-
 
 import datetime
-
-from ajax_select import make_ajax_form
-from auf.django.metadata.admin import \
-        AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, \
-        AUF_METADATA_READONLY_FIELDS
+        
 from django.core.urlresolvers import reverse
 from django.contrib import admin
 from django.conf import settings
 from django.db.models import Q, Count
 from django.template.defaultfilters import date
 
+from ajax_select import make_ajax_form
+
+from auf.django.metadata.admin import \
+        AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, \
+        AUF_METADATA_READONLY_FIELDS
 import auf.django.references.models as ref
-import models as rh
-from forms import \
+
+from project import groups
+from project.decorators import in_drh_or_admin
+from project.groups import get_employe_from_user
+
+import project.rh.models as rh
+from project.rh.forms import \
         ContratForm, AyantDroitForm, EmployeAdminForm, AjaxSelect, DossierForm
-from dae.utils import get_employe_from_user
-from change_list import ChangeList
-from project.rh import groups
-from decorators import in_drh_or_admin
+from project.rh.change_list import ChangeList
 
 
 class BaseAdmin(admin.ModelAdmin):
@@ -418,7 +421,7 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin,
         apercu_link = u"""<a title="Aperçu du dossier"
                              onclick="return showAddAnotherPopup(this);"
                              href='%s'>
-                             <img src="%simg/loupe.png" />
+                             <img src="%simg/dossier-apercu.png" />
                              </a>""" % \
                 (reverse('dossier_apercu', args=(d.id,)),
                  settings.STATIC_URL,
@@ -464,7 +467,7 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin,
     def _poste(self, dossier):
         link = u"""<a title="Aperçu du poste"
                       onclick="return showAddAnotherPopup(this);"
-                      href='%s'><img src="%simg/loupe.png" />
+                      href='%s'><img src="%simg/poste-apercu.png" />
                     </a>
                     <a href="%s" title="Modifier le poste">%s</a>""" % \
                 (reverse('poste_apercu', args=(dossier.poste.id,)),
@@ -486,7 +489,7 @@ class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin,
         view = u"""<a href="%s"
                       title="Aperçu l'employé"
                       onclick="return showAddAnotherPopup(this);">
-                      <img src="%simg/loupe.png" />
+                      <img src="%simg/employe-apercu.png" />
                     </a>""" % (view_link, settings.STATIC_URL,)
         return u"""%s<a href='%s' style="%s;">%s</a>""" % \
         (view, edit_link, style, employe)
@@ -573,7 +576,7 @@ class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin,
         return u"""<a title="Aperçu de l'employé"
                       onclick="return showAddAnotherPopup(this);"
                       href='%s'>
-                      <img src="%simg/loupe.png" />
+                      <img src="%simg/employe-apercu.png" />
                     </a>""" % \
             (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL)
     _apercu.allow_tags = True
@@ -605,7 +608,7 @@ class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin,
                              href="%s"
                              onclick="return showAddAnotherPopup(this);"
                              title="Aperçu du dossier">
-                             <img src="%simg/loupe.png" />
+                             <img src="%simg/dossier-apercu.png" />
                           </a>
                           <a href="%s">Dossier</a>
                           &nbsp;""" % \
@@ -617,7 +620,7 @@ class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin,
                            href="%s"
                            onclick="return showAddAnotherPopup(this);"
                            title="Aperçu du poste">
-                           <img src="%simg/loupe.png" />
+                           <img src="%simg/poste-apercu.png" />
                         </a>
                         <a href="%s">Poste</a>
                         &nbsp;""" % \
@@ -865,7 +868,7 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
         view_link = u"""<a onclick="return showAddAnotherPopup(this);"
                            title="Aperçu du poste"
                            href='%s'>
-                        <img src="%simg/loupe.png" />
+                        <img src="%simg/poste-apercu.png" />
                         </a>""" % \
                 (reverse('poste_apercu', args=(poste.id,)),
                  settings.STATIC_URL,)
@@ -905,7 +908,7 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
         try:
             responsable = u"""<a href="%s"
                                  onclick="return showAddAnotherPopup(this)">
-                                <img src="%simg/loupe.png"
+                                <img src="%simg/poste-apercu.png"
                                      title="Aperçu du poste" />
                               </a>
                               <a href="%s">%s</a>
@@ -923,7 +926,7 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
             employe_html = u"""<br />
                     <a href="%s"
                        onclick="return showAddAnotherPopup(this)">
-                       <img src="%simg/loupe.png"
+                       <img src="%simg/employe-apercu.png"
                             title="Aperçu de l'employé">
                     </a>
                     <a href="%s">%s</a>""" % \
@@ -966,9 +969,9 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
             l = []
             for e in employes:
                 link = u"""<a href='%s'
-                              title='Aperçu de l\'employer'
+                              title='Aperçu de l\'employé'
                               onclick='return showAddAnotherPopup(this)'>
-                              <img src='%simg/loupe.png' />
+                              <img src='%simg/employe-apercu.png' />
                             </a>
                             <a href='%s'>%s</a>""" % \
                      (reverse('employe_apercu', args=(e.id,)),
@@ -1000,11 +1003,21 @@ class ResponsableInline(admin.TabularInline):
 class ResponsableImplantationAdmin(BaseAdmin):
     actions = None
     list_filter = ('region', 'statut', )
-    list_display = ('nom', 'statut', '_responsable', )
+    list_display = ('_region', '_nom', 'statut', '_responsable', )
     readonly_fields = ('nom', )
     fields = ('nom', )
     inlines = (ResponsableInline, )
-
+    
+    def _region(self, obj):
+        return obj.region.code
+    _region.short_description = u"Région"
+    _region.admin_order_field = 'region__code'
+    
+    def _nom(self, obj):
+        return obj.nom
+    _nom.short_description = u"Implantation"
+    _nom.admin_order_field = 'nom'
+    
     def _responsable(self, obj):
         try:
             employe = obj.responsable.employe