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
.utils
import get_employe_from_user
17 from change_list
import ChangeList
18 from groups
import grp_correspondants_rh
19 from decorators
import in_drh_or_admin
21 import auf
.django
.references
.models
as ref
23 class ArchiveMixin(object):
25 Archive Mixin pour gérer le queryset et le display
26 NON COMPRIS : list_filter, et list_display, field à setter dans la classe.
29 def queryset(self
, request
):
30 return self
.model
._base_manager
32 def _archive(self
, obj
):
37 _archive
.short_description
= u
'Archivé'
38 _archive
.admin_order_field
= 'archive'
40 class RegionProxy(ref
.Region
):
41 """ Proxy utilisé pour les organigrammes par région """
44 verbose_name
= u
"Organigramme par région"
45 verbose_name_plural
= u
"Organigramme par région"
48 class ImplantationProxy(ref
.Implantation
):
49 """ Proxy utilisé pour les organigrammes par implantation """
52 verbose_name
= u
"Organigramme par implantations"
53 verbose_name_plural
= u
"Organigramme par implantations"
56 class ServiceProxy(rh
.Service
):
57 """ Proxy utilisé pour les organigrammes opar service """
60 verbose_name
= u
"Organigramme par services"
61 verbose_name_plural
= u
"Organigramme par services"
64 class EmployeProxy(rh
.Employe
):
65 """ Proxy utilisé pour les organigrammes des employés """
68 verbose_name
= u
"Organigramme des employés"
69 verbose_name_plural
= u
"Organigramme des employés"
72 class DateRangeMixin(object):
73 prefixe_recherche_temporelle
= ""
75 def get_changelist(self
, request
, **kwargs
):
76 if 'HTTP_REFERER' in request
.META
.keys():
77 referer
= request
.META
['HTTP_REFERER']
78 referer
= "/".join(referer
.split('/')[3:])
79 referer
= "/%s" % referer
.split('?')[0]
80 change_list_view
= 'admin:%s_%s_changelist' % (
81 self
.model
._meta
.app_label
,
82 self
.model
.__name__
.lower(),)
83 if referer
!= reverse(change_list_view
):
84 params
= request
.GET
.copy()
85 params
.update({'statut': 'Actif'})
90 # Override of the InlineModelAdmin to support the link in the tabular inline
91 class LinkedInline(admin
.options
.InlineModelAdmin
):
92 template
= "admin/linked.html"
93 admin_model_path
= None
95 def __init__(self
, *args
):
96 super(LinkedInline
, self
).__init__(*args
)
97 if self
.admin_model_path
is None:
98 self
.admin_model_path
= self
.model
.__name__
.lower()
101 class ProtectRegionMixin(object):
103 def queryset(self
, request
):
104 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
106 user_groups
= request
.user
.groups
.all()
107 if in_drh_or_admin(request
.user
):
110 if grp_correspondants_rh
in user_groups
:
111 employe
= get_employe_from_user(request
.user
)
112 q
= Q(**{self
.model
.prefix_implantation
: \
113 employe
.implantation
.region
})
114 qs
= qs
.filter(q
).distinct()
118 def has_add_permission(self
, request
):
119 if not in_drh_or_admin(request
.user
):
124 def has_change_permission(self
, request
, obj
=None):
125 user_groups
= request
.user
.groups
.all()
127 # Lock pour autoriser uniquement les DRH à utiliser RH
128 if not in_drh_or_admin(request
.user
):
131 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
136 ids
= [o
.id for o
in self
.queryset(request
)]
142 class ReadOnlyInlineMixin(object):
144 def get_readonly_fields(self
, request
, obj
=None):
145 return [f
.name
for f
in self
.model
._meta
.fields \
146 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
149 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
150 model
= rh
.AyantDroit
151 form
= AyantDroitForm
158 ('nom_affichage', 'genre'),
166 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
167 admin
.TabularInline
):
168 readonly_fields
= ('owner', )
169 model
= rh
.AyantDroitCommentaire
173 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
179 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
180 template
= "admin/rh/dossier/linked.html"
181 exclude
= AUF_METADATA_READONLY_FIELDS
186 def has_add_permission(self
, request
=None):
189 def has_change_permission(self
, request
, obj
=None):
192 def has_delete_permission(self
, request
, obj
=None):
196 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
197 admin
.TabularInline
):
198 readonly_fields
= ('owner', )
199 model
= rh
.DossierCommentaire
203 class DossierPieceInline(admin
.TabularInline
):
204 model
= rh
.DossierPiece
208 class EmployeInline(admin
.TabularInline
):
212 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
213 admin
.TabularInline
):
214 readonly_fields
= ('owner', )
215 model
= rh
.EmployeCommentaire
219 class EmployePieceInline(admin
.TabularInline
):
220 model
= rh
.EmployePiece
224 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
225 readonly_fields
= ('owner', )
226 model
= rh
.PosteCommentaire
230 class PosteFinancementInline(admin
.TabularInline
):
231 model
= rh
.PosteFinancement
234 class PostePieceInline(admin
.TabularInline
):
235 model
= rh
.PostePiece
238 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
239 model
= rh
.Remuneration
243 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
247 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
251 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
252 model
= rh
.PosteComparaison
255 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
256 list_display
= ('_classement', '_date_modification', 'user_modification', )
257 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
259 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
262 def _classement(self
, obj
):
264 _classement
.short_description
= u
"Classement"
266 def _date_modification(self
, obj
):
267 return date(obj
.date_modification
) \
268 if obj
.date_modification
is not None else "(aucune)"
269 _date_modification
.short_description
= u
'date modification'
270 _date_modification
.admin_order_field
= 'date_modification'
273 class CommentaireAdmin(admin
.ModelAdmin
):
277 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
282 '_date_modification',
285 list_filter
= ('archive', )
286 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
288 'fields': ('code', 'nom', 'archive', ),
292 def _date_modification(self
, obj
):
293 return date(obj
.date_modification
) \
294 if obj
.date_modification
is not None else "(aucune)"
295 _date_modification
.short_description
= u
'date modification'
296 _date_modification
.admin_order_field
= 'date_modification'
299 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
300 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
301 alphabet_filter
= 'employe__nom'
306 'poste__nom_feminin')
315 '_date_modification',
318 list_display_links
= ('_nom',)
320 'poste__implantation__region',
321 'poste__implantation',
322 'poste__type_poste__famille_emploi',
324 'rh_contrats__type_contrat',
327 inlines
= (DossierPieceInline
, ContratInline
,
329 DossierCommentaireInline
,
331 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
338 'organisme_bstg',)}),
343 'remplacement_de', )}),
347 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
348 ('Occupation du Poste par cet Employe', {
349 'fields': (('date_debut', 'date_fin'), )}
352 form
= make_ajax_form(rh
.Dossier
, {
353 'employe': 'employes',
355 'remplacement_de': 'dossiers',
356 }, superclass
=DossierForm
)
358 def lookup_allowed(self
, key
, value
):
360 'employe__nom__istartswith',
361 'poste__implantation__region__id__exact',
362 'poste__implantation__id__exact',
363 'poste__type_poste__id__exact',
364 'poste__type_poste__famille_emploi__id__exact',
365 'rh_contrats__type_contrat__id__exact',
373 _id
.short_description
= u
"#"
374 _id
.admin_order_field
= "id"
377 return "%d : %s %s" % (
379 obj
.employe
.nom
.upper(),
381 _nom
.allow_tags
= True
382 _nom
.short_description
= u
"Dossier"
384 def _apercu(self
, d
):
385 apercu_link
= u
"""<a title="Aperçu du dossier"
386 onclick="return showAddAnotherPopup(this);"
388 <img src="%simg/loupe.png" />
390 (reverse('dossier_apercu', args
=(d
.id,)),
394 _apercu
.allow_tags
= True
395 _apercu
.short_description
= u
""
397 def _date_debut(self
, obj
):
398 return date(obj
.date_debut
)
400 _date_debut
.short_description
= u
'Occupation début'
401 _date_debut
.admin_order_field
= 'date_debut'
403 def _date_fin(self
, obj
):
404 return date(obj
.date_fin
)
405 _date_fin
.short_description
= u
'Occupation fin'
406 _date_fin
.admin_order_field
= 'date_fin'
408 def _date_modification(self
, obj
):
409 return date(obj
.date_modification
) \
410 if obj
.date_modification
is not None else "(aucune)"
411 _date_modification
.short_description
= u
'date modification'
412 _date_modification
.admin_order_field
= 'date_modification'
414 def _poste(self
, dossier
):
415 link
= u
"""<a title="Aperçu du poste"
416 onclick="return showAddAnotherPopup(this);"
417 href='%s'><img src="%simg/loupe.png" />
419 <a href="%s" title="Modifier le poste">%s</a>""" % \
420 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
422 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
426 _poste
.allow_tags
= True
427 _poste
.short_description
= u
'Poste'
428 _poste
.admin_order_field
= 'poste__nom'
430 def _employe(self
, obj
):
431 employe
= obj
.employe
432 view_link
= reverse('employe_apercu', args
=(employe
.id,))
433 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
436 view
= u
"""<a href="%s"
437 title="Aperçu l'employé"
438 onclick="return showAddAnotherPopup(this);">
439 <img src="%simg/loupe.png" />
440 </a>""" % (view_link
, settings
.STATIC_URL
,)
441 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
442 (view
, edit_link
, style
, employe
)
443 _employe
.allow_tags
= True
444 _employe
.short_description
= u
"Employé"
445 _employe
.admin_order_field
= "employe__nom"
447 def save_formset(self
, request
, form
, formset
, change
):
448 instances
= formset
.save(commit
=False)
449 for instance
in instances
:
450 if instance
.__class__
== rh
.DossierCommentaire
:
451 instance
.owner
= request
.user
452 instance
.date_creation
= datetime
.datetime
.now()
456 class DossierPieceAdmin(admin
.ModelAdmin
):
460 class DossierCommentaireAdmin(admin
.ModelAdmin
):
464 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
465 ProtectRegionMixin
, admin
.ModelAdmin
,):
466 prefixe_recherche_temporelle
= "rh_dossiers__"
467 alphabet_filter
= 'nom'
468 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
469 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
471 form
= EmployeAdminForm
477 '_date_modification',
480 list_display_links
= ('_nom',)
482 'rh_dossiers__poste__implantation__region',
483 'rh_dossiers__poste__implantation',
486 inlines
= (AyantDroitInline
,
489 EmployeCommentaireInline
)
490 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
494 ('nom_affichage', 'genre'),
499 ('Informations personnelles', {
500 'fields': ('situation_famille', 'date_entree', )}
504 ('tel_domicile', 'tel_cellulaire'),
505 ('adresse', 'ville'),
506 ('code_postal', 'province'),
512 def _apercu(self
, obj
):
513 return u
"""<a title="Aperçu de l'employé"
514 onclick="return showAddAnotherPopup(this);"
516 <img src="%simg/loupe.png" />
518 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
519 _apercu
.allow_tags
= True
520 _apercu
.short_description
= u
""
523 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
524 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
525 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
526 _nom
.allow_tags
= True
527 _nom
.short_description
= u
"Employé"
528 _nom
.admin_order_field
= "nom"
532 _id
.short_description
= u
"#"
533 _id
.admin_order_field
= "id"
535 def _date_modification(self
, obj
):
536 return date(obj
.date_modification
) \
537 if obj
.date_modification
is not None else "(aucune)"
538 _date_modification
.short_description
= u
'date modification'
539 _date_modification
.admin_order_field
= 'date_modification'
541 def _dossiers_postes(self
, obj
):
543 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
544 dossier
= u
"""<a title="Aperçu du dossier"
546 onclick="return showAddAnotherPopup(this);"
547 title="Aperçu du dossier">
548 <img src="%simg/loupe.png" />
550 <a href="%s">Dossier</a>
552 (reverse('dossier_apercu', args
=(d
.id,)),
554 reverse('admin:rh_dossier_change', args
=(d
.id,)))
556 poste
= u
"""<a title="Aperçu du poste"
558 onclick="return showAddAnotherPopup(this);"
559 title="Aperçu du poste">
560 <img src="%simg/loupe.png" />
562 <a href="%s">Poste</a>
564 (reverse('poste_apercu', args
=(d
.poste
.id,)),
566 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
567 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
574 # Dossier terminé en gris non cliquable
575 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
576 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
583 return "<ul>%s</ul>" % "\n".join(l
)
584 _dossiers_postes
.allow_tags
= True
585 _dossiers_postes
.short_description
= u
"Dossiers et postes"
587 def queryset(self
, request
):
588 qs
= super(EmployeAdmin
, self
).queryset(request
)
589 return qs
.select_related(depth
=1).order_by('nom')
591 def save_formset(self
, request
, form
, formset
, change
):
592 instances
= formset
.save(commit
=False)
593 for instance
in instances
:
594 if instance
.__class__
== rh
.EmployeCommentaire
:
595 instance
.owner
= request
.user
596 instance
.date_creation
= datetime
.datetime
.now()
600 class EmployeProxyAdmin(EmployeAdmin
):
601 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
602 list_display_links
= ('_nom',)
604 def has_add_permission(self
, obj
):
607 def _organigramme(self
, obj
):
609 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():
610 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" />""" % \
611 (d
.poste
.id, reverse('rho_employe_sans_niveau', args
=(d
.poste
.id,)), d
.poste
.id)
612 link
= u
"""<li>%s - [%s] %s : %s</li>""" % \
619 return "<ul>%s</ul>" % "\n".join(l
)
621 _organigramme
.allow_tags
= True
622 _organigramme
.short_description
= "Organigramme"
625 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
629 class EmployePieceAdmin(admin
.ModelAdmin
):
633 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
634 list_display
= ('nom', '_date_modification', 'user_modification', )
635 inlines
= (TypePosteInline
,)
636 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
637 (None, {'fields': ('nom', )}),)
639 def _date_modification(self
, obj
):
640 return date(obj
.date_modification
) \
641 if obj
.date_modification
is not None else "(aucune)"
642 _date_modification
.short_description
= u
'date modification'
643 _date_modification
.admin_order_field
= 'date_modification'
646 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
647 search_fields
= ('nom',)
652 '_date_modification',
655 list_filter
= ('type', )
656 inlines
= (DossierROInline
,)
657 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
658 (None, {'fields': ('nom', 'type', 'pays',)}),
661 def _date_modification(self
, obj
):
662 return date(obj
.date_modification
) \
663 if obj
.date_modification
is not None else "(aucune)"
664 _date_modification
.short_description
= u
'date modification'
665 _date_modification
.admin_order_field
= 'date_modification'
668 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
669 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
670 form
= make_ajax_form(rh
.Poste
, {
671 'implantation': 'implantations',
672 'type_poste': 'typepostes',
673 'responsable': 'postes',
674 'valeur_point_min': 'valeurpoints',
675 'valeur_point_max': 'valeurpoints',
677 alphabet_filter
= 'nom'
682 'implantation__region__code',
683 'implantation__region__nom',
684 'rh_dossiers__employe__nom',
685 'rh_dossiers__employe__prenom',
697 '_date_modification',
701 'implantation__region',
705 'type_poste__famille_emploi',
708 list_display_links
= ('_nom',)
709 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
711 ('nom', 'nom_feminin'),
721 'regime_travail_nb_heure_semaine'),
725 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
728 'fields': (('classement_min',
741 ('Comparatifs de rémunération', {
742 'fields': ('devise_comparaison',
743 ('comp_locale_min', 'comp_locale_max'),
744 ('comp_universite_min', 'comp_universite_max'),
745 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
746 ('comp_ong_min', 'comp_ong_max'),
747 ('comp_autre_min', 'comp_autre_max'))}
750 'fields': ('justification',)}
752 ('Autres Méta-données', {
753 'fields': ('date_debut', 'date_fin')}
757 inlines
= (PosteFinancementInline
,
760 PosteComparaisonInline
,
761 PosteCommentaireInline
, )
763 def lookup_allowed(self
, key
, value
):
766 'date_debut__isnull',
769 'implantation__region__id__exact',
770 'implantation__id__exact',
771 'type_poste__id__exact',
772 'type_poste__famille_emploi__id__exact',
773 'service__id__exact',
780 def _apercu(self
, poste
):
781 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
782 title="Aperçu du poste"
784 <img src="%simg/loupe.png" />
786 (reverse('poste_apercu', args
=(poste
.id,)),
787 settings
.STATIC_URL
,)
789 _apercu
.allow_tags
= True
790 _apercu
.short_description
= ''
794 _id
.short_description
= '#'
795 _id
.admin_order_field
= 'id'
797 def _service(self
, obj
):
798 if obj
.service
.supprime
:
799 return """<span style="color:red">%s</span>""" % obj
.service
802 _service
.short_description
= 'Service'
803 _service
.allow_tags
= True
805 def _responsable(self
, obj
):
807 responsable
= u
"""<a href="%s"
808 onclick="return showAddAnotherPopup(this)">
809 <img src="%simg/loupe.png"
810 title="Aperçu du poste" />
814 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
816 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
822 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
825 onclick="return showAddAnotherPopup(this)">
826 <img src="%simg/loupe.png"
827 title="Aperçu de l'employé">
829 <a href="%s">%s</a>""" % \
830 (reverse('employe_apercu', args
=(employe_id
,)),
832 reverse('admin:rh_employe_change', args
=(employe_id
,)),
837 return "%s %s" % (responsable
, employe
)
838 _responsable
.short_description
= 'Responsable'
839 _responsable
.allow_tags
= True
841 def _nom(self
, poste
):
842 return """<a href="%s">%s</a>""" % \
843 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
845 _nom
.allow_tags
= True
846 _nom
.short_description
= u
'Nom'
847 _nom
.admin_order_field
= 'nom'
849 def _date_modification(self
, obj
):
850 return date(obj
.date_modification
)
851 _date_modification
.short_description
= u
'date modification'
852 _date_modification
.admin_order_field
= 'date_modification'
854 def _occupe_par(self
, obj
):
855 """Formatte la méthode Poste.occupe_par() pour l'admin"""
856 import pdb
; pdb
.set_trace()
859 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.today():
861 employes
= obj
.occupe_par()
865 link
= u
"""<a href='%s'
866 title='Aperçu de l\'employer'
867 onclick='return showAddAnotherPopup(this)'>
868 <img src='%simg/loupe.png' />
870 <a href='%s'>%s</a>""" % \
871 (reverse('employe_apercu', args
=(e
.id,)),
873 reverse('admin:rh_employe_change', args
=(e
.id,)),
876 output
= "\n<br />".join(l
)
878 _occupe_par
.allow_tags
= True
879 _occupe_par
.short_description
= "Occupé par"
881 def save_formset(self
, request
, form
, formset
, change
):
882 instances
= formset
.save(commit
=False)
883 for instance
in instances
:
884 if instance
.__class__
== rh
.PosteCommentaire
:
885 instance
.owner
= request
.user
886 instance
.date_creation
= datetime
.datetime
.now()
891 class PosteCommentaireAdmin(admin
.ModelAdmin
):
895 class PosteFinancementAdmin(admin
.ModelAdmin
):
899 class PostePieceAdmin(admin
.ModelAdmin
):
903 class RemunerationAdmin(admin
.ModelAdmin
):
907 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
908 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
910 'fields': ('employe', 'implantation', ),
915 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
919 '_date_modification',
922 list_filter
= ('archive', )
923 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
925 'fields': ('nom', 'archive', ),
929 def _date_modification(self
, obj
):
930 return date(obj
.date_modification
) \
931 if obj
.date_modification
is not None else "(aucune)"
932 _date_modification
.short_description
= u
'date modification'
933 _date_modification
.admin_order_field
= 'date_modification'
936 class ServiceProxyAdmin(ServiceAdmin
):
937 list_display
= ('nom', '_organigramme')
938 list_display_links
= ('nom',)
940 def has_add_permission(self
, obj
):
943 def _organigramme(self
, obj
):
944 return """<a href="%s">Organigramme</a>""" % (reverse('rho_service', args
=(obj
.id,)))
945 _organigramme
.allow_tags
= True
946 _organigramme
.short_description
= "Organigramme"
948 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
949 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
950 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
952 'fields': ('code', 'nom', ),
956 def _date_modification(self
, obj
):
957 return date(obj
.date_modification
) \
958 if obj
.date_modification
is not None else "(aucune)"
959 _date_modification
.short_description
= u
'date modification'
960 _date_modification
.admin_order_field
= 'date_modification'
963 class TauxChangeAdmin(admin
.ModelAdmin
):
968 '_date_modification',
971 list_filter
= ('devise', )
972 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
974 'fields': ('taux', 'devise', 'annee', ),
978 def _date_modification(self
, obj
):
979 return date(obj
.date_modification
) \
980 if obj
.date_modification
is not None else "(aucune)"
981 _date_modification
.short_description
= u
'date modification'
982 _date_modification
.admin_order_field
= 'date_modification'
985 class TypeContratAdmin(admin
.ModelAdmin
):
989 '_date_modification',
992 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
994 'fields': ('nom', 'nom_long', ),
998 def _date_modification(self
, obj
):
999 return date(obj
.date_modification
) \
1000 if obj
.date_modification
is not None else "(aucune)"
1001 _date_modification
.short_description
= u
'date modification'
1002 _date_modification
.admin_order_field
= 'date_modification'
1005 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1006 search_fields
= ('nom', 'nom_feminin', )
1010 '_date_modification',
1011 'user_modification',
1013 list_filter
= ('famille_emploi', )
1014 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1025 def _date_modification(self
, obj
):
1026 return date(obj
.date_modification
) \
1027 if obj
.date_modification
is not None else "(aucune)"
1028 _date_modification
.short_description
= u
'date modification'
1029 _date_modification
.admin_order_field
= 'date_modification'
1032 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
1036 'nature_remuneration',
1038 '_date_modification',
1039 'user_modification',)
1040 list_filter
= ('archive', )
1041 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1042 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',
1046 def _date_modification(self
, obj
):
1047 return date(obj
.date_modification
) \
1048 if obj
.date_modification
is not None else "(aucune)"
1049 _date_modification
.short_description
= u
'date modification'
1050 _date_modification
.admin_order_field
= 'date_modification'
1053 class TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1054 list_display
= ('nom', '_date_modification', 'user_modification', )
1055 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1056 (None, {'fields': ('nom', )}),
1059 def _date_modification(self
, obj
):
1060 return date(obj
.date_modification
) \
1061 if obj
.date_modification
is not None else "(aucune)"
1062 _date_modification
.short_description
= u
'date modification'
1063 _date_modification
.admin_order_field
= 'date_modification'
1066 class ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1072 '_date_modification',
1073 'user_modification',
1075 list_filter
= ('annee', 'devise', )
1076 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1077 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
1080 def _date_modification(self
, obj
):
1081 return date(obj
.date_modification
) \
1082 if obj
.date_modification
is not None else "(aucune)"
1083 _date_modification
.short_description
= u
'date modification'
1084 _date_modification
.admin_order_field
= 'date_modification'
1086 def _devise_code(self
, obj
):
1087 return obj
.devise
.code
1088 _devise_code
.short_description
= "Code de la devise"
1090 def _devise_nom(self
, obj
):
1091 return obj
.devise
.nom
1092 _devise_nom
.short_description
= "Nom de la devise"
1094 class ImplantationProxyAdmin(admin
.ModelAdmin
):
1095 list_display
= ('nom', '_organigramme')
1096 list_display_links
= ('nom',)
1098 def has_add_permission(self
, obj
):
1101 def _organigramme(self
, obj
):
1102 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
1103 _organigramme
.allow_tags
= True
1104 _organigramme
.short_description
= "Organigramme"
1106 class RegionProxyAdmin(admin
.ModelAdmin
):
1107 list_display
= ('nom', '_organigramme')
1108 list_display_links
= ('nom',)
1110 def has_add_permission(self
, obj
):
1113 def _organigramme(self
, obj
):
1114 return """<a href="%s">Organigramme</a>""" % (reverse('rho_region', args
=(obj
.id,)))
1115 _organigramme
.allow_tags
= True
1116 _organigramme
.short_description
= "Organigramme"
1121 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
1122 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
1123 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
1124 admin
.site
.register(EmployeProxy
, EmployeProxyAdmin
)
1125 admin
.site
.register(ServiceProxy
, ServiceProxyAdmin
)
1126 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
1127 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
1128 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
1129 admin
.site
.register(rh
.Poste
, PosteAdmin
)
1130 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
1131 admin
.site
.register(rh
.Service
, ServiceAdmin
)
1132 admin
.site
.register(rh
.Statut
, StatutAdmin
)
1133 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
1134 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
1135 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
1136 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
1137 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
1138 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)
1139 admin
.site
.register(ImplantationProxy
, ImplantationProxyAdmin
)
1140 admin
.site
.register(RegionProxy
, RegionProxyAdmin
)