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 RegionProxy(ref
.Region
):
23 """ Proxy utilisé pour les organigrammes par région """
26 verbose_name
= u
"Organigramme par région"
27 verbose_name_plural
= u
"Organigramme par région"
30 class ImplantationProxy(ref
.Implantation
):
31 """ Proxy utilisé pour les organigrammes par implantation """
34 verbose_name
= u
"Organigramme par implantations"
35 verbose_name_plural
= u
"Organigramme par implantations"
38 class ServiceProxy(rh
.Service
):
39 """ Proxy utilisé pour les organigrammes opar service """
42 verbose_name
= u
"Organigramme par services"
43 verbose_name_plural
= u
"Organigramme par services"
46 class EmployeProxy(rh
.Employe
):
47 """ Proxy utilisé pour les organigrammes des employés """
50 verbose_name
= u
"Organigramme des employés"
51 verbose_name_plural
= u
"Organigramme des employés"
54 class DateRangeMixin(object):
55 prefixe_recherche_temporelle
= ""
57 def get_changelist(self
, request
, **kwargs
):
58 if 'HTTP_REFERER' in request
.META
.keys():
59 referer
= request
.META
['HTTP_REFERER']
60 referer
= "/".join(referer
.split('/')[3:])
61 referer
= "/%s" % referer
.split('?')[0]
62 change_list_view
= 'admin:%s_%s_changelist' % (
63 self
.model
._meta
.app_label
,
64 self
.model
.__name__
.lower(),)
65 if referer
!= reverse(change_list_view
):
66 params
= request
.GET
.copy()
67 params
.update({'statut': 'Actif'})
72 # Override of the InlineModelAdmin to support the link in the tabular inline
73 class LinkedInline(admin
.options
.InlineModelAdmin
):
74 template
= "admin/linked.html"
75 admin_model_path
= None
77 def __init__(self
, *args
):
78 super(LinkedInline
, self
).__init__(*args
)
79 if self
.admin_model_path
is None:
80 self
.admin_model_path
= self
.model
.__name__
.lower()
83 class ProtectRegionMixin(object):
85 def queryset(self
, request
):
86 from dae
.workflow
import grp_drh
, grp_correspondants_rh
87 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
89 if request
.user
.is_superuser
:
92 user_groups
= request
.user
.groups
.all()
94 if grp_drh
in user_groups
:
97 if grp_correspondants_rh
in user_groups
:
98 employe
= get_employe_from_user(request
.user
)
99 q
= Q(**{self
.model
.prefix_implantation
: \
100 employe
.implantation
.region
})
101 qs
= qs
.filter(q
).distinct()
105 def has_change_permission(self
, request
, obj
=None):
106 user_groups
= request
.user
.groups
.all()
108 # Lock pour autoriser uniquement les DRH à utiliser RH
109 if not request
.user
.is_superuser
and not grp_drh
in user_groups
:
112 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
117 ids
= [o
.id for o
in self
.queryset(request
)]
123 class ReadOnlyInlineMixin(object):
125 def get_readonly_fields(self
, request
, obj
=None):
126 return [f
.name
for f
in self
.model
._meta
.fields \
127 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
130 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
131 model
= rh
.AyantDroit
132 form
= AyantDroitForm
139 ('nom_affichage', 'genre'),
147 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
148 admin
.TabularInline
):
149 readonly_fields
= ('owner', )
150 model
= rh
.AyantDroitCommentaire
154 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
160 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
161 template
= "admin/rh/dossier/linked.html"
162 exclude
= AUF_METADATA_READONLY_FIELDS
167 def has_add_permission(self
, request
=None):
170 def has_change_permission(self
, request
, obj
=None):
173 def has_delete_permission(self
, request
, obj
=None):
177 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
178 admin
.TabularInline
):
179 readonly_fields
= ('owner', )
180 model
= rh
.DossierCommentaire
184 class DossierPieceInline(admin
.TabularInline
):
185 model
= rh
.DossierPiece
189 class EmployeInline(admin
.TabularInline
):
193 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
194 admin
.TabularInline
):
195 readonly_fields
= ('owner', )
196 model
= rh
.EmployeCommentaire
200 class EmployePieceInline(admin
.TabularInline
):
201 model
= rh
.EmployePiece
205 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
206 readonly_fields
= ('owner', )
207 model
= rh
.PosteCommentaire
211 class PosteFinancementInline(admin
.TabularInline
):
212 model
= rh
.PosteFinancement
215 class PostePieceInline(admin
.TabularInline
):
216 model
= rh
.PostePiece
219 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
220 model
= rh
.Remuneration
224 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
228 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
232 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
233 model
= rh
.PosteComparaison
236 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
237 list_display
= ('_classement', '_date_modification', 'user_modification', )
238 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
240 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
243 def _classement(self
, obj
):
245 _classement
.short_description
= u
"Classement"
247 def _date_modification(self
, obj
):
248 return date(obj
.date_modification
) \
249 if obj
.date_modification
is not None else "(aucune)"
250 _date_modification
.short_description
= u
'date modification'
251 _date_modification
.admin_order_field
= 'date_modification'
254 class CommentaireAdmin(admin
.ModelAdmin
):
258 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
263 '_date_modification',
266 list_filter
= ('archive', )
267 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
269 'fields': ('code', 'nom', 'archive', ),
273 def queryset(self
, request
):
274 return self
.model
._base_manager
276 def _archive(self
, obj
):
281 _archive
.short_description
= u
'Archivé'
283 def _date_modification(self
, obj
):
284 return date(obj
.date_modification
) \
285 if obj
.date_modification
is not None else "(aucune)"
286 _date_modification
.short_description
= u
'date modification'
287 _date_modification
.admin_order_field
= 'date_modification'
290 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
291 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
292 alphabet_filter
= 'employe__nom'
297 'poste__nom_feminin')
306 '_date_modification',
309 list_display_links
= ('_nom',)
311 'poste__implantation__region',
312 'poste__implantation',
313 'poste__type_poste__famille_emploi',
315 'rh_contrats__type_contrat',
317 inlines
= (DossierPieceInline
, ContratInline
,
319 DossierCommentaireInline
,
321 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
327 'organisme_bstg',)}),
332 'remplacement_de', )}),
336 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
337 ('Occupation du Poste par cet Employe', {
338 'fields': (('date_debut', 'date_fin'), )}
341 form
= make_ajax_form(rh
.Dossier
, {
342 'employe': 'employes',
344 'remplacement_de': 'dossiers',
347 def lookup_allowed(self
, key
, value
):
349 'employe__nom__istartswith',
350 'poste__implantation__region__id__exact',
351 'poste__implantation__id__exact',
352 'poste__type_poste__id__exact',
353 'poste__type_poste__famille_emploi__id__exact',
354 'rh_contrats__type_contrat__id__exact',
360 _id
.short_description
= u
"#"
361 _id
.admin_order_field
= "id"
364 return "%d : %s %s" % (
366 obj
.employe
.nom
.upper(),
368 _nom
.allow_tags
= True
369 _nom
.short_description
= u
"Dossier"
371 def _apercu(self
, d
):
372 apercu_link
= u
"""<a title="Aperçu du dossier"
373 onclick="return showAddAnotherPopup(this);"
375 <img src="%simg/loupe.png" />
377 (reverse('dossier_apercu', args
=(d
.id,)),
381 _apercu
.allow_tags
= True
382 _apercu
.short_description
= u
""
384 def _date_debut(self
, obj
):
385 return date(obj
.date_debut
)
387 _date_debut
.short_description
= u
'Occupation début'
388 _date_debut
.admin_order_field
= 'date_debut'
390 def _date_fin(self
, obj
):
391 return date(obj
.date_fin
)
392 _date_fin
.short_description
= u
'Occupation fin'
393 _date_fin
.admin_order_field
= 'date_fin'
395 def _date_modification(self
, obj
):
396 return date(obj
.date_modification
) \
397 if obj
.date_modification
is not None else "(aucune)"
398 _date_modification
.short_description
= u
'date modification'
399 _date_modification
.admin_order_field
= 'date_modification'
401 def _poste(self
, dossier
):
402 link
= u
"""<a title="Aperçu du poste"
403 onclick="return showAddAnotherPopup(this);"
404 href='%s'><img src="%simg/loupe.png" />
406 <a href="%s" title="Modifier le poste">%s</a>""" % \
407 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
409 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
413 _poste
.allow_tags
= True
414 _poste
.short_description
= u
'Poste'
415 _poste
.admin_order_field
= 'poste__nom'
417 def _employe(self
, obj
):
418 employe
= obj
.employe
419 view_link
= reverse('employe_apercu', args
=(employe
.id,))
420 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
423 view
= u
"""<a href="%s"
424 title="Aperçu l'employé"
425 onclick="return showAddAnotherPopup(this);">
426 <img src="%simg/loupe.png" />
427 </a>""" % (view_link
, settings
.STATIC_URL
,)
428 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
429 (view
, edit_link
, style
, employe
)
430 _employe
.allow_tags
= True
431 _employe
.short_description
= u
"Employé"
432 _employe
.admin_order_field
= "employe__nom"
434 def save_formset(self
, request
, form
, formset
, change
):
435 instances
= formset
.save(commit
=False)
436 for instance
in instances
:
437 if instance
.__class__
== rh
.DossierCommentaire
:
438 instance
.owner
= request
.user
439 instance
.date_creation
= datetime
.datetime
.now()
443 class DossierPieceAdmin(admin
.ModelAdmin
):
447 class DossierCommentaireAdmin(admin
.ModelAdmin
):
451 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
452 ProtectRegionMixin
, admin
.ModelAdmin
,):
453 prefixe_recherche_temporelle
= "rh_dossiers__"
454 alphabet_filter
= 'nom'
455 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
456 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
458 form
= EmployeAdminForm
464 '_date_modification',
467 list_display_links
= ('_nom',)
469 'rh_dossiers__poste__implantation__region',
470 'rh_dossiers__poste__implantation',
473 inlines
= (AyantDroitInline
,
476 EmployeCommentaireInline
)
477 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
481 ('nom_affichage', 'genre'),
486 ('Informations personnelles', {
487 'fields': ('situation_famille', 'date_entree', )}
491 ('tel_domicile', 'tel_cellulaire'),
492 ('adresse', 'ville'),
493 ('code_postal', 'province'),
499 def _apercu(self
, obj
):
500 return u
"""<a title="Aperçu de l'employé"
501 onclick="return showAddAnotherPopup(this);"
503 <img src="%simg/loupe.png" />
505 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
506 _apercu
.allow_tags
= True
507 _apercu
.short_description
= u
""
510 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
511 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
512 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
513 _nom
.allow_tags
= True
514 _nom
.short_description
= u
"Employé"
515 _nom
.admin_order_field
= "nom"
519 _id
.short_description
= u
"#"
520 _id
.admin_order_field
= "id"
522 def _date_modification(self
, obj
):
523 return date(obj
.date_modification
) \
524 if obj
.date_modification
is not None else "(aucune)"
525 _date_modification
.short_description
= u
'date modification'
526 _date_modification
.admin_order_field
= 'date_modification'
528 def _dossiers_postes(self
, obj
):
530 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
531 dossier
= u
"""<a title="Aperçu du dossier"
533 onclick="return showAddAnotherPopup(this);"
534 title="Aperçu du dossier">
535 <img src="%simg/loupe.png" />
537 <a href="%s">Dossier</a>
539 (reverse('dossier_apercu', args
=(d
.id,)),
541 reverse('admin:rh_dossier_change', args
=(d
.id,)))
543 poste
= u
"""<a title="Aperçu du poste"
545 onclick="return showAddAnotherPopup(this);"
546 title="Aperçu du poste">
547 <img src="%simg/loupe.png" />
549 <a href="%s">Poste</a>
551 (reverse('poste_apercu', args
=(d
.poste
.id,)),
553 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
554 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
561 # Dossier terminé en gris non cliquable
562 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
563 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
570 return "<ul>%s</ul>" % "\n".join(l
)
571 _dossiers_postes
.allow_tags
= True
572 _dossiers_postes
.short_description
= u
"Dossiers et postes"
574 def queryset(self
, request
):
575 qs
= super(EmployeAdmin
, self
).queryset(request
)
576 return qs
.select_related(depth
=1).order_by('nom')
578 def save_formset(self
, request
, form
, formset
, change
):
579 instances
= formset
.save(commit
=False)
580 for instance
in instances
:
581 if instance
.__class__
== rh
.EmployeCommentaire
:
582 instance
.owner
= request
.user
583 instance
.date_creation
= datetime
.datetime
.now()
587 class EmployeProxyAdmin(EmployeAdmin
):
588 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
589 list_display_links
= ('_nom',)
591 def has_add_permission(self
, obj
):
594 def _organigramme(self
, obj
):
596 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():
597 poste
= u
"""<a title="Aperçu du poste"
599 onclick="return showAddAnotherPopup(this);"
600 title="Aperçu du poste">
601 <img src="%simg/loupe.png" />
603 <a href="%s">Poste</a>
605 (reverse('poste_apercu', args
=(d
.poste
.id,)),
607 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
608 organigramme
= u
"""<a href="%s">Organigramme</a>""" % \
609 (reverse('rho_employe', args
=(d
.poste
.id, "all")))
610 link
= u
"""<li>%s - %s - %s : [%s] %s</li>""" % \
611 (poste
, organigramme
,
617 return "<ul>%s</ul>" % "\n".join(l
)
619 _organigramme
.allow_tags
= True
620 _organigramme
.short_description
= "Organigramme"
623 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
627 class EmployePieceAdmin(admin
.ModelAdmin
):
631 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
632 list_display
= ('nom', '_date_modification', 'user_modification', )
633 inlines
= (TypePosteInline
,)
634 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
635 (None, {'fields': ('nom', )}),)
637 def _date_modification(self
, obj
):
638 return date(obj
.date_modification
) \
639 if obj
.date_modification
is not None else "(aucune)"
640 _date_modification
.short_description
= u
'date modification'
641 _date_modification
.admin_order_field
= 'date_modification'
644 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
645 search_fields
= ('nom',)
650 '_date_modification',
653 list_filter
= ('type', )
654 inlines
= (DossierROInline
,)
655 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
656 (None, {'fields': ('nom', 'type', 'pays',)}),
659 def _date_modification(self
, obj
):
660 return date(obj
.date_modification
) \
661 if obj
.date_modification
is not None else "(aucune)"
662 _date_modification
.short_description
= u
'date modification'
663 _date_modification
.admin_order_field
= 'date_modification'
666 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
667 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
668 form
= make_ajax_form(rh
.Poste
, {
669 'implantation': 'implantations',
670 'type_poste': 'typepostes',
671 'responsable': 'postes',
672 'valeur_point_min': 'valeurpoints',
673 'valeur_point_max': 'valeurpoints',
675 alphabet_filter
= 'nom'
680 'implantation__region__code',
681 'implantation__region__nom',
682 'rh_dossiers__employe__nom',
683 'rh_dossiers__employe__prenom',
695 '_date_modification',
699 'implantation__region',
703 'type_poste__famille_emploi',
706 list_display_links
= ('_nom',)
707 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
709 ('nom', 'nom_feminin'),
719 'regime_travail_nb_heure_semaine'),
723 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
726 'fields': (('classement_min',
739 ('Comparatifs de rémunération', {
740 'fields': ('devise_comparaison',
741 ('comp_locale_min', 'comp_locale_max'),
742 ('comp_universite_min', 'comp_universite_max'),
743 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
744 ('comp_ong_min', 'comp_ong_max'),
745 ('comp_autre_min', 'comp_autre_max'))}
748 'fields': ('justification',)}
750 ('Autres Méta-données', {
751 'fields': ('date_debut', 'date_fin')}
755 inlines
= (PosteFinancementInline
,
758 PosteComparaisonInline
,
759 PosteCommentaireInline
, )
761 def lookup_allowed(self
, key
, value
):
764 'date_debut__isnull',
767 'implantation__region__id__exact',
768 'implantation__id__exact',
769 'type_poste__id__exact',
770 'type_poste__famille_emploi__id__exact',
771 'service__id__exact',
778 def _apercu(self
, poste
):
779 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
780 title="Aperçu du poste"
782 <img src="%simg/loupe.png" />
784 (reverse('poste_apercu', args
=(poste
.id,)),
785 settings
.STATIC_URL
,)
787 _apercu
.allow_tags
= True
788 _apercu
.short_description
= ''
792 _id
.short_description
= '#'
793 _id
.admin_order_field
= 'id'
795 def _service(self
, obj
):
796 if obj
.service
.supprime
:
797 return """<span style="color:red">%s</span>""" % obj
.service
800 _service
.short_description
= 'Service'
801 _service
.allow_tags
= True
803 def _responsable(self
, obj
):
805 responsable
= u
"""<a href="%s"
806 onclick="return showAddAnotherPopup(this)">
807 <img src="%simg/loupe.png"
808 title="Aperçu du poste" />
812 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
814 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
820 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
823 onclick="return showAddAnotherPopup(this)">
824 <img src="%simg/loupe.png"
825 title="Aperçu de l'employé">
827 <a href="%s">%s</a>""" % \
828 (reverse('employe_apercu', args
=(employe_id
,)),
830 reverse('admin:rh_employe_change', args
=(employe_id
,)),
835 return "%s %s" % (responsable
, employe
)
836 _responsable
.short_description
= 'Responsable'
837 _responsable
.allow_tags
= True
839 def _nom(self
, poste
):
840 return """<a href="%s">%s</a>""" % \
841 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
843 _nom
.allow_tags
= True
844 _nom
.short_description
= u
'Nom'
845 _nom
.admin_order_field
= 'nom'
847 def _date_modification(self
, obj
):
848 return date(obj
.date_modification
)
849 _date_modification
.short_description
= u
'date modification'
850 _date_modification
.admin_order_field
= 'date_modification'
852 def _occupe_par(self
, obj
):
853 """Formatte la méthode Poste.occupe_par() pour l'admin"""
855 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.now():
857 employes
= obj
.occupe_par()
861 link
= u
"""<a href='%s'
862 title='Aperçu de l\'employer'
863 onclick='return showAddAnotherPopup(this)'>
864 <img src='%simg/loupe.png' />
866 <a href='%s'>%s</a>""" % \
867 (reverse('employe_apercu', args
=(e
.id,)),
869 reverse('admin:rh_employe_change', args
=(e
.id,)),
872 output
= "\n<br />".join(l
)
874 _occupe_par
.allow_tags
= True
875 _occupe_par
.short_description
= "Occupé par"
877 def save_formset(self
, request
, form
, formset
, change
):
878 instances
= formset
.save(commit
=False)
879 for instance
in instances
:
880 if instance
.__class__
== rh
.PosteCommentaire
:
881 instance
.owner
= request
.user
882 instance
.date_creation
= datetime
.datetime
.now()
887 class PosteCommentaireAdmin(admin
.ModelAdmin
):
891 class PosteFinancementAdmin(admin
.ModelAdmin
):
895 class PostePieceAdmin(admin
.ModelAdmin
):
899 class RemunerationAdmin(admin
.ModelAdmin
):
903 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
904 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
906 'fields': ('employe', 'implantation', ),
911 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
915 '_date_modification',
918 list_filter
= ('archive', )
919 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
921 'fields': ('nom', 'archive', ),
925 def _archive(self
, obj
):
930 _archive
.short_description
= u
'Archivé'
932 def _date_modification(self
, obj
):
933 return date(obj
.date_modification
) \
934 if obj
.date_modification
is not None else "(aucune)"
935 _date_modification
.short_description
= u
'date modification'
936 _date_modification
.admin_order_field
= 'date_modification'
939 class ServiceProxyAdmin(ServiceAdmin
):
940 list_display
= ('nom', '_organigramme')
941 list_display_links
= ('nom',)
943 def has_add_permission(self
, obj
):
946 def _organigramme(self
, obj
):
947 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
948 _organigramme
.allow_tags
= True
949 _organigramme
.short_description
= "Organigramme"
951 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
952 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
953 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
955 'fields': ('code', 'nom', ),
959 def _date_modification(self
, obj
):
960 return date(obj
.date_modification
) \
961 if obj
.date_modification
is not None else "(aucune)"
962 _date_modification
.short_description
= u
'date modification'
963 _date_modification
.admin_order_field
= 'date_modification'
966 class TauxChangeAdmin(admin
.ModelAdmin
):
971 '_date_modification',
974 list_filter
= ('devise', )
975 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
977 'fields': ('taux', 'devise', 'annee', ),
981 def _date_modification(self
, obj
):
982 return date(obj
.date_modification
) \
983 if obj
.date_modification
is not None else "(aucune)"
984 _date_modification
.short_description
= u
'date modification'
985 _date_modification
.admin_order_field
= 'date_modification'
988 class TypeContratAdmin(admin
.ModelAdmin
):
992 '_date_modification',
995 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
997 'fields': ('nom', 'nom_long', ),
1001 def _date_modification(self
, obj
):
1002 return date(obj
.date_modification
) \
1003 if obj
.date_modification
is not None else "(aucune)"
1004 _date_modification
.short_description
= u
'date modification'
1005 _date_modification
.admin_order_field
= 'date_modification'
1008 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1009 search_fields
= ('nom', 'nom_feminin', )
1013 '_date_modification',
1014 'user_modification',
1016 list_filter
= ('famille_emploi', )
1017 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1028 def _date_modification(self
, obj
):
1029 return date(obj
.date_modification
) \
1030 if obj
.date_modification
is not None else "(aucune)"
1031 _date_modification
.short_description
= u
'date modification'
1032 _date_modification
.admin_order_field
= 'date_modification'
1035 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1039 'nature_remuneration',
1040 '_date_modification',
1041 'user_modification',)
1042 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1043 (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
)