1 # -*- encoding: utf-8 -*-
5 from django
.core
.urlresolvers
import reverse
6 from django
.contrib
import admin
7 from django
.conf
import settings
8 from django
.db
.models
import Q
9 from django
.template
.defaultfilters
import date
10 from ajax_select
import make_ajax_form
11 from auf
.django
.metadata
.admin
import AUFMetadataAdminMixin
, \
12 AUFMetadataInlineAdminMixin
, \
13 AUF_METADATA_READONLY_FIELDS
14 from forms
import ContratForm
, AyantDroitForm
, EmployeAdminForm
, AjaxSelect
15 from dae
.utils
import get_employe_from_user
16 from change_list
import ChangeList
17 from groups
import grp_drh
20 import auf
.django
.references
.models
as ref
22 class ImplantationProxy(ref
.Implantation
):
23 """ Proxy utilisé pour les organigrammes par implantation """
26 verbose_name
= u
"Organigramme par implantations"
27 verbose_name_plural
= u
"Organigramme par implantations"
30 class ServiceProxy(rh
.Service
):
31 """ Proxy utilisé pour les organigrammes opar service """
34 verbose_name
= u
"Organigramme par services"
35 verbose_name_plural
= u
"Organigramme par services"
38 class EmployeProxy(rh
.Employe
):
39 """ Proxy utilisé pour les organigrammes des employés """
42 verbose_name
= u
"Organigramme des employés"
43 verbose_name_plural
= u
"Organigramme des employés"
46 class DateRangeMixin(object):
47 prefixe_recherche_temporelle
= ""
49 def get_changelist(self
, request
, **kwargs
):
50 if 'HTTP_REFERER' in request
.META
.keys():
51 referer
= request
.META
['HTTP_REFERER']
52 referer
= "/".join(referer
.split('/')[3:])
53 referer
= "/%s" % referer
.split('?')[0]
54 change_list_view
= 'admin:%s_%s_changelist' % (
55 self
.model
._meta
.app_label
,
56 self
.model
.__name__
.lower(),)
57 if referer
!= reverse(change_list_view
):
58 params
= request
.GET
.copy()
59 params
.update({'statut': 'Actif'})
64 # Override of the InlineModelAdmin to support the link in the tabular inline
65 class LinkedInline(admin
.options
.InlineModelAdmin
):
66 template
= "admin/linked.html"
67 admin_model_path
= None
69 def __init__(self
, *args
):
70 super(LinkedInline
, self
).__init__(*args
)
71 if self
.admin_model_path
is None:
72 self
.admin_model_path
= self
.model
.__name__
.lower()
75 class ProtectRegionMixin(object):
77 def queryset(self
, request
):
78 from dae
.workflow
import grp_drh
, grp_correspondants_rh
79 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
81 if request
.user
.is_superuser
:
84 user_groups
= request
.user
.groups
.all()
86 if grp_drh
in user_groups
:
89 if grp_correspondants_rh
in user_groups
:
90 employe
= get_employe_from_user(request
.user
)
91 q
= Q(**{self
.model
.prefix_implantation
: \
92 employe
.implantation
.region
})
93 qs
= qs
.filter(q
).distinct()
97 def has_change_permission(self
, request
, obj
=None):
98 user_groups
= request
.user
.groups
.all()
100 # Lock pour autoriser uniquement les DRH à utiliser RH
101 if not request
.user
.is_superuser
and not grp_drh
in user_groups
:
104 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
109 ids
= [o
.id for o
in self
.queryset(request
)]
115 class ReadOnlyInlineMixin(object):
117 def get_readonly_fields(self
, request
, obj
=None):
118 return [f
.name
for f
in self
.model
._meta
.fields \
119 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
122 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
123 model
= rh
.AyantDroit
124 form
= AyantDroitForm
131 ('nom_affichage', 'genre'),
139 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
140 admin
.TabularInline
):
141 readonly_fields
= ('owner', )
142 model
= rh
.AyantDroitCommentaire
146 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
152 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
153 template
= "admin/rh/dossier/linked.html"
154 exclude
= AUF_METADATA_READONLY_FIELDS
159 def has_add_permission(self
, request
=None):
162 def has_change_permission(self
, request
, obj
=None):
165 def has_delete_permission(self
, request
, obj
=None):
169 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
170 admin
.TabularInline
):
171 readonly_fields
= ('owner', )
172 model
= rh
.DossierCommentaire
176 class DossierPieceInline(admin
.TabularInline
):
177 model
= rh
.DossierPiece
181 class EmployeInline(admin
.TabularInline
):
185 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
186 admin
.TabularInline
):
187 readonly_fields
= ('owner', )
188 model
= rh
.EmployeCommentaire
192 class EmployePieceInline(admin
.TabularInline
):
193 model
= rh
.EmployePiece
197 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
198 readonly_fields
= ('owner', )
199 model
= rh
.PosteCommentaire
203 class PosteFinancementInline(admin
.TabularInline
):
204 model
= rh
.PosteFinancement
207 class PostePieceInline(admin
.TabularInline
):
208 model
= rh
.PostePiece
211 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
212 model
= rh
.Remuneration
216 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
220 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
224 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
225 model
= rh
.PosteComparaison
228 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
229 list_display
= ('_classement', '_date_modification', 'user_modification', )
230 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
232 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
235 def _classement(self
, obj
):
237 _classement
.short_description
= u
"Classement"
239 def _date_modification(self
, obj
):
240 return date(obj
.date_modification
) \
241 if obj
.date_modification
is not None else "(aucune)"
242 _date_modification
.short_description
= u
'date modification'
243 _date_modification
.admin_order_field
= 'date_modification'
246 class CommentaireAdmin(admin
.ModelAdmin
):
250 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
255 '_date_modification',
258 list_filter
= ('archive', )
259 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
261 'fields': ('code', 'nom', 'archive', ),
265 def queryset(self
, request
):
266 return self
.model
._base_manager
268 def _archive(self
, obj
):
273 _archive
.short_description
= u
'Archivé'
275 def _date_modification(self
, obj
):
276 return date(obj
.date_modification
) \
277 if obj
.date_modification
is not None else "(aucune)"
278 _date_modification
.short_description
= u
'date modification'
279 _date_modification
.admin_order_field
= 'date_modification'
282 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
283 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
284 alphabet_filter
= 'employe__nom'
289 'poste__nom_feminin')
298 '_date_modification',
301 list_display_links
= ('_nom',)
303 'poste__implantation__region',
304 'poste__implantation',
305 'poste__type_poste__famille_emploi',
307 'rh_contrats__type_contrat',
309 inlines
= (DossierPieceInline
, ContratInline
,
311 DossierCommentaireInline
,
313 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
319 'organisme_bstg',)}),
324 'remplacement_de', )}),
328 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
329 ('Occupation du Poste par cet Employe', {
330 'fields': (('date_debut', 'date_fin'), )}
333 form
= make_ajax_form(rh
.Dossier
, {
334 'employe': 'employes',
336 'remplacement_de': 'dossiers',
339 def lookup_allowed(self
, key
, value
):
341 'employe__nom__istartswith',
342 'poste__implantation__region__id__exact',
343 'poste__implantation__id__exact',
344 'poste__type_poste__id__exact',
345 'poste__type_poste__famille_emploi__id__exact',
346 'rh_contrats__type_contrat__id__exact',
352 _id
.short_description
= u
"#"
353 _id
.admin_order_field
= "id"
356 return "%d : %s %s" % (
358 obj
.employe
.nom
.upper(),
360 _nom
.allow_tags
= True
361 _nom
.short_description
= u
"Dossier"
363 def _apercu(self
, d
):
364 apercu_link
= u
"""<a title="Aperçu du dossier"
365 onclick="return showAddAnotherPopup(this);"
367 <img src="%simg/loupe.png" />
369 (reverse('dossier_apercu', args
=(d
.id,)),
373 _apercu
.allow_tags
= True
374 _apercu
.short_description
= u
""
376 def _date_debut(self
, obj
):
377 return date(obj
.date_debut
)
379 _date_debut
.short_description
= u
'Occupation début'
380 _date_debut
.admin_order_field
= 'date_debut'
382 def _date_fin(self
, obj
):
383 return date(obj
.date_fin
)
384 _date_fin
.short_description
= u
'Occupation fin'
385 _date_fin
.admin_order_field
= 'date_fin'
387 def _date_modification(self
, obj
):
388 return date(obj
.date_modification
) \
389 if obj
.date_modification
is not None else "(aucune)"
390 _date_modification
.short_description
= u
'date modification'
391 _date_modification
.admin_order_field
= 'date_modification'
393 def _poste(self
, dossier
):
394 link
= u
"""<a title="Aperçu du poste"
395 onclick="return showAddAnotherPopup(this);"
396 href='%s'><img src="%simg/loupe.png" />
398 <a href="%s" title="Modifier le poste">%s</a>""" % \
399 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
401 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
405 _poste
.allow_tags
= True
406 _poste
.short_description
= u
'Poste'
407 _poste
.admin_order_field
= 'poste__nom'
409 def _employe(self
, obj
):
410 employe
= obj
.employe
411 view_link
= reverse('employe_apercu', args
=(employe
.id,))
412 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
415 view
= u
"""<a href="%s"
416 title="Aperçu l'employé"
417 onclick="return showAddAnotherPopup(this);">
418 <img src="%simg/loupe.png" />
419 </a>""" % (view_link
, settings
.STATIC_URL
,)
420 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
421 (view
, edit_link
, style
, employe
)
422 _employe
.allow_tags
= True
423 _employe
.short_description
= u
"Employé"
424 _employe
.admin_order_field
= "employe__nom"
426 def save_formset(self
, request
, form
, formset
, change
):
427 instances
= formset
.save(commit
=False)
428 for instance
in instances
:
429 if instance
.__class__
== rh
.DossierCommentaire
:
430 instance
.owner
= request
.user
431 instance
.date_creation
= datetime
.datetime
.now()
435 class DossierPieceAdmin(admin
.ModelAdmin
):
439 class DossierCommentaireAdmin(admin
.ModelAdmin
):
443 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
444 ProtectRegionMixin
, admin
.ModelAdmin
,):
445 prefixe_recherche_temporelle
= "rh_dossiers__"
446 alphabet_filter
= 'nom'
447 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
448 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
450 form
= EmployeAdminForm
456 '_date_modification',
459 list_display_links
= ('_nom',)
461 'rh_dossiers__poste__implantation__region',
462 'rh_dossiers__poste__implantation',
465 inlines
= (AyantDroitInline
,
468 EmployeCommentaireInline
)
469 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
473 ('nom_affichage', 'genre'),
478 ('Informations personnelles', {
479 'fields': ('situation_famille', 'date_entree', )}
483 ('tel_domicile', 'tel_cellulaire'),
484 ('adresse', 'ville'),
485 ('code_postal', 'province'),
491 def _apercu(self
, obj
):
492 return u
"""<a title="Aperçu de l'employé"
493 onclick="return showAddAnotherPopup(this);"
495 <img src="%simg/loupe.png" />
497 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
498 _apercu
.allow_tags
= True
499 _apercu
.short_description
= u
""
502 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
503 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
504 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
505 _nom
.allow_tags
= True
506 _nom
.short_description
= u
"Employé"
507 _nom
.admin_order_field
= "nom"
511 _id
.short_description
= u
"#"
512 _id
.admin_order_field
= "id"
514 def _date_modification(self
, obj
):
515 return date(obj
.date_modification
) \
516 if obj
.date_modification
is not None else "(aucune)"
517 _date_modification
.short_description
= u
'date modification'
518 _date_modification
.admin_order_field
= 'date_modification'
520 def _dossiers_postes(self
, obj
):
522 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
523 dossier
= u
"""<a title="Aperçu du dossier"
525 onclick="return showAddAnotherPopup(this);"
526 title="Aperçu du dossier">
527 <img src="%simg/loupe.png" />
529 <a href="%s">Dossier</a>
531 (reverse('dossier_apercu', args
=(d
.id,)),
533 reverse('admin:rh_dossier_change', args
=(d
.id,)))
535 poste
= u
"""<a title="Aperçu du poste"
537 onclick="return showAddAnotherPopup(this);"
538 title="Aperçu du poste">
539 <img src="%simg/loupe.png" />
541 <a href="%s">Poste</a>
543 (reverse('poste_apercu', args
=(d
.poste
.id,)),
545 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
546 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
553 # Dossier terminé en gris non cliquable
554 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
555 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
562 return "<ul>%s</ul>" % "\n".join(l
)
563 _dossiers_postes
.allow_tags
= True
564 _dossiers_postes
.short_description
= u
"Dossiers et postes"
566 def queryset(self
, request
):
567 qs
= super(EmployeAdmin
, self
).queryset(request
)
568 return qs
.select_related(depth
=1).order_by('nom')
570 def save_formset(self
, request
, form
, formset
, change
):
571 instances
= formset
.save(commit
=False)
572 for instance
in instances
:
573 if instance
.__class__
== rh
.EmployeCommentaire
:
574 instance
.owner
= request
.user
575 instance
.date_creation
= datetime
.datetime
.now()
579 class EmployeProxyAdmin(EmployeAdmin
):
580 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
581 list_display_links
= ('_nom',)
583 def has_add_permission(self
, obj
):
586 def _organigramme(self
, obj
):
588 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
589 poste
= u
"""<a title="Aperçu du poste"
591 onclick="return showAddAnotherPopup(this);"
592 title="Aperçu du poste">
593 <img src="%simg/loupe.png" />
595 <a href="%s">Poste</a>
597 (reverse('poste_apercu', args
=(d
.poste
.id,)),
599 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
600 organigramme
= u
"""<a href="%s">Organigramme</a>""" % \
601 (reverse('rho_employe', args
=(d
.poste
.id,)))
602 link
= u
"""<li>%s - %s - %s : [%s] %s</li>""" % \
603 (poste
, organigramme
,
609 return "<ul>%s</ul>" % "\n".join(l
)
611 _organigramme
.allow_tags
= True
612 _organigramme
.short_description
= "Organigramme"
615 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
619 class EmployePieceAdmin(admin
.ModelAdmin
):
623 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
624 list_display
= ('nom', '_date_modification', 'user_modification', )
625 inlines
= (TypePosteInline
,)
626 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
627 (None, {'fields': ('nom', )}),)
629 def _date_modification(self
, obj
):
630 return date(obj
.date_modification
) \
631 if obj
.date_modification
is not None else "(aucune)"
632 _date_modification
.short_description
= u
'date modification'
633 _date_modification
.admin_order_field
= 'date_modification'
636 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
637 search_fields
= ('nom',)
642 '_date_modification',
645 list_filter
= ('type', )
646 inlines
= (DossierROInline
,)
647 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
648 (None, {'fields': ('nom', 'type', 'pays',)}),
651 def _date_modification(self
, obj
):
652 return date(obj
.date_modification
) \
653 if obj
.date_modification
is not None else "(aucune)"
654 _date_modification
.short_description
= u
'date modification'
655 _date_modification
.admin_order_field
= 'date_modification'
658 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
659 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
660 form
= make_ajax_form(rh
.Poste
, {
661 'implantation': 'implantations',
662 'type_poste': 'typepostes',
663 'responsable': 'postes',
664 'valeur_point_min': 'valeurpoints',
665 'valeur_point_max': 'valeurpoints',
667 alphabet_filter
= 'nom'
672 'implantation__region__code',
673 'implantation__region__nom',
674 'rh_dossiers__employe__nom',
675 'rh_dossiers__employe__prenom',
687 '_date_modification',
691 'implantation__region',
695 'type_poste__famille_emploi',
698 list_display_links
= ('_nom',)
699 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
701 ('nom', 'nom_feminin'),
711 'regime_travail_nb_heure_semaine'),
715 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
718 'fields': (('classement_min',
731 ('Comparatifs de rémunération', {
732 'fields': ('devise_comparaison',
733 ('comp_locale_min', 'comp_locale_max'),
734 ('comp_universite_min', 'comp_universite_max'),
735 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
736 ('comp_ong_min', 'comp_ong_max'),
737 ('comp_autre_min', 'comp_autre_max'))}
740 'fields': ('justification',)}
742 ('Autres Méta-données', {
743 'fields': ('date_debut', 'date_fin')}
747 inlines
= (PosteFinancementInline
,
750 PosteComparaisonInline
,
751 PosteCommentaireInline
, )
753 def lookup_allowed(self
, key
, value
):
756 'date_debut__isnull',
759 'implantation__region__id__exact',
760 'implantation__id__exact',
761 'type_poste__id__exact',
762 'type_poste__famille_emploi__id__exact',
763 'service__id__exact',
770 def _apercu(self
, poste
):
771 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
772 title="Aperçu du poste"
774 <img src="%simg/loupe.png" />
776 (reverse('poste_apercu', args
=(poste
.id,)),
777 settings
.STATIC_URL
,)
779 _apercu
.allow_tags
= True
780 _apercu
.short_description
= ''
784 _id
.short_description
= '#'
785 _id
.admin_order_field
= 'id'
787 def _service(self
, obj
):
788 if obj
.service
.supprime
:
789 return """<span style="color:red">%s</span>""" % obj
.service
792 _service
.short_description
= 'Service'
793 _service
.allow_tags
= True
795 def _responsable(self
, obj
):
797 responsable
= u
"""<a href="%s"
798 onclick="return showAddAnotherPopup(this)">
799 <img src="%simg/loupe.png"
800 title="Aperçu du poste" />
804 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
806 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
812 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
815 onclick="return showAddAnotherPopup(this)">
816 <img src="%simg/loupe.png"
817 title="Aperçu de l'employé">
819 <a href="%s">%s</a>""" % \
820 (reverse('employe_apercu', args
=(employe_id
,)),
822 reverse('admin:rh_employe_change', args
=(employe_id
,)),
827 return "%s %s" % (responsable
, employe
)
828 _responsable
.short_description
= 'Responsable'
829 _responsable
.allow_tags
= True
831 def _nom(self
, poste
):
832 return """<a href="%s">%s</a>""" % \
833 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
835 _nom
.allow_tags
= True
836 _nom
.short_description
= u
'Nom'
837 _nom
.admin_order_field
= 'nom'
839 def _date_modification(self
, obj
):
840 return date(obj
.date_modification
)
841 _date_modification
.short_description
= u
'date modification'
842 _date_modification
.admin_order_field
= 'date_modification'
844 def _occupe_par(self
, obj
):
845 """Formatte la méthode Poste.occupe_par() pour l'admin"""
847 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.now():
849 employes
= obj
.occupe_par()
853 link
= u
"""<a href='%s'
854 title='Aperçu de l\'employer'
855 onclick='return showAddAnotherPopup(this)'>
856 <img src='%simg/loupe.png' />
858 <a href='%s'>%s</a>""" % \
859 (reverse('employe_apercu', args
=(e
.id,)),
861 reverse('admin:rh_employe_change', args
=(e
.id,)),
864 output
= "\n<br />".join(l
)
866 _occupe_par
.allow_tags
= True
867 _occupe_par
.short_description
= "Occupé par"
869 def save_formset(self
, request
, form
, formset
, change
):
870 instances
= formset
.save(commit
=False)
871 for instance
in instances
:
872 if instance
.__class__
== rh
.PosteCommentaire
:
873 instance
.owner
= request
.user
874 instance
.date_creation
= datetime
.datetime
.now()
879 class PosteCommentaireAdmin(admin
.ModelAdmin
):
883 class PosteFinancementAdmin(admin
.ModelAdmin
):
887 class PostePieceAdmin(admin
.ModelAdmin
):
891 class RemunerationAdmin(admin
.ModelAdmin
):
895 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
896 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
898 'fields': ('employe', 'implantation', ),
903 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
907 '_date_modification',
910 list_filter
= ('archive', )
911 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
913 'fields': ('nom', 'archive', ),
917 def _archive(self
, obj
):
922 _archive
.short_description
= u
'Archivé'
924 def _date_modification(self
, obj
):
925 return date(obj
.date_modification
) \
926 if obj
.date_modification
is not None else "(aucune)"
927 _date_modification
.short_description
= u
'date modification'
928 _date_modification
.admin_order_field
= 'date_modification'
931 class ServiceProxyAdmin(ServiceAdmin
):
932 list_display
= ('nom', '_organigramme')
933 list_display_links
= ('nom',)
935 def has_add_permission(self
, obj
):
938 def _organigramme(self
, obj
):
939 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
940 _organigramme
.allow_tags
= True
941 _organigramme
.short_description
= "Organigramme"
943 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
944 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
945 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
947 'fields': ('code', 'nom', ),
951 def _date_modification(self
, obj
):
952 return date(obj
.date_modification
) \
953 if obj
.date_modification
is not None else "(aucune)"
954 _date_modification
.short_description
= u
'date modification'
955 _date_modification
.admin_order_field
= 'date_modification'
958 class TauxChangeAdmin(admin
.ModelAdmin
):
963 '_date_modification',
966 list_filter
= ('devise', )
967 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
969 'fields': ('taux', 'devise', 'annee', ),
973 def _date_modification(self
, obj
):
974 return date(obj
.date_modification
) \
975 if obj
.date_modification
is not None else "(aucune)"
976 _date_modification
.short_description
= u
'date modification'
977 _date_modification
.admin_order_field
= 'date_modification'
980 class TypeContratAdmin(admin
.ModelAdmin
):
984 '_date_modification',
987 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
989 'fields': ('nom', 'nom_long', ),
993 def _date_modification(self
, obj
):
994 return date(obj
.date_modification
) \
995 if obj
.date_modification
is not None else "(aucune)"
996 _date_modification
.short_description
= u
'date modification'
997 _date_modification
.admin_order_field
= 'date_modification'
1000 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1001 search_fields
= ('nom', 'nom_feminin', )
1005 '_date_modification',
1006 'user_modification',
1008 list_filter
= ('famille_emploi', )
1009 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1020 def _date_modification(self
, obj
):
1021 return date(obj
.date_modification
) \
1022 if obj
.date_modification
is not None else "(aucune)"
1023 _date_modification
.short_description
= u
'date modification'
1024 _date_modification
.admin_order_field
= 'date_modification'
1027 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1031 'nature_remuneration',
1032 '_date_modification',
1033 'user_modification',)
1034 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1035 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',)}),
1038 def _date_modification(self
, obj
):
1039 return date(obj
.date_modification
) \
1040 if obj
.date_modification
is not None else "(aucune)"
1041 _date_modification
.short_description
= u
'date modification'
1042 _date_modification
.admin_order_field
= 'date_modification'
1045 class TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1046 list_display
= ('nom', '_date_modification', 'user_modification', )
1047 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1048 (None, {'fields': ('nom', )}),
1051 def _date_modification(self
, obj
):
1052 return date(obj
.date_modification
) \
1053 if obj
.date_modification
is not None else "(aucune)"
1054 _date_modification
.short_description
= u
'date modification'
1055 _date_modification
.admin_order_field
= 'date_modification'
1058 class ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1064 '_date_modification',
1065 'user_modification',
1067 list_filter
= ('annee', 'devise', )
1068 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1069 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
1072 def _date_modification(self
, obj
):
1073 return date(obj
.date_modification
) \
1074 if obj
.date_modification
is not None else "(aucune)"
1075 _date_modification
.short_description
= u
'date modification'
1076 _date_modification
.admin_order_field
= 'date_modification'
1078 def _devise_code(self
, obj
):
1079 return obj
.devise
.code
1080 _devise_code
.short_description
= "Code de la devise"
1082 def _devise_nom(self
, obj
):
1083 return obj
.devise
.nom
1084 _devise_nom
.short_description
= "Nom de la devise"
1086 class ImplantationProxyAdmin(admin
.ModelAdmin
):
1087 list_display
= ('nom', '_organigramme')
1088 list_display_links
= ('nom',)
1090 def has_add_permission(self
, obj
):
1093 def _organigramme(self
, obj
):
1094 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
1095 _organigramme
.allow_tags
= True
1096 _organigramme
.short_description
= "Organigramme"
1100 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
1101 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
1102 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
1103 admin
.site
.register(EmployeProxy
, EmployeProxyAdmin
)
1104 admin
.site
.register(ServiceProxy
, ServiceProxyAdmin
)
1105 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
1106 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
1107 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
1108 admin
.site
.register(rh
.Poste
, PosteAdmin
)
1109 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
1110 admin
.site
.register(rh
.Service
, ServiceAdmin
)
1111 admin
.site
.register(rh
.Statut
, StatutAdmin
)
1112 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
1113 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
1114 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
1115 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
1116 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
1117 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)
1118 admin
.site
.register(ImplantationProxy
, ImplantationProxyAdmin
)