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_correspondants_rh
18 from decorators
import in_drh_or_admin
20 import auf
.django
.references
.models
as ref
22 class ArchiveMixin(object):
24 Archive Mixin pour gérer le queryset et le display
25 NON COMPRIS : list_filter, et list_display, field à setter dans la classe.
28 def queryset(self
, request
):
29 return self
.model
._base_manager
31 def _archive(self
, obj
):
36 _archive
.short_description
= u
'Archivé'
37 _archive
.admin_order_field
= 'archive'
39 class RegionProxy(ref
.Region
):
40 """ Proxy utilisé pour les organigrammes par région """
43 verbose_name
= u
"Organigramme par région"
44 verbose_name_plural
= u
"Organigramme par région"
47 class ImplantationProxy(ref
.Implantation
):
48 """ Proxy utilisé pour les organigrammes par implantation """
51 verbose_name
= u
"Organigramme par implantations"
52 verbose_name_plural
= u
"Organigramme par implantations"
55 class ServiceProxy(rh
.Service
):
56 """ Proxy utilisé pour les organigrammes opar service """
59 verbose_name
= u
"Organigramme par services"
60 verbose_name_plural
= u
"Organigramme par services"
63 class EmployeProxy(rh
.Employe
):
64 """ Proxy utilisé pour les organigrammes des employés """
67 verbose_name
= u
"Organigramme des employés"
68 verbose_name_plural
= u
"Organigramme des employés"
71 class DateRangeMixin(object):
72 prefixe_recherche_temporelle
= ""
74 def get_changelist(self
, request
, **kwargs
):
75 if 'HTTP_REFERER' in request
.META
.keys():
76 referer
= request
.META
['HTTP_REFERER']
77 referer
= "/".join(referer
.split('/')[3:])
78 referer
= "/%s" % referer
.split('?')[0]
79 change_list_view
= 'admin:%s_%s_changelist' % (
80 self
.model
._meta
.app_label
,
81 self
.model
.__name__
.lower(),)
82 if referer
!= reverse(change_list_view
):
83 params
= request
.GET
.copy()
84 params
.update({'statut': 'Actif'})
89 # Override of the InlineModelAdmin to support the link in the tabular inline
90 class LinkedInline(admin
.options
.InlineModelAdmin
):
91 template
= "admin/linked.html"
92 admin_model_path
= None
94 def __init__(self
, *args
):
95 super(LinkedInline
, self
).__init__(*args
)
96 if self
.admin_model_path
is None:
97 self
.admin_model_path
= self
.model
.__name__
.lower()
100 class ProtectRegionMixin(object):
102 def queryset(self
, request
):
103 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
105 user_groups
= request
.user
.groups
.all()
106 if in_drh_or_admin(request
.user
):
109 if grp_correspondants_rh
in user_groups
:
110 employe
= get_employe_from_user(request
.user
)
111 q
= Q(**{self
.model
.prefix_implantation
: \
112 employe
.implantation
.region
})
113 qs
= qs
.filter(q
).distinct()
117 def has_change_permission(self
, request
, obj
=None):
118 user_groups
= request
.user
.groups
.all()
120 # Lock pour autoriser uniquement les DRH à utiliser RH
121 if not in_drh_or_admin(request
.user
):
124 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
129 ids
= [o
.id for o
in self
.queryset(request
)]
135 class ReadOnlyInlineMixin(object):
137 def get_readonly_fields(self
, request
, obj
=None):
138 return [f
.name
for f
in self
.model
._meta
.fields \
139 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
142 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
143 model
= rh
.AyantDroit
144 form
= AyantDroitForm
151 ('nom_affichage', 'genre'),
159 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
160 admin
.TabularInline
):
161 readonly_fields
= ('owner', )
162 model
= rh
.AyantDroitCommentaire
166 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
172 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
173 template
= "admin/rh/dossier/linked.html"
174 exclude
= AUF_METADATA_READONLY_FIELDS
179 def has_add_permission(self
, request
=None):
182 def has_change_permission(self
, request
, obj
=None):
185 def has_delete_permission(self
, request
, obj
=None):
189 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
190 admin
.TabularInline
):
191 readonly_fields
= ('owner', )
192 model
= rh
.DossierCommentaire
196 class DossierPieceInline(admin
.TabularInline
):
197 model
= rh
.DossierPiece
201 class EmployeInline(admin
.TabularInline
):
205 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
206 admin
.TabularInline
):
207 readonly_fields
= ('owner', )
208 model
= rh
.EmployeCommentaire
212 class EmployePieceInline(admin
.TabularInline
):
213 model
= rh
.EmployePiece
217 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
218 readonly_fields
= ('owner', )
219 model
= rh
.PosteCommentaire
223 class PosteFinancementInline(admin
.TabularInline
):
224 model
= rh
.PosteFinancement
227 class PostePieceInline(admin
.TabularInline
):
228 model
= rh
.PostePiece
231 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
232 model
= rh
.Remuneration
236 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
240 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
244 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
245 model
= rh
.PosteComparaison
248 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
249 list_display
= ('_classement', '_date_modification', 'user_modification', )
250 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
252 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
255 def _classement(self
, obj
):
257 _classement
.short_description
= u
"Classement"
259 def _date_modification(self
, obj
):
260 return date(obj
.date_modification
) \
261 if obj
.date_modification
is not None else "(aucune)"
262 _date_modification
.short_description
= u
'date modification'
263 _date_modification
.admin_order_field
= 'date_modification'
266 class CommentaireAdmin(admin
.ModelAdmin
):
270 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
275 '_date_modification',
278 list_filter
= ('archive', )
279 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
281 'fields': ('code', 'nom', 'archive', ),
285 def _date_modification(self
, obj
):
286 return date(obj
.date_modification
) \
287 if obj
.date_modification
is not None else "(aucune)"
288 _date_modification
.short_description
= u
'date modification'
289 _date_modification
.admin_order_field
= 'date_modification'
292 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
293 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
294 alphabet_filter
= 'employe__nom'
299 'poste__nom_feminin')
308 '_date_modification',
311 list_display_links
= ('_nom',)
313 'poste__implantation__region',
314 'poste__implantation',
315 'poste__type_poste__famille_emploi',
317 'rh_contrats__type_contrat',
319 inlines
= (DossierPieceInline
, ContratInline
,
321 DossierCommentaireInline
,
323 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
329 'organisme_bstg',)}),
334 'remplacement_de', )}),
338 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
339 ('Occupation du Poste par cet Employe', {
340 'fields': (('date_debut', 'date_fin'), )}
343 form
= make_ajax_form(rh
.Dossier
, {
344 'employe': 'employes',
346 'remplacement_de': 'dossiers',
349 def lookup_allowed(self
, key
, value
):
351 'employe__nom__istartswith',
352 'poste__implantation__region__id__exact',
353 'poste__implantation__id__exact',
354 'poste__type_poste__id__exact',
355 'poste__type_poste__famille_emploi__id__exact',
356 'rh_contrats__type_contrat__id__exact',
362 _id
.short_description
= u
"#"
363 _id
.admin_order_field
= "id"
366 return "%d : %s %s" % (
368 obj
.employe
.nom
.upper(),
370 _nom
.allow_tags
= True
371 _nom
.short_description
= u
"Dossier"
373 def _apercu(self
, d
):
374 apercu_link
= u
"""<a title="Aperçu du dossier"
375 onclick="return showAddAnotherPopup(this);"
377 <img src="%simg/loupe.png" />
379 (reverse('dossier_apercu', args
=(d
.id,)),
383 _apercu
.allow_tags
= True
384 _apercu
.short_description
= u
""
386 def _date_debut(self
, obj
):
387 return date(obj
.date_debut
)
389 _date_debut
.short_description
= u
'Occupation début'
390 _date_debut
.admin_order_field
= 'date_debut'
392 def _date_fin(self
, obj
):
393 return date(obj
.date_fin
)
394 _date_fin
.short_description
= u
'Occupation fin'
395 _date_fin
.admin_order_field
= 'date_fin'
397 def _date_modification(self
, obj
):
398 return date(obj
.date_modification
) \
399 if obj
.date_modification
is not None else "(aucune)"
400 _date_modification
.short_description
= u
'date modification'
401 _date_modification
.admin_order_field
= 'date_modification'
403 def _poste(self
, dossier
):
404 link
= u
"""<a title="Aperçu du poste"
405 onclick="return showAddAnotherPopup(this);"
406 href='%s'><img src="%simg/loupe.png" />
408 <a href="%s" title="Modifier le poste">%s</a>""" % \
409 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
411 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
415 _poste
.allow_tags
= True
416 _poste
.short_description
= u
'Poste'
417 _poste
.admin_order_field
= 'poste__nom'
419 def _employe(self
, obj
):
420 employe
= obj
.employe
421 view_link
= reverse('employe_apercu', args
=(employe
.id,))
422 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
425 view
= u
"""<a href="%s"
426 title="Aperçu l'employé"
427 onclick="return showAddAnotherPopup(this);">
428 <img src="%simg/loupe.png" />
429 </a>""" % (view_link
, settings
.STATIC_URL
,)
430 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
431 (view
, edit_link
, style
, employe
)
432 _employe
.allow_tags
= True
433 _employe
.short_description
= u
"Employé"
434 _employe
.admin_order_field
= "employe__nom"
436 def save_formset(self
, request
, form
, formset
, change
):
437 instances
= formset
.save(commit
=False)
438 for instance
in instances
:
439 if instance
.__class__
== rh
.DossierCommentaire
:
440 instance
.owner
= request
.user
441 instance
.date_creation
= datetime
.datetime
.now()
445 class DossierPieceAdmin(admin
.ModelAdmin
):
449 class DossierCommentaireAdmin(admin
.ModelAdmin
):
453 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
454 ProtectRegionMixin
, admin
.ModelAdmin
,):
455 prefixe_recherche_temporelle
= "rh_dossiers__"
456 alphabet_filter
= 'nom'
457 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
458 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
460 form
= EmployeAdminForm
466 '_date_modification',
469 list_display_links
= ('_nom',)
471 'rh_dossiers__poste__implantation__region',
472 'rh_dossiers__poste__implantation',
475 inlines
= (AyantDroitInline
,
478 EmployeCommentaireInline
)
479 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
483 ('nom_affichage', 'genre'),
488 ('Informations personnelles', {
489 'fields': ('situation_famille', 'date_entree', )}
493 ('tel_domicile', 'tel_cellulaire'),
494 ('adresse', 'ville'),
495 ('code_postal', 'province'),
501 def _apercu(self
, obj
):
502 return u
"""<a title="Aperçu de l'employé"
503 onclick="return showAddAnotherPopup(this);"
505 <img src="%simg/loupe.png" />
507 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
508 _apercu
.allow_tags
= True
509 _apercu
.short_description
= u
""
512 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
513 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
514 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
515 _nom
.allow_tags
= True
516 _nom
.short_description
= u
"Employé"
517 _nom
.admin_order_field
= "nom"
521 _id
.short_description
= u
"#"
522 _id
.admin_order_field
= "id"
524 def _date_modification(self
, obj
):
525 return date(obj
.date_modification
) \
526 if obj
.date_modification
is not None else "(aucune)"
527 _date_modification
.short_description
= u
'date modification'
528 _date_modification
.admin_order_field
= 'date_modification'
530 def _dossiers_postes(self
, obj
):
532 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
533 dossier
= u
"""<a title="Aperçu du dossier"
535 onclick="return showAddAnotherPopup(this);"
536 title="Aperçu du dossier">
537 <img src="%simg/loupe.png" />
539 <a href="%s">Dossier</a>
541 (reverse('dossier_apercu', args
=(d
.id,)),
543 reverse('admin:rh_dossier_change', args
=(d
.id,)))
545 poste
= u
"""<a title="Aperçu du poste"
547 onclick="return showAddAnotherPopup(this);"
548 title="Aperçu du poste">
549 <img src="%simg/loupe.png" />
551 <a href="%s">Poste</a>
553 (reverse('poste_apercu', args
=(d
.poste
.id,)),
555 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
556 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
563 # Dossier terminé en gris non cliquable
564 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
565 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
572 return "<ul>%s</ul>" % "\n".join(l
)
573 _dossiers_postes
.allow_tags
= True
574 _dossiers_postes
.short_description
= u
"Dossiers et postes"
576 def queryset(self
, request
):
577 qs
= super(EmployeAdmin
, self
).queryset(request
)
578 return qs
.select_related(depth
=1).order_by('nom')
580 def save_formset(self
, request
, form
, formset
, change
):
581 instances
= formset
.save(commit
=False)
582 for instance
in instances
:
583 if instance
.__class__
== rh
.EmployeCommentaire
:
584 instance
.owner
= request
.user
585 instance
.date_creation
= datetime
.datetime
.now()
589 class EmployeProxyAdmin(EmployeAdmin
):
590 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
591 list_display_links
= ('_nom',)
593 def has_add_permission(self
, obj
):
596 def _organigramme(self
, obj
):
598 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():
599 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" />""" % \
600 (d
.poste
.id, reverse('rho_employe_sans_niveau', args
=(d
.poste
.id,)), d
.poste
.id)
601 link
= u
"""<li>%s - [%s] %s : %s</li>""" % \
608 return "<ul>%s</ul>" % "\n".join(l
)
610 _organigramme
.allow_tags
= True
611 _organigramme
.short_description
= "Organigramme"
614 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
618 class EmployePieceAdmin(admin
.ModelAdmin
):
622 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
623 list_display
= ('nom', '_date_modification', 'user_modification', )
624 inlines
= (TypePosteInline
,)
625 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
626 (None, {'fields': ('nom', )}),)
628 def _date_modification(self
, obj
):
629 return date(obj
.date_modification
) \
630 if obj
.date_modification
is not None else "(aucune)"
631 _date_modification
.short_description
= u
'date modification'
632 _date_modification
.admin_order_field
= 'date_modification'
635 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
636 search_fields
= ('nom',)
641 '_date_modification',
644 list_filter
= ('type', )
645 inlines
= (DossierROInline
,)
646 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
647 (None, {'fields': ('nom', 'type', 'pays',)}),
650 def _date_modification(self
, obj
):
651 return date(obj
.date_modification
) \
652 if obj
.date_modification
is not None else "(aucune)"
653 _date_modification
.short_description
= u
'date modification'
654 _date_modification
.admin_order_field
= 'date_modification'
657 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
658 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
659 form
= make_ajax_form(rh
.Poste
, {
660 'implantation': 'implantations',
661 'type_poste': 'typepostes',
662 'responsable': 'postes',
663 'valeur_point_min': 'valeurpoints',
664 'valeur_point_max': 'valeurpoints',
666 alphabet_filter
= 'nom'
671 'implantation__region__code',
672 'implantation__region__nom',
673 'rh_dossiers__employe__nom',
674 'rh_dossiers__employe__prenom',
686 '_date_modification',
690 'implantation__region',
694 'type_poste__famille_emploi',
697 list_display_links
= ('_nom',)
698 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
700 ('nom', 'nom_feminin'),
710 'regime_travail_nb_heure_semaine'),
714 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
717 'fields': (('classement_min',
730 ('Comparatifs de rémunération', {
731 'fields': ('devise_comparaison',
732 ('comp_locale_min', 'comp_locale_max'),
733 ('comp_universite_min', 'comp_universite_max'),
734 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
735 ('comp_ong_min', 'comp_ong_max'),
736 ('comp_autre_min', 'comp_autre_max'))}
739 'fields': ('justification',)}
741 ('Autres Méta-données', {
742 'fields': ('date_debut', 'date_fin')}
746 inlines
= (PosteFinancementInline
,
749 PosteComparaisonInline
,
750 PosteCommentaireInline
, )
752 def lookup_allowed(self
, key
, value
):
755 'date_debut__isnull',
758 'implantation__region__id__exact',
759 'implantation__id__exact',
760 'type_poste__id__exact',
761 'type_poste__famille_emploi__id__exact',
762 'service__id__exact',
769 def _apercu(self
, poste
):
770 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
771 title="Aperçu du poste"
773 <img src="%simg/loupe.png" />
775 (reverse('poste_apercu', args
=(poste
.id,)),
776 settings
.STATIC_URL
,)
778 _apercu
.allow_tags
= True
779 _apercu
.short_description
= ''
783 _id
.short_description
= '#'
784 _id
.admin_order_field
= 'id'
786 def _service(self
, obj
):
787 if obj
.service
.supprime
:
788 return """<span style="color:red">%s</span>""" % obj
.service
791 _service
.short_description
= 'Service'
792 _service
.allow_tags
= True
794 def _responsable(self
, obj
):
796 responsable
= u
"""<a href="%s"
797 onclick="return showAddAnotherPopup(this)">
798 <img src="%simg/loupe.png"
799 title="Aperçu du poste" />
803 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
805 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
811 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
814 onclick="return showAddAnotherPopup(this)">
815 <img src="%simg/loupe.png"
816 title="Aperçu de l'employé">
818 <a href="%s">%s</a>""" % \
819 (reverse('employe_apercu', args
=(employe_id
,)),
821 reverse('admin:rh_employe_change', args
=(employe_id
,)),
826 return "%s %s" % (responsable
, employe
)
827 _responsable
.short_description
= 'Responsable'
828 _responsable
.allow_tags
= True
830 def _nom(self
, poste
):
831 return """<a href="%s">%s</a>""" % \
832 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
834 _nom
.allow_tags
= True
835 _nom
.short_description
= u
'Nom'
836 _nom
.admin_order_field
= 'nom'
838 def _date_modification(self
, obj
):
839 return date(obj
.date_modification
)
840 _date_modification
.short_description
= u
'date modification'
841 _date_modification
.admin_order_field
= 'date_modification'
843 def _occupe_par(self
, obj
):
844 """Formatte la méthode Poste.occupe_par() pour l'admin"""
846 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.now():
848 employes
= obj
.occupe_par()
852 link
= u
"""<a href='%s'
853 title='Aperçu de l\'employer'
854 onclick='return showAddAnotherPopup(this)'>
855 <img src='%simg/loupe.png' />
857 <a href='%s'>%s</a>""" % \
858 (reverse('employe_apercu', args
=(e
.id,)),
860 reverse('admin:rh_employe_change', args
=(e
.id,)),
863 output
= "\n<br />".join(l
)
865 _occupe_par
.allow_tags
= True
866 _occupe_par
.short_description
= "Occupé par"
868 def save_formset(self
, request
, form
, formset
, change
):
869 instances
= formset
.save(commit
=False)
870 for instance
in instances
:
871 if instance
.__class__
== rh
.PosteCommentaire
:
872 instance
.owner
= request
.user
873 instance
.date_creation
= datetime
.datetime
.now()
878 class PosteCommentaireAdmin(admin
.ModelAdmin
):
882 class PosteFinancementAdmin(admin
.ModelAdmin
):
886 class PostePieceAdmin(admin
.ModelAdmin
):
890 class RemunerationAdmin(admin
.ModelAdmin
):
894 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
895 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
897 'fields': ('employe', 'implantation', ),
902 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
906 '_date_modification',
909 list_filter
= ('archive', )
910 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
912 'fields': ('nom', 'archive', ),
916 def _date_modification(self
, obj
):
917 return date(obj
.date_modification
) \
918 if obj
.date_modification
is not None else "(aucune)"
919 _date_modification
.short_description
= u
'date modification'
920 _date_modification
.admin_order_field
= 'date_modification'
923 class ServiceProxyAdmin(ServiceAdmin
):
924 list_display
= ('nom', '_organigramme')
925 list_display_links
= ('nom',)
927 def has_add_permission(self
, obj
):
930 def _organigramme(self
, obj
):
931 return """<a href="%s">Organigramme</a>""" % (reverse('rho_service', args
=(obj
.id,)))
932 _organigramme
.allow_tags
= True
933 _organigramme
.short_description
= "Organigramme"
935 class StatutAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
936 list_display
= ('code', 'nom', '_date_modification', 'user_modification', )
937 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
939 'fields': ('code', 'nom', ),
943 def _date_modification(self
, obj
):
944 return date(obj
.date_modification
) \
945 if obj
.date_modification
is not None else "(aucune)"
946 _date_modification
.short_description
= u
'date modification'
947 _date_modification
.admin_order_field
= 'date_modification'
950 class TauxChangeAdmin(admin
.ModelAdmin
):
955 '_date_modification',
958 list_filter
= ('devise', )
959 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
961 'fields': ('taux', 'devise', 'annee', ),
965 def _date_modification(self
, obj
):
966 return date(obj
.date_modification
) \
967 if obj
.date_modification
is not None else "(aucune)"
968 _date_modification
.short_description
= u
'date modification'
969 _date_modification
.admin_order_field
= 'date_modification'
972 class TypeContratAdmin(admin
.ModelAdmin
):
976 '_date_modification',
979 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
981 'fields': ('nom', 'nom_long', ),
985 def _date_modification(self
, obj
):
986 return date(obj
.date_modification
) \
987 if obj
.date_modification
is not None else "(aucune)"
988 _date_modification
.short_description
= u
'date modification'
989 _date_modification
.admin_order_field
= 'date_modification'
992 class TypePosteAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
993 search_fields
= ('nom', 'nom_feminin', )
997 '_date_modification',
1000 list_filter
= ('famille_emploi', )
1001 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1012 def _date_modification(self
, obj
):
1013 return date(obj
.date_modification
) \
1014 if obj
.date_modification
is not None else "(aucune)"
1015 _date_modification
.short_description
= u
'date modification'
1016 _date_modification
.admin_order_field
= 'date_modification'
1019 class TypeRemunerationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
, ArchiveMixin
):
1023 'nature_remuneration',
1025 '_date_modification',
1026 'user_modification',)
1027 list_filter
= ('archive', )
1028 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1029 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',
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 TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1041 list_display
= ('nom', '_date_modification', 'user_modification', )
1042 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1043 (None, {'fields': ('nom', )}),
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 ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1059 '_date_modification',
1060 'user_modification',
1062 list_filter
= ('annee', 'devise', )
1063 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1064 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
1067 def _date_modification(self
, obj
):
1068 return date(obj
.date_modification
) \
1069 if obj
.date_modification
is not None else "(aucune)"
1070 _date_modification
.short_description
= u
'date modification'
1071 _date_modification
.admin_order_field
= 'date_modification'
1073 def _devise_code(self
, obj
):
1074 return obj
.devise
.code
1075 _devise_code
.short_description
= "Code de la devise"
1077 def _devise_nom(self
, obj
):
1078 return obj
.devise
.nom
1079 _devise_nom
.short_description
= "Nom de la devise"
1081 class ImplantationProxyAdmin(admin
.ModelAdmin
):
1082 list_display
= ('nom', '_organigramme')
1083 list_display_links
= ('nom',)
1085 def has_add_permission(self
, obj
):
1088 def _organigramme(self
, obj
):
1089 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
1090 _organigramme
.allow_tags
= True
1091 _organigramme
.short_description
= "Organigramme"
1093 class RegionProxyAdmin(admin
.ModelAdmin
):
1094 list_display
= ('nom', '_organigramme')
1095 list_display_links
= ('nom',)
1097 def has_add_permission(self
, obj
):
1100 def _organigramme(self
, obj
):
1101 return """<a href="%s">Organigramme</a>""" % (reverse('rho_region', args
=(obj
.id,)))
1102 _organigramme
.allow_tags
= True
1103 _organigramme
.short_description
= "Organigramme"
1108 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
1109 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
1110 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
1111 admin
.site
.register(EmployeProxy
, EmployeProxyAdmin
)
1112 admin
.site
.register(ServiceProxy
, ServiceProxyAdmin
)
1113 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
1114 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
1115 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
1116 admin
.site
.register(rh
.Poste
, PosteAdmin
)
1117 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
1118 admin
.site
.register(rh
.Service
, ServiceAdmin
)
1119 admin
.site
.register(rh
.Statut
, StatutAdmin
)
1120 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
1121 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
1122 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
1123 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
1124 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
1125 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)
1126 admin
.site
.register(ImplantationProxy
, ImplantationProxyAdmin
)
1127 admin
.site
.register(RegionProxy
, RegionProxyAdmin
)