1 # -*- encoding: utf-8 -*-
3 from collections
import defaultdict
6 from django
.db
import models
7 from django
import forms
8 from django
.core
.urlresolvers
import reverse
9 from django
.contrib
import admin
10 from django
.conf
import settings
11 from django
.db
.models
import Q
12 from django
.template
.defaultfilters
import date
13 from ajax_select
import make_ajax_form
14 from auf
.django
.metadata
.admin
import AUFMetadataAdminMixin
, AUFMetadataInlineAdminMixin
, AUF_METADATA_READONLY_FIELDS
15 from forms
import ContratForm
, AyantDroitForm
, EmployeAdminForm
, AjaxSelect
16 from dae
.utils
import get_employe_from_user
17 from change_list
import ChangeList
18 from groups
import grp_drh
22 class DateRangeMixin(object):
23 prefixe_recherche_temporelle
= ""
24 def get_changelist(self
, request
, **kwargs
):
25 if request
.META
.has_key('HTTP_REFERER'):
26 referer
= request
.META
['HTTP_REFERER']
27 referer
= "/".join(referer
.split('/')[3:])
28 referer
= "/%s" % referer
.split('?')[0]
29 change_list_view
= 'admin:%s_%s_changelist' % (self
.model
._meta
.app_label
, self
.model
.__name__
.lower())
30 if referer
!= reverse(change_list_view
):
31 params
= request
.GET
.copy()
32 today
= datetime
.date
.today()
33 params
.update({'statut' : 'Actif'})
37 # Override of the InlineModelAdmin to support the link in the tabular inline
38 class LinkedInline(admin
.options
.InlineModelAdmin
):
39 template
= "admin/linked.html"
40 admin_model_path
= None
42 def __init__(self
, *args
):
43 super(LinkedInline
, self
).__init__(*args
)
44 if self
.admin_model_path
is None:
45 self
.admin_model_path
= self
.model
.__name__
.lower()
48 class ProtectRegionMixin(object):
50 def queryset(self
, request
):
51 from dae
.workflow
import grp_drh
, grp_correspondants_rh
52 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
54 if request
.user
.is_superuser
:
57 user_groups
= request
.user
.groups
.all()
59 if grp_drh
in user_groups
:
62 if grp_correspondants_rh
in user_groups
:
63 employe
= get_employe_from_user(request
.user
)
64 q
= Q(**{self
.model
.prefix_implantation
: employe
.implantation
.region
})
65 qs
= qs
.filter(q
).distinct()
69 def has_change_permission(self
, request
, obj
=None):
70 user_groups
= request
.user
.groups
.all()
72 # Lock pour autoriser uniquement les DRH à utiliser RH
73 if not request
.user
.is_superuser
and not grp_drh
in user_groups
:
76 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
81 ids
= [o
.id for o
in self
.queryset(request
)]
87 class ReadOnlyInlineMixin(object):
88 def get_readonly_fields(self
, request
, obj
=None):
89 return [f
.name
for f
in self
.model
._meta
.fields
if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
92 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
99 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', 'lien_parente', )
104 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
105 readonly_fields
= ('owner', )
106 model
= rh
.AyantDroitCommentaire
110 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
116 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
117 template
= "admin/rh/dossier/linked.html"
118 exclude
= AUF_METADATA_READONLY_FIELDS
123 def has_add_permission(self
, request
=None):
126 def has_change_permission(self
, request
, obj
=None):
129 def has_delete_permission(self
, request
, obj
=None):
133 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
134 readonly_fields
= ('owner', )
135 model
= rh
.DossierCommentaire
139 class DossierPieceInline(admin
.TabularInline
):
140 model
= rh
.DossierPiece
144 class EmployeInline(admin
.TabularInline
):
147 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
148 readonly_fields
= ('owner', )
149 model
= rh
.EmployeCommentaire
153 class EmployePieceInline(admin
.TabularInline
):
154 model
= rh
.EmployePiece
158 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
159 readonly_fields
= ('owner', )
160 model
= rh
.PosteCommentaire
164 class PosteFinancementInline(admin
.TabularInline
):
165 model
= rh
.PosteFinancement
168 class PostePieceInline(admin
.TabularInline
):
169 model
= rh
.PostePiece
172 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
173 model
= rh
.Remuneration
177 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
181 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
185 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
186 model
= rh
.PosteComparaison
189 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
190 list_display
= ('_classement', '_date_modification', 'user_modification', )
191 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
193 'fields': ('type', 'echelon', 'degre', 'coefficient', )
197 def _classement(self
, obj
):
199 _classement
.short_description
= u
"Classement"
201 def _date_modification(self
, obj
):
202 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
203 _date_modification
.short_description
= u
'date modification'
204 _date_modification
.admin_order_field
= 'date_modification'
206 class CommentaireAdmin(admin
.ModelAdmin
):
210 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
211 list_display
= ('code', 'nom', '_archive', '_date_modification', 'user_modification',)
212 list_filter
= ('archive', )
213 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
215 'fields': ('code', 'nom', 'archive', ),
219 def queryset(self
, request
):
220 return self
.model
._base_manager
222 def _archive(self
, obj
):
227 _archive
.short_description
= u
'Archivé'
229 def _date_modification(self
, obj
):
230 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
231 _date_modification
.short_description
= u
'date modification'
232 _date_modification
.admin_order_field
= 'date_modification'
234 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
235 alphabet_filter
= 'employe__nom'
236 search_fields
= ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin')
245 '_date_modification',
248 list_display_links
= ('_nom',)
250 'poste__implantation__region',
251 'poste__implantation',
252 'poste__type_poste__famille_emploi',
254 'rh_contrats__type_contrat',
256 inlines
= (DossierPieceInline
, ContratInline
,
258 DossierCommentaireInline
,
260 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
262 'fields': ('employe', 'poste', 'statut', 'organisme_bstg',)
265 'fields': ('statut_residence', 'remplacement', 'remplacement_de', )
268 'fields': ('classement', ('regime_travail', 'regime_travail_nb_heure_semaine'),)
270 ('Occupation du Poste par cet Employe', {
271 'fields': (('date_debut', 'date_fin'), )
274 form
= make_ajax_form(rh
.Dossier
, {
275 'employe' : 'employes',
277 'remplacement_de' : 'dossiers',
280 def lookup_allowed(self
, key
, value
):
282 'employe__nom__istartswith',
283 'poste__implantation__region__id__exact',
284 'poste__implantation__id__exact',
285 'poste__type_poste__id__exact',
286 'poste__type_poste__famille_emploi__id__exact',
287 'rh_contrats__type_contrat__id__exact',
293 _id
.short_description
= u
"#"
294 _id
.admin_order_field
= "id"
297 return "%d : %s %s" % \
298 (obj
.date_debut
.year
, obj
.employe
.nom
.upper(), obj
.employe
.prenom
)
299 _nom
.allow_tags
= True
300 _nom
.short_description
= u
"Dossier"
303 def _apercu(self
, d
):
304 apercu_link
= u
"""<a title="Aperçu du dossier" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
305 (reverse('dossier_apercu', args
=(d
.id,)),
309 _apercu
.allow_tags
= True
310 _apercu
.short_description
= u
""
313 def _date_debut(self
, obj
):
314 return date(obj
.date_debut
)
316 _date_debut
.short_description
= u
'Occupation début'
317 _date_debut
.admin_order_field
= 'date_debut'
319 def _date_fin(self
, obj
):
320 return date(obj
.date_fin
)
321 _date_fin
.short_description
= u
'Occupation fin'
322 _date_fin
.admin_order_field
= 'date_fin'
325 def _date_modification(self
, obj
):
326 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
327 _date_modification
.short_description
= u
'date modification'
328 _date_modification
.admin_order_field
= 'date_modification'
330 def _poste(self
, dossier
):
331 link
= u
"""<a title="Aperçu du poste" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a> <a href="%s" title="Modifier le poste">%s</a>""" % \
332 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
334 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
338 _poste
.allow_tags
= True
339 _poste
.short_description
= u
'Poste'
340 _poste
.admin_order_field
= 'poste__nom'
342 def _employe(self
, obj
):
343 employe
= obj
.employe
344 view_link
= reverse('employe_apercu', args
=(employe
.id,))
345 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
348 view
= u
"""<a href="%s" title="Aperçu l'employé" onclick="return showAddAnotherPopup(this);"><img src="%simg/loupe.png" /></a>""" % (view_link
, settings
.STATIC_URL
,)
349 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
350 (view
, edit_link
, style
, employe
)
351 _employe
.allow_tags
= True
352 _employe
.short_description
= u
"Employé"
353 _employe
.admin_order_field
= "employe__nom"
355 def save_formset(self
, request
, form
, formset
, change
):
356 instances
= formset
.save(commit
=False)
357 for instance
in instances
:
358 if instance
.__class__
== rh
.DossierCommentaire
:
359 instance
.owner
= request
.user
360 instance
.date_creation
= datetime
.datetime
.now()
364 class DossierPieceAdmin(admin
.ModelAdmin
):
368 class DossierCommentaireAdmin(admin
.ModelAdmin
):
372 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, ProtectRegionMixin
, admin
.ModelAdmin
,):
373 prefixe_recherche_temporelle
= "rh_dossiers__"
374 alphabet_filter
= 'nom'
375 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
376 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
378 form
= EmployeAdminForm
379 list_display
= ('_id', '_apercu', '_nom', '_dossiers_postes', '_date_modification', 'user_modification', )
380 list_display_links
= ('_nom',)
381 list_filter
= ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', )
382 inlines
= (AyantDroitInline
,
385 EmployeCommentaireInline
)
386 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
388 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
390 ('Informations personnelles', {
391 'fields': ('situation_famille', 'date_entree', )
394 'fields': (('tel_domicile', 'tel_cellulaire'), ('adresse', 'ville'), ('code_postal', 'province'), 'pays', )
398 def _apercu(self
, obj
):
399 return u
"""<a title="Aperçu de l'employé" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
400 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
401 _apercu
.allow_tags
= True
402 _apercu
.short_description
= u
""
405 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
406 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
407 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
408 _nom
.allow_tags
= True
409 _nom
.short_description
= u
"Employé"
410 _nom
.admin_order_field
= "nom"
414 _id
.short_description
= u
"#"
415 _id
.admin_order_field
= "id"
417 def _date_modification(self
, obj
):
418 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
419 _date_modification
.short_description
= u
'date modification'
420 _date_modification
.admin_order_field
= 'date_modification'
422 def _dossiers_postes(self
, obj
):
424 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
425 dossier
= u
"""<a title="Aperçu du dossier" href="%s" onclick="return showAddAnotherPopup(this);" title="Aperçu du dossier"><img src="%simg/loupe.png" /></a><a href="%s">Dossier</a> """ % \
426 ( reverse('dossier_apercu', args
=(d
.id,)),
428 reverse('admin:rh_dossier_change', args
=(d
.id,))
431 poste
= u
"""<a title="Aperçu du poste" href="%s" onclick="return showAddAnotherPopup(this);" title="Aperçu du poste"><img src="%simg/loupe.png" /></a><a href="%s">Poste</a> """ % \
432 ( reverse('poste_apercu', args
=(d
.poste
.id,)),
434 reverse('admin:rh_poste_change', args
=(d
.poste
.id,))
436 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
443 # Dossier terminé en gris non cliquable
444 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
445 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
452 return "<ul>%s</ul>" % "\n".join(l
)
453 _dossiers_postes
.allow_tags
= True
454 _dossiers_postes
.short_description
= u
"Dossiers et postes"
456 def queryset(self
, request
):
457 qs
= super(EmployeAdmin
, self
).queryset(request
)
458 return qs
.select_related(depth
=1).order_by('nom')
460 def save_formset(self
, request
, form
, formset
, change
):
461 instances
= formset
.save(commit
=False)
462 for instance
in instances
:
463 if instance
.__class__
== rh
.EmployeCommentaire
:
464 instance
.owner
= request
.user
465 instance
.date_creation
= datetime
.datetime
.now()
468 class EmployeProxyAdmin(EmployeAdmin
):
469 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
470 list_display_links
= ('_nom',)
472 def _organigramme(self
, obj
):
474 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
475 poste
= u
"""<a title="Aperçu du poste" href="%s" onclick="return showAddAnotherPopup(this);" title="Aperçu du poste"><img src="%simg/loupe.png" /></a><a href="%s">Poste</a> """ % \
476 ( reverse('poste_apercu', args
=(d
.poste
.id,)),
478 reverse('admin:rh_poste_change', args
=(d
.poste
.id,))
480 organigramme
= u
"""<a href="%s">Organigramme</a>""" % (reverse('rho_employe', args
=(d
.poste
.id,)))
481 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
482 (poste
, organigramme
,
488 return "<ul>%s</ul>" % "\n".join(l
)
490 _organigramme
.allow_tags
= True
491 _organigramme
.short_description
= "Organigramme"
495 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
499 class EmployePieceAdmin(admin
.ModelAdmin
):
503 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
504 list_display
= ('nom', '_date_modification', 'user_modification', )
505 inlines
= (TypePosteInline
,)
506 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
512 def _date_modification(self
, obj
):
513 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
514 _date_modification
.short_description
= u
'date modification'
515 _date_modification
.admin_order_field
= 'date_modification'
517 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
518 search_fields
= ('nom',)
519 list_display
= ('nom', 'type', 'pays', '_date_modification', 'user_modification', )
520 list_filter
= ('type', )
521 inlines
= (DossierROInline
,)
522 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
524 'fields': ('nom', 'type', 'pays', )
528 def _date_modification(self
, obj
):
529 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
530 _date_modification
.short_description
= u
'date modification'
531 _date_modification
.admin_order_field
= 'date_modification'
534 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
535 form
= make_ajax_form(rh
.Poste
, {
536 'implantation' : 'implantations',
537 'type_poste' : 'typepostes',
538 'responsable' : 'postes',
539 'valeur_point_min' : 'valeurpoints',
540 'valeur_point_max' : 'valeurpoints',
542 alphabet_filter
= 'nom'
543 search_fields
= ('nom',
544 'implantation__code',
546 'implantation__region__code',
547 'implantation__region__nom',
548 'rh_dossiers__employe__nom',
549 'rh_dossiers__employe__prenom',
561 '_date_modification',
565 'implantation__region',
569 'type_poste__famille_emploi',
572 list_display_links
= ('_nom',)
573 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
575 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste',
576 'service', 'responsable')
579 'fields': (('regime_travail', 'regime_travail_nb_heure_semaine'), )
582 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)
585 'fields': (('classement_min', 'valeur_point_min', 'devise_min', 'salaire_min', 'indemn_min', 'autre_min', ),
586 ('classement_max', 'valeur_point_max' ,'devise_max', 'salaire_max', 'indemn_max', 'autre_max', ),
589 ('Comparatifs de rémunération', {
590 'fields': ('devise_comparaison',
591 ('comp_locale_min', 'comp_locale_max'),
592 ('comp_universite_min', 'comp_universite_max'),
593 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
594 ('comp_ong_min', 'comp_ong_max'),
595 ('comp_autre_min', 'comp_autre_max'))
598 'fields': ('justification',)
600 ('Autres Méta-données', {
601 'fields': ('date_debut', 'date_fin')
605 inlines
= (PosteFinancementInline
,
608 PosteComparaisonInline
,
609 PosteCommentaireInline
, )
612 def lookup_allowed(self
, key
, value
):
615 'date_debut__isnull',
618 'implantation__region__id__exact',
619 'implantation__id__exact',
620 'type_poste__id__exact',
621 'type_poste__famille_emploi__id__exact',
622 'service__id__exact',
630 def _apercu(self
, poste
):
631 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /></a>""" % \
632 (reverse('poste_apercu', args
=(poste
.id,)),
636 _apercu
.allow_tags
= True
637 _apercu
.short_description
= ''
641 _id
.short_description
= '#'
642 _id
.admin_order_field
= 'id'
644 def _service(self
, obj
):
645 if obj
.service
.supprime
:
646 return """<span style="color:red">%s</span>""" % obj
.service
649 _service
.short_description
= 'Service'
650 _service
.allow_tags
= True
652 def _responsable(self
, obj
):
654 responsable
= u
"""<a href="%s" onclick="return showAddAnotherPopup(this)"><img src="%simg/loupe.png" title="Aperçu du poste"></a> <a href="%s">%s</a><br />""" % \
656 reverse('poste_apercu', args
=(obj
.responsable
.id,)),
658 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
665 employeposte_change
= "%s %s" % (obj
.responsable
.rh_dossiers
.all()[0].employe
.nom
.upper(), obj
.responsable
.rh_dossiers
.all()[0].employe
.prenom
)
666 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
667 employe
= u
"""<br /><a href="%s" onclick="return showAddAnotherPopup(this)"><img src="%simg/loupe.png" title="Aperçu de l'employé"></a> <a href="%s">%s</a>""" % \
669 reverse('employe_apercu', args
=(employe_id
,)),
671 reverse('admin:rh_employe_change', args
=(employe_id
,)),
677 return "%s %s" % (responsable
, employe
)
678 _responsable
.short_description
= 'Responsable'
679 _responsable
.allow_tags
= True
681 def _nom(self
, poste
):
682 return """<a href="%s">%s</a>""" % \
683 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
686 _nom
.allow_tags
= True
687 _nom
.short_description
= u
'Nom'
688 _nom
.admin_order_field
= 'nom'
690 def _date_modification(self
, obj
):
691 return date(obj
.date_modification
)
692 _date_modification
.short_description
= u
'date modification'
693 _date_modification
.admin_order_field
= 'date_modification'
695 def _occupe_par(self
, obj
):
696 """Formatte la méthode Poste.occupe_par() pour l'admin"""
698 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.now():
700 employes
= obj
.occupe_par()
704 link
= "<a href='%s' title='Aperçu de l\'employer' onclick='return showAddAnotherPopup(this)'><img src='%simg/loupe.png' /></a> <a href='%s'>%s</a>" % \
705 (reverse('employe_apercu', args
=(e
.id,)),
707 reverse('admin:rh_employe_change', args
=(e
.id,)),
711 output
= "\n<br />".join(l
)
713 _occupe_par
.allow_tags
= True
714 _occupe_par
.short_description
= "Occupé par"
716 def save_formset(self
, request
, form
, formset
, change
):
717 instances
= formset
.save(commit
=False)
718 for instance
in instances
:
719 if instance
.__class__
== rh
.PosteCommentaire
:
720 instance
.owner
= request
.user
721 instance
.date_creation
= datetime
.datetime
.now()
726 class PosteCommentaireAdmin(admin
.ModelAdmin
):
730 class PosteFinancementAdmin(admin
.ModelAdmin
):
734 class PostePieceAdmin(admin
.ModelAdmin
):
738 class RemunerationAdmin(admin
.ModelAdmin
):
742 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
743 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
745 'fields': ('employe', 'implantation', ),
750 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
751 list_display
= ('nom', '_archive', '_date_modification', 'user_modification', )
752 list_filter
= ('archive', )
753 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
755 'fields': ('nom', 'archive', ),
759 def _archive(self
, obj
):
764 _archive
.short_description
= u
'Archivé'
766 def _date_modification(self
, obj
):
767 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
768 _date_modification
.short_description
= u
'date modification'
769 _date_modification
.admin_order_field
= 'date_modification'
772 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
773 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
774 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
776 'fields': ('code', 'nom', ),
780 def _date_modification(self
, obj
):
781 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
782 _date_modification
.short_description
= u
'date modification'
783 _date_modification
.admin_order_field
= 'date_modification'
785 class TauxChangeAdmin(admin
.ModelAdmin
):
786 list_display
= ('taux', 'devise', 'annee', '_date_modification', 'user_modification', )
787 list_filter
= ('devise', )
788 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
790 'fields': ('taux', 'devise', 'annee', ),
794 def _date_modification(self
, obj
):
795 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
796 _date_modification
.short_description
= u
'date modification'
797 _date_modification
.admin_order_field
= 'date_modification'
799 class TypeContratAdmin(admin
.ModelAdmin
):
800 list_display
= ('nom', 'nom_long', '_date_modification', 'user_modification', )
801 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
803 'fields': ('nom', 'nom_long', ),
807 def _date_modification(self
, obj
):
808 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
809 _date_modification
.short_description
= u
'date modification'
810 _date_modification
.admin_order_field
= 'date_modification'
813 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
814 search_fields
= ('nom', 'nom_feminin', )
815 list_display
= ('nom', 'famille_emploi', '_date_modification', 'user_modification', )
816 list_filter
= ('famille_emploi', )
817 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
819 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
823 def _date_modification(self
, obj
):
824 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
825 _date_modification
.short_description
= u
'date modification'
826 _date_modification
.admin_order_field
= 'date_modification'
829 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
830 list_display
= ('nom', 'type_paiement', 'nature_remuneration', '_date_modification', 'user_modification', )
831 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
833 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
837 def _date_modification(self
, obj
):
838 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
839 _date_modification
.short_description
= u
'date modification'
840 _date_modification
.admin_order_field
= 'date_modification'
843 class TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
844 list_display
= ('nom', '_date_modification', 'user_modification', )
845 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
851 def _date_modification(self
, obj
):
852 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
853 _date_modification
.short_description
= u
'date modification'
854 _date_modification
.admin_order_field
= 'date_modification'
857 class ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
858 list_display
= ('_devise_code', '_devise_nom', 'annee', 'valeur', '_date_modification', 'user_modification', )
859 list_filter
= ('annee', 'devise', )
860 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
862 'fields': ('valeur', 'devise', 'implantation', 'annee', )
866 def _date_modification(self
, obj
):
867 return date(obj
.date_modification
) if obj
.date_modification
is not None else "(aucune)"
868 _date_modification
.short_description
= u
'date modification'
869 _date_modification
.admin_order_field
= 'date_modification'
871 def _devise_code(self
, obj
):
872 return obj
.devise
.code
873 _devise_code
.short_description
= "Code de la devise"
875 def _devise_nom(self
, obj
):
876 return obj
.devise
.nom
877 _devise_nom
.short_description
= "Nom de la devise"
880 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
881 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
882 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
883 admin
.site
.register(rh
.EmployeProxy
, EmployeProxyAdmin
)
884 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
885 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
886 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
887 admin
.site
.register(rh
.Poste
, PosteAdmin
)
888 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
889 admin
.site
.register(rh
.Service
, ServiceAdmin
)
890 admin
.site
.register(rh
.Statut
, StatutAdmin
)
891 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
892 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
893 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
894 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
895 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
896 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)