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
, \
16 from dae
import models
as dae
17 from dae
.utils
import get_employe_from_user
18 from change_list
import ChangeList
19 from groups
import grp_correspondants_rh
20 from decorators
import in_drh_or_admin
22 import auf
.django
.references
.models
as ref
24 class ArchiveMixin(object):
26 Archive Mixin pour gérer le queryset et le display
27 NON COMPRIS : list_filter, et list_display, field à setter dans la classe.
30 def queryset(self
, request
):
31 return self
.model
._base_manager
33 def _archive(self
, obj
):
38 _archive
.short_description
= u
'Archivé'
39 _archive
.admin_order_field
= 'archive'
41 class RegionProxy(ref
.Region
):
42 """ Proxy utilisé pour les organigrammes par région """
45 verbose_name
= u
"Organigramme par région"
46 verbose_name_plural
= u
"Organigramme par région"
49 class ImplantationProxy(ref
.Implantation
):
50 """ Proxy utilisé pour les organigrammes par implantation """
53 verbose_name
= u
"Organigramme par implantations"
54 verbose_name_plural
= u
"Organigramme par implantations"
57 class ServiceProxy(rh
.Service
):
58 """ Proxy utilisé pour les organigrammes opar service """
61 verbose_name
= u
"Organigramme par services"
62 verbose_name_plural
= u
"Organigramme par services"
65 class EmployeProxy(rh
.Employe
):
66 """ Proxy utilisé pour les organigrammes des employés """
69 verbose_name
= u
"Organigramme des employés"
70 verbose_name_plural
= u
"Organigramme des employés"
73 class DateRangeMixin(object):
74 prefixe_recherche_temporelle
= ""
76 def get_changelist(self
, request
, **kwargs
):
77 if 'HTTP_REFERER' in request
.META
.keys():
78 referer
= request
.META
['HTTP_REFERER']
79 referer
= "/".join(referer
.split('/')[3:])
80 referer
= "/%s" % referer
.split('?')[0]
81 change_list_view
= 'admin:%s_%s_changelist' % (
82 self
.model
._meta
.app_label
,
83 self
.model
.__name__
.lower(),)
84 if referer
!= reverse(change_list_view
):
85 params
= request
.GET
.copy()
86 params
.update({'statut': 'Actif'})
91 # Override of the InlineModelAdmin to support the link in the tabular inline
92 class LinkedInline(admin
.options
.InlineModelAdmin
):
93 template
= "admin/linked.html"
94 admin_model_path
= None
96 def __init__(self
, *args
):
97 super(LinkedInline
, self
).__init__(*args
)
98 if self
.admin_model_path
is None:
99 self
.admin_model_path
= self
.model
.__name__
.lower()
102 class ProtectRegionMixin(object):
104 def queryset(self
, request
):
105 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
107 user_groups
= request
.user
.groups
.all()
108 if in_drh_or_admin(request
.user
):
111 if grp_correspondants_rh
in user_groups
:
112 employe
= get_employe_from_user(request
.user
)
113 q
= Q(**{self
.model
.prefix_implantation
: \
114 employe
.implantation
.region
})
115 qs
= qs
.filter(q
).distinct()
119 def has_add_permission(self
, request
):
120 if not in_drh_or_admin(request
.user
):
125 def has_change_permission(self
, request
, obj
=None):
126 user_groups
= request
.user
.groups
.all()
128 # Lock pour autoriser uniquement les DRH à utiliser RH
129 if not in_drh_or_admin(request
.user
):
132 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
137 ids
= [o
.id for o
in self
.queryset(request
)]
143 class ReadOnlyInlineMixin(object):
145 def get_readonly_fields(self
, request
, obj
=None):
146 return [f
.name
for f
in self
.model
._meta
.fields \
147 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
150 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
151 model
= rh
.AyantDroit
152 form
= AyantDroitForm
159 ('nom_affichage', 'genre'),
167 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
168 admin
.TabularInline
):
169 readonly_fields
= ('owner', )
170 model
= rh
.AyantDroitCommentaire
174 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
180 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
181 template
= "admin/rh/dossier/linked.html"
182 exclude
= AUF_METADATA_READONLY_FIELDS
187 def has_add_permission(self
, request
=None):
190 def has_change_permission(self
, request
, obj
=None):
193 def has_delete_permission(self
, request
, obj
=None):
197 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
198 admin
.TabularInline
):
199 readonly_fields
= ('owner', )
200 model
= rh
.DossierCommentaire
204 class DossierPieceInline(admin
.TabularInline
):
205 model
= rh
.DossierPiece
209 class EmployeInline(admin
.TabularInline
):
213 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
214 admin
.TabularInline
):
215 readonly_fields
= ('owner', )
216 model
= rh
.EmployeCommentaire
220 class EmployePieceInline(admin
.TabularInline
):
221 model
= rh
.EmployePiece
225 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
226 readonly_fields
= ('owner', )
227 model
= rh
.PosteCommentaire
231 class PosteFinancementInline(admin
.TabularInline
):
232 model
= rh
.PosteFinancement
235 class PostePieceInline(admin
.TabularInline
):
236 model
= rh
.PostePiece
239 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
240 model
= rh
.Remuneration
244 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
248 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
252 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
253 model
= rh
.PosteComparaison
256 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
257 list_display
= ('_classement', '_date_modification', 'user_modification', )
258 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
260 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
263 def _classement(self
, obj
):
265 _classement
.short_description
= u
"Classement"
267 def _date_modification(self
, obj
):
268 return date(obj
.date_modification
) \
269 if obj
.date_modification
is not None else "(aucune)"
270 _date_modification
.short_description
= u
'date modification'
271 _date_modification
.admin_order_field
= 'date_modification'
274 class CommentaireAdmin(admin
.ModelAdmin
):
278 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
283 '_date_modification',
286 list_filter
= ('archive', )
287 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
289 'fields': ('code', 'nom', 'archive', ),
293 def _date_modification(self
, obj
):
294 return date(obj
.date_modification
) \
295 if obj
.date_modification
is not None else "(aucune)"
296 _date_modification
.short_description
= u
'date modification'
297 _date_modification
.admin_order_field
= 'date_modification'
300 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
301 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
302 alphabet_filter
= 'employe__nom'
307 'poste__nom_feminin')
316 '_date_modification',
320 list_display_links
= ('_nom',)
322 'poste__implantation__region',
323 'poste__implantation',
324 'poste__type_poste__famille_emploi',
326 'rh_contrats__type_contrat',
329 inlines
= (DossierPieceInline
, ContratInline
,
331 DossierCommentaireInline
,
333 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
340 'organisme_bstg',)}),
345 'remplacement_de', )}),
349 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
350 ('Occupation du Poste par cet Employe', {
351 'fields': (('date_debut', 'date_fin'), )}
354 form
= make_ajax_form(rh
.Dossier
, {
355 'employe': 'employes',
357 'remplacement_de': 'dossiers',
358 }, superclass
=DossierForm
)
360 def lookup_allowed(self
, key
, value
):
362 'employe__nom__istartswith',
363 'poste__implantation__region__id__exact',
364 'poste__implantation__id__exact',
365 'poste__type_poste__id__exact',
366 'poste__type_poste__famille_emploi__id__exact',
367 'rh_contrats__type_contrat__id__exact',
375 _id
.short_description
= u
"#"
376 _id
.admin_order_field
= "id"
379 return "%d : %s %s" % (
381 obj
.employe
.nom
.upper(),
383 _nom
.allow_tags
= True
384 _nom
.short_description
= u
"Dossier"
386 def _apercu(self
, d
):
387 apercu_link
= u
"""<a title="Aperçu du dossier"
388 onclick="return showAddAnotherPopup(this);"
390 <img src="%simg/loupe.png" />
392 (reverse('dossier_apercu', args
=(d
.id,)),
396 _apercu
.allow_tags
= True
397 _apercu
.short_description
= u
""
401 if dae
.ImportDossier
.objects
.filter(rh
=d
).exists():
402 dae_id
= dae
.ImportDossier
.objects
.get(rh
=d
).dae_id
403 apercu_link
= u
"""<a title="Aperçu du dossier"
404 onclick="return showAddAnotherPopup(this);"
406 <img src="%simg/loupe.png" />
408 (reverse('embauche_consulter', args
=(dae_id
,)),
412 _dae
.allow_tags
= True
413 _dae
.short_description
= u
"DAE"
415 def _date_debut(self
, obj
):
416 return date(obj
.date_debut
)
418 _date_debut
.short_description
= u
'Occupation début'
419 _date_debut
.admin_order_field
= 'date_debut'
421 def _date_fin(self
, obj
):
422 return date(obj
.date_fin
)
423 _date_fin
.short_description
= u
'Occupation fin'
424 _date_fin
.admin_order_field
= 'date_fin'
426 def _date_modification(self
, obj
):
427 return date(obj
.date_modification
) \
428 if obj
.date_modification
is not None else "(aucune)"
429 _date_modification
.short_description
= u
'date modification'
430 _date_modification
.admin_order_field
= 'date_modification'
432 def _poste(self
, dossier
):
433 link
= u
"""<a title="Aperçu du poste"
434 onclick="return showAddAnotherPopup(this);"
435 href='%s'><img src="%simg/loupe.png" />
437 <a href="%s" title="Modifier le poste">%s</a>""" % \
438 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
440 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
444 _poste
.allow_tags
= True
445 _poste
.short_description
= u
'Poste'
446 _poste
.admin_order_field
= 'poste__nom'
448 def _employe(self
, obj
):
449 employe
= obj
.employe
450 view_link
= reverse('employe_apercu', args
=(employe
.id,))
451 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
454 view
= u
"""<a href="%s"
455 title="Aperçu l'employé"
456 onclick="return showAddAnotherPopup(this);">
457 <img src="%simg/loupe.png" />
458 </a>""" % (view_link
, settings
.STATIC_URL
,)
459 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
460 (view
, edit_link
, style
, employe
)
461 _employe
.allow_tags
= True
462 _employe
.short_description
= u
"Employé"
463 _employe
.admin_order_field
= "employe__nom"
465 def save_formset(self
, request
, form
, formset
, change
):
466 instances
= formset
.save(commit
=False)
467 for instance
in instances
:
468 if instance
.__class__
== rh
.DossierCommentaire
:
469 instance
.owner
= request
.user
470 instance
.date_creation
= datetime
.datetime
.now()
474 class DossierPieceAdmin(admin
.ModelAdmin
):
478 class DossierCommentaireAdmin(admin
.ModelAdmin
):
482 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
483 ProtectRegionMixin
, admin
.ModelAdmin
,):
484 prefixe_recherche_temporelle
= "rh_dossiers__"
485 alphabet_filter
= 'nom'
486 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
487 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
489 form
= EmployeAdminForm
495 '_date_modification',
498 list_display_links
= ('_nom',)
500 'rh_dossiers__poste__implantation__region',
501 'rh_dossiers__poste__implantation',
504 inlines
= (AyantDroitInline
,
507 EmployeCommentaireInline
)
508 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
512 ('nom_affichage', 'genre'),
517 ('Informations personnelles', {
518 'fields': ('situation_famille', 'date_entree', )}
522 ('tel_domicile', 'tel_cellulaire'),
523 ('adresse', 'ville'),
524 ('code_postal', 'province'),
530 def _apercu(self
, obj
):
531 return u
"""<a title="Aperçu de l'employé"
532 onclick="return showAddAnotherPopup(this);"
534 <img src="%simg/loupe.png" />
536 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
537 _apercu
.allow_tags
= True
538 _apercu
.short_description
= u
""
541 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
542 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
543 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
544 _nom
.allow_tags
= True
545 _nom
.short_description
= u
"Employé"
546 _nom
.admin_order_field
= "nom"
550 _id
.short_description
= u
"#"
551 _id
.admin_order_field
= "id"
553 def _date_modification(self
, obj
):
554 return date(obj
.date_modification
) \
555 if obj
.date_modification
is not None else "(aucune)"
556 _date_modification
.short_description
= u
'date modification'
557 _date_modification
.admin_order_field
= 'date_modification'
559 def _dossiers_postes(self
, obj
):
561 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
562 dossier
= u
"""<a title="Aperçu du dossier"
564 onclick="return showAddAnotherPopup(this);"
565 title="Aperçu du dossier">
566 <img src="%simg/loupe.png" />
568 <a href="%s">Dossier</a>
570 (reverse('dossier_apercu', args
=(d
.id,)),
572 reverse('admin:rh_dossier_change', args
=(d
.id,)))
574 poste
= u
"""<a title="Aperçu du poste"
576 onclick="return showAddAnotherPopup(this);"
577 title="Aperçu du poste">
578 <img src="%simg/loupe.png" />
580 <a href="%s">Poste</a>
582 (reverse('poste_apercu', args
=(d
.poste
.id,)),
584 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
585 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
592 # Dossier terminé en gris non cliquable
593 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
594 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
601 return "<ul>%s</ul>" % "\n".join(l
)
602 _dossiers_postes
.allow_tags
= True
603 _dossiers_postes
.short_description
= u
"Dossiers et postes"
605 def queryset(self
, request
):
606 qs
= super(EmployeAdmin
, self
).queryset(request
)
607 return qs
.select_related(depth
=1).order_by('nom')
609 def save_formset(self
, request
, form
, formset
, change
):
610 instances
= formset
.save(commit
=False)
611 for instance
in instances
:
612 if instance
.__class__
== rh
.EmployeCommentaire
:
613 instance
.owner
= request
.user
614 instance
.date_creation
= datetime
.datetime
.now()
618 class EmployeProxyAdmin(EmployeAdmin
):
619 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
620 list_display_links
= ('_nom',)
622 def has_add_permission(self
, obj
):
625 def _organigramme(self
, obj
):
627 for d
in rh
.Dossier
.objects
.filter((Q(date_fin__gt
=datetime
.date
.today()) |
Q(date_fin
=None)) & (Q(date_debut__lt
=datetime
.date
.today()) |
Q(date_debut
=None)) ).filter(employe
=obj
.id).all():
628 organigramme
= u
"""Organigramme, niveau: <input type="text" id="level_%s" style="width:30px;height:15px;" /> <input type="button" value="Générer" onclick="window.location='%s'+document.getElementById('level_%s').value" />""" % \
629 (d
.poste
.id, reverse('rho_employe_sans_niveau', args
=(d
.poste
.id,)), d
.poste
.id)
630 link
= u
"""<li>%s - [%s] %s : %s</li>""" % \
637 return "<ul>%s</ul>" % "\n".join(l
)
639 _organigramme
.allow_tags
= True
640 _organigramme
.short_description
= "Organigramme"
643 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
647 class EmployePieceAdmin(admin
.ModelAdmin
):
651 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
652 list_display
= ('nom', '_date_modification', 'user_modification', )
653 inlines
= (TypePosteInline
,)
654 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
655 (None, {'fields': ('nom', )}),)
657 def _date_modification(self
, obj
):
658 return date(obj
.date_modification
) \
659 if obj
.date_modification
is not None else "(aucune)"
660 _date_modification
.short_description
= u
'date modification'
661 _date_modification
.admin_order_field
= 'date_modification'
664 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
665 search_fields
= ('nom',)
670 '_date_modification',
673 list_filter
= ('type', )
674 inlines
= (DossierROInline
,)
675 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
676 (None, {'fields': ('nom', 'type', 'pays',)}),
679 def _date_modification(self
, obj
):
680 return date(obj
.date_modification
) \
681 if obj
.date_modification
is not None else "(aucune)"
682 _date_modification
.short_description
= u
'date modification'
683 _date_modification
.admin_order_field
= 'date_modification'
686 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
687 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
688 form
= make_ajax_form(rh
.Poste
, {
689 'implantation': 'implantations',
690 'type_poste': 'typepostes',
691 'responsable': 'postes',
692 'valeur_point_min': 'valeurpoints',
693 'valeur_point_max': 'valeurpoints',
695 alphabet_filter
= 'nom'
700 'implantation__region__code',
701 'implantation__region__nom',
702 'rh_dossiers__employe__nom',
703 'rh_dossiers__employe__prenom',
715 '_date_modification',
720 'implantation__region',
724 'type_poste__famille_emploi',
727 list_display_links
= ('_nom',)
728 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
730 ('nom', 'nom_feminin'),
740 'regime_travail_nb_heure_semaine'),
744 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
747 'fields': (('classement_min',
760 ('Comparatifs de rémunération', {
761 'fields': ('devise_comparaison',
762 ('comp_locale_min', 'comp_locale_max'),
763 ('comp_universite_min', 'comp_universite_max'),
764 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
765 ('comp_ong_min', 'comp_ong_max'),
766 ('comp_autre_min', 'comp_autre_max'))}
769 'fields': ('justification',)}
771 ('Autres Méta-données', {
772 'fields': ('date_debut', 'date_fin')}
776 inlines
= (PosteFinancementInline
,
779 PosteComparaisonInline
,
780 PosteCommentaireInline
, )
782 def lookup_allowed(self
, key
, value
):
785 'date_debut__isnull',
788 'implantation__region__id__exact',
789 'implantation__id__exact',
790 'type_poste__id__exact',
791 'type_poste__famille_emploi__id__exact',
792 'service__id__exact',
799 def _apercu(self
, poste
):
800 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
801 title="Aperçu du poste"
803 <img src="%simg/loupe.png" />
805 (reverse('poste_apercu', args
=(poste
.id,)),
806 settings
.STATIC_URL
,)
808 _apercu
.allow_tags
= True
809 _apercu
.short_description
= ''
811 def _dae(self
, poste
):
813 if dae
.ImportPoste
.objects
.filter(rh
=poste
).exists():
814 dae_id
= dae
.ImportPoste
.objects
.get(rh
=poste
).dae_id
815 apercu_link
= u
"""<a title="Aperçu du dossier"
816 onclick="return showAddAnotherPopup(this);"
818 <img src="%simg/loupe.png" />
820 (reverse('poste_consulter', args
=("dae-%s" % dae_id
,)),
824 _dae
.allow_tags
= True
825 _dae
.short_description
= u
"DAE"
829 _id
.short_description
= '#'
830 _id
.admin_order_field
= 'id'
832 def _service(self
, obj
):
833 if obj
.service
.supprime
:
834 return """<span style="color:red">%s</span>""" % obj
.service
837 _service
.short_description
= 'Service'
838 _service
.allow_tags
= True
840 def _responsable(self
, obj
):
842 responsable
= u
"""<a href="%s"
843 onclick="return showAddAnotherPopup(this)">
844 <img src="%simg/loupe.png"
845 title="Aperçu du poste" />
849 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
851 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
857 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
860 onclick="return showAddAnotherPopup(this)">
861 <img src="%simg/loupe.png"
862 title="Aperçu de l'employé">
864 <a href="%s">%s</a>""" % \
865 (reverse('employe_apercu', args
=(employe_id
,)),
867 reverse('admin:rh_employe_change', args
=(employe_id
,)),
872 return "%s %s" % (responsable
, employe
)
873 _responsable
.short_description
= 'Responsable'
874 _responsable
.allow_tags
= True
876 def _nom(self
, poste
):
877 return """<a href="%s">%s</a>""" % \
878 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
880 _nom
.allow_tags
= True
881 _nom
.short_description
= u
'Nom'
882 _nom
.admin_order_field
= 'nom'
884 def _date_modification(self
, obj
):
885 return date(obj
.date_modification
)
886 _date_modification
.short_description
= u
'date modification'
887 _date_modification
.admin_order_field
= 'date_modification'
889 def _occupe_par(self
, obj
):
890 """Formatte la méthode Poste.occupe_par() pour l'admin"""
891 import pdb
; pdb
.set_trace()
894 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.today():
896 employes
= obj
.occupe_par()
900 link
= u
"""<a href='%s'
901 title='Aperçu de l\'employer'
902 onclick='return showAddAnotherPopup(this)'>
903 <img src='%simg/loupe.png' />
905 <a href='%s'>%s</a>""" % \
906 (reverse('employe_apercu', args
=(e
.id,)),
908 reverse('admin:rh_employe_change', args
=(e
.id,)),
911 output
= "\n<br />".join(l
)
913 _occupe_par
.allow_tags
= True
914 _occupe_par
.short_description
= "Occupé par"
916 def save_formset(self
, request
, form
, formset
, change
):
917 instances
= formset
.save(commit
=False)
918 for instance
in instances
:
919 if instance
.__class__
== rh
.PosteCommentaire
:
920 instance
.owner
= request
.user
921 instance
.date_creation
= datetime
.datetime
.now()
926 class PosteCommentaireAdmin(admin
.ModelAdmin
):
930 class PosteFinancementAdmin(admin
.ModelAdmin
):
934 class PostePieceAdmin(admin
.ModelAdmin
):
938 class RemunerationAdmin(admin
.ModelAdmin
):
942 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
943 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
945 'fields': ('employe', 'implantation', ),
950 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
954 '_date_modification',
957 list_filter
= ('archive', )
958 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
960 'fields': ('nom', 'archive', ),
964 def _date_modification(self
, obj
):
965 return date(obj
.date_modification
) \
966 if obj
.date_modification
is not None else "(aucune)"
967 _date_modification
.short_description
= u
'date modification'
968 _date_modification
.admin_order_field
= 'date_modification'
971 class ServiceProxyAdmin(ServiceAdmin
):
972 list_display
= ('nom', '_organigramme')
973 list_display_links
= ('nom',)
975 def has_add_permission(self
, obj
):
978 def _organigramme(self
, obj
):
979 return """<a href="%s">Organigramme</a>""" % (reverse('rho_service', args
=(obj
.id,)))
980 _organigramme
.allow_tags
= True
981 _organigramme
.short_description
= "Organigramme"
983 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
984 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
985 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
987 'fields': ('code', 'nom', ),
991 def _date_modification(self
, obj
):
992 return date(obj
.date_modification
) \
993 if obj
.date_modification
is not None else "(aucune)"
994 _date_modification
.short_description
= u
'date modification'
995 _date_modification
.admin_order_field
= 'date_modification'
998 class TauxChangeAdmin(admin
.ModelAdmin
):
1003 '_date_modification',
1004 'user_modification',
1006 list_filter
= ('devise', )
1007 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1009 'fields': ('taux', 'devise', 'annee', ),
1013 def _date_modification(self
, obj
):
1014 return date(obj
.date_modification
) \
1015 if obj
.date_modification
is not None else "(aucune)"
1016 _date_modification
.short_description
= u
'date modification'
1017 _date_modification
.admin_order_field
= 'date_modification'
1020 class TypeContratAdmin(admin
.ModelAdmin
):
1024 '_date_modification',
1025 'user_modification',
1027 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1029 'fields': ('nom', 'nom_long', ),
1033 def _date_modification(self
, obj
):
1034 return date(obj
.date_modification
) \
1035 if obj
.date_modification
is not None else "(aucune)"
1036 _date_modification
.short_description
= u
'date modification'
1037 _date_modification
.admin_order_field
= 'date_modification'
1040 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1041 search_fields
= ('nom', 'nom_feminin', )
1045 '_date_modification',
1046 'user_modification',
1048 list_filter
= ('famille_emploi', )
1049 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1060 def _date_modification(self
, obj
):
1061 return date(obj
.date_modification
) \
1062 if obj
.date_modification
is not None else "(aucune)"
1063 _date_modification
.short_description
= u
'date modification'
1064 _date_modification
.admin_order_field
= 'date_modification'
1067 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
1071 'nature_remuneration',
1073 '_date_modification',
1074 'user_modification',)
1075 list_filter
= ('archive', )
1076 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1077 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',
1081 def _date_modification(self
, obj
):
1082 return date(obj
.date_modification
) \
1083 if obj
.date_modification
is not None else "(aucune)"
1084 _date_modification
.short_description
= u
'date modification'
1085 _date_modification
.admin_order_field
= 'date_modification'
1088 class TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1089 list_display
= ('nom', '_date_modification', 'user_modification', )
1090 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1091 (None, {'fields': ('nom', )}),
1094 def _date_modification(self
, obj
):
1095 return date(obj
.date_modification
) \
1096 if obj
.date_modification
is not None else "(aucune)"
1097 _date_modification
.short_description
= u
'date modification'
1098 _date_modification
.admin_order_field
= 'date_modification'
1101 class ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1107 '_date_modification',
1108 'user_modification',
1110 list_filter
= ('annee', 'devise', )
1111 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1112 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
1115 def _date_modification(self
, obj
):
1116 return date(obj
.date_modification
) \
1117 if obj
.date_modification
is not None else "(aucune)"
1118 _date_modification
.short_description
= u
'date modification'
1119 _date_modification
.admin_order_field
= 'date_modification'
1121 def _devise_code(self
, obj
):
1122 return obj
.devise
.code
1123 _devise_code
.short_description
= "Code de la devise"
1125 def _devise_nom(self
, obj
):
1126 return obj
.devise
.nom
1127 _devise_nom
.short_description
= "Nom de la devise"
1129 class ImplantationProxyAdmin(admin
.ModelAdmin
):
1130 list_display
= ('nom', '_organigramme')
1131 list_display_links
= ('nom',)
1133 def has_add_permission(self
, obj
):
1136 def _organigramme(self
, obj
):
1137 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
1138 _organigramme
.allow_tags
= True
1139 _organigramme
.short_description
= "Organigramme"
1141 class RegionProxyAdmin(admin
.ModelAdmin
):
1142 list_display
= ('nom', '_organigramme')
1143 list_display_links
= ('nom',)
1145 def has_add_permission(self
, obj
):
1148 def _organigramme(self
, obj
):
1149 return """<a href="%s">Organigramme</a>""" % (reverse('rho_region', args
=(obj
.id,)))
1150 _organigramme
.allow_tags
= True
1151 _organigramme
.short_description
= "Organigramme"
1156 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
1157 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
1158 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
1159 admin
.site
.register(EmployeProxy
, EmployeProxyAdmin
)
1160 admin
.site
.register(ServiceProxy
, ServiceProxyAdmin
)
1161 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
1162 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
1163 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
1164 admin
.site
.register(rh
.Poste
, PosteAdmin
)
1165 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
1166 admin
.site
.register(rh
.Service
, ServiceAdmin
)
1167 admin
.site
.register(rh
.Statut
, StatutAdmin
)
1168 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
1169 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
1170 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
1171 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
1172 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
1173 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)
1174 admin
.site
.register(ImplantationProxy
, ImplantationProxyAdmin
)
1175 admin
.site
.register(RegionProxy
, RegionProxyAdmin
)