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 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 qs
= super(ProtectRegionMixin
, self
).queryset(request
)
88 user_groups
= request
.user
.groups
.all()
89 if in_drh_or_admin(request
.user
):
92 if grp_correspondants_rh
in user_groups
:
93 employe
= get_employe_from_user(request
.user
)
94 q
= Q(**{self
.model
.prefix_implantation
: \
95 employe
.implantation
.region
})
96 qs
= qs
.filter(q
).distinct()
100 def has_change_permission(self
, request
, obj
=None):
101 user_groups
= request
.user
.groups
.all()
103 # Lock pour autoriser uniquement les DRH à utiliser RH
104 if not in_drh_or_admin(request
.user
):
107 if len(user_groups
) == 0 and not request
.user
.is_superuser
:
112 ids
= [o
.id for o
in self
.queryset(request
)]
118 class ReadOnlyInlineMixin(object):
120 def get_readonly_fields(self
, request
, obj
=None):
121 return [f
.name
for f
in self
.model
._meta
.fields \
122 if f
.name
not in AUF_METADATA_READONLY_FIELDS
]
125 class AyantDroitInline(AUFMetadataInlineAdminMixin
, admin
.StackedInline
):
126 model
= rh
.AyantDroit
127 form
= AyantDroitForm
134 ('nom_affichage', 'genre'),
142 class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin
, \
143 admin
.TabularInline
):
144 readonly_fields
= ('owner', )
145 model
= rh
.AyantDroitCommentaire
149 class ContratInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
155 class DossierROInline(ReadOnlyInlineMixin
, LinkedInline
):
156 template
= "admin/rh/dossier/linked.html"
157 exclude
= AUF_METADATA_READONLY_FIELDS
162 def has_add_permission(self
, request
=None):
165 def has_change_permission(self
, request
, obj
=None):
168 def has_delete_permission(self
, request
, obj
=None):
172 class DossierCommentaireInline(AUFMetadataInlineAdminMixin
, \
173 admin
.TabularInline
):
174 readonly_fields
= ('owner', )
175 model
= rh
.DossierCommentaire
179 class DossierPieceInline(admin
.TabularInline
):
180 model
= rh
.DossierPiece
184 class EmployeInline(admin
.TabularInline
):
188 class EmployeCommentaireInline(AUFMetadataInlineAdminMixin
, \
189 admin
.TabularInline
):
190 readonly_fields
= ('owner', )
191 model
= rh
.EmployeCommentaire
195 class EmployePieceInline(admin
.TabularInline
):
196 model
= rh
.EmployePiece
200 class PosteCommentaireInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
201 readonly_fields
= ('owner', )
202 model
= rh
.PosteCommentaire
206 class PosteFinancementInline(admin
.TabularInline
):
207 model
= rh
.PosteFinancement
210 class PostePieceInline(admin
.TabularInline
):
211 model
= rh
.PostePiece
214 class RemunerationInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
215 model
= rh
.Remuneration
219 class RemunerationROInline(ReadOnlyInlineMixin
, RemunerationInline
):
223 class TypePosteInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
227 class PosteComparaisonInline(AUFMetadataInlineAdminMixin
, admin
.TabularInline
):
228 model
= rh
.PosteComparaison
231 class ClassementAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
232 list_display
= ('_classement', '_date_modification', 'user_modification', )
233 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
235 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
238 def _classement(self
, obj
):
240 _classement
.short_description
= u
"Classement"
242 def _date_modification(self
, obj
):
243 return date(obj
.date_modification
) \
244 if obj
.date_modification
is not None else "(aucune)"
245 _date_modification
.short_description
= u
'date modification'
246 _date_modification
.admin_order_field
= 'date_modification'
249 class CommentaireAdmin(admin
.ModelAdmin
):
253 class DeviseAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
258 '_date_modification',
261 list_filter
= ('archive', )
262 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
264 'fields': ('code', 'nom', 'archive', ),
268 def queryset(self
, request
):
269 return self
.model
._base_manager
271 def _archive(self
, obj
):
276 _archive
.short_description
= u
'Archivé'
278 def _date_modification(self
, obj
):
279 return date(obj
.date_modification
) \
280 if obj
.date_modification
is not None else "(aucune)"
281 _date_modification
.short_description
= u
'date modification'
282 _date_modification
.admin_order_field
= 'date_modification'
285 class DossierAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
286 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
287 alphabet_filter
= 'employe__nom'
292 'poste__nom_feminin')
301 '_date_modification',
304 list_display_links
= ('_nom',)
306 'poste__implantation__region',
307 'poste__implantation',
308 'poste__type_poste__famille_emploi',
310 'rh_contrats__type_contrat',
312 inlines
= (DossierPieceInline
, ContratInline
,
314 DossierCommentaireInline
,
316 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
322 'organisme_bstg',)}),
327 'remplacement_de', )}),
331 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
332 ('Occupation du Poste par cet Employe', {
333 'fields': (('date_debut', 'date_fin'), )}
336 form
= make_ajax_form(rh
.Dossier
, {
337 'employe': 'employes',
339 'remplacement_de': 'dossiers',
342 def lookup_allowed(self
, key
, value
):
344 'employe__nom__istartswith',
345 'poste__implantation__region__id__exact',
346 'poste__implantation__id__exact',
347 'poste__type_poste__id__exact',
348 'poste__type_poste__famille_emploi__id__exact',
349 'rh_contrats__type_contrat__id__exact',
355 _id
.short_description
= u
"#"
356 _id
.admin_order_field
= "id"
359 return "%d : %s %s" % (
361 obj
.employe
.nom
.upper(),
363 _nom
.allow_tags
= True
364 _nom
.short_description
= u
"Dossier"
366 def _apercu(self
, d
):
367 apercu_link
= u
"""<a title="Aperçu du dossier"
368 onclick="return showAddAnotherPopup(this);"
370 <img src="%simg/loupe.png" />
372 (reverse('dossier_apercu', args
=(d
.id,)),
376 _apercu
.allow_tags
= True
377 _apercu
.short_description
= u
""
379 def _date_debut(self
, obj
):
380 return date(obj
.date_debut
)
382 _date_debut
.short_description
= u
'Occupation début'
383 _date_debut
.admin_order_field
= 'date_debut'
385 def _date_fin(self
, obj
):
386 return date(obj
.date_fin
)
387 _date_fin
.short_description
= u
'Occupation fin'
388 _date_fin
.admin_order_field
= 'date_fin'
390 def _date_modification(self
, obj
):
391 return date(obj
.date_modification
) \
392 if obj
.date_modification
is not None else "(aucune)"
393 _date_modification
.short_description
= u
'date modification'
394 _date_modification
.admin_order_field
= 'date_modification'
396 def _poste(self
, dossier
):
397 link
= u
"""<a title="Aperçu du poste"
398 onclick="return showAddAnotherPopup(this);"
399 href='%s'><img src="%simg/loupe.png" />
401 <a href="%s" title="Modifier le poste">%s</a>""" % \
402 (reverse('poste_apercu', args
=(dossier
.poste
.id,)),
404 reverse('admin:rh_poste_change', args
=(dossier
.poste
.id,)),
408 _poste
.allow_tags
= True
409 _poste
.short_description
= u
'Poste'
410 _poste
.admin_order_field
= 'poste__nom'
412 def _employe(self
, obj
):
413 employe
= obj
.employe
414 view_link
= reverse('employe_apercu', args
=(employe
.id,))
415 edit_link
= reverse('admin:rh_employe_change', args
=(employe
.id,))
418 view
= u
"""<a href="%s"
419 title="Aperçu l'employé"
420 onclick="return showAddAnotherPopup(this);">
421 <img src="%simg/loupe.png" />
422 </a>""" % (view_link
, settings
.STATIC_URL
,)
423 return u
"""%s<a href='%s' style="%s;">%s</a>""" % \
424 (view
, edit_link
, style
, employe
)
425 _employe
.allow_tags
= True
426 _employe
.short_description
= u
"Employé"
427 _employe
.admin_order_field
= "employe__nom"
429 def save_formset(self
, request
, form
, formset
, change
):
430 instances
= formset
.save(commit
=False)
431 for instance
in instances
:
432 if instance
.__class__
== rh
.DossierCommentaire
:
433 instance
.owner
= request
.user
434 instance
.date_creation
= datetime
.datetime
.now()
438 class DossierPieceAdmin(admin
.ModelAdmin
):
442 class DossierCommentaireAdmin(admin
.ModelAdmin
):
446 class EmployeAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
447 ProtectRegionMixin
, admin
.ModelAdmin
,):
448 prefixe_recherche_temporelle
= "rh_dossiers__"
449 alphabet_filter
= 'nom'
450 DEFAULT_ALPHABET
= u
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
451 search_fields
= ('id', 'nom', 'prenom', 'nom_affichage', )
453 form
= EmployeAdminForm
459 '_date_modification',
462 list_display_links
= ('_nom',)
464 'rh_dossiers__poste__implantation__region',
465 'rh_dossiers__poste__implantation',
468 inlines
= (AyantDroitInline
,
471 EmployeCommentaireInline
)
472 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
476 ('nom_affichage', 'genre'),
481 ('Informations personnelles', {
482 'fields': ('situation_famille', 'date_entree', )}
486 ('tel_domicile', 'tel_cellulaire'),
487 ('adresse', 'ville'),
488 ('code_postal', 'province'),
494 def _apercu(self
, obj
):
495 return u
"""<a title="Aperçu de l'employé"
496 onclick="return showAddAnotherPopup(this);"
498 <img src="%simg/loupe.png" />
500 (reverse('employe_apercu', args
=(obj
.id,)), settings
.STATIC_URL
)
501 _apercu
.allow_tags
= True
502 _apercu
.short_description
= u
""
505 edit_link
= reverse('admin:rh_employe_change', args
=(obj
.id,))
506 return u
"""<a href='%s'><strong>%s</strong></a>""" % \
507 (edit_link
, "%s %s" % (obj
.nom
.upper(), obj
.prenom
))
508 _nom
.allow_tags
= True
509 _nom
.short_description
= u
"Employé"
510 _nom
.admin_order_field
= "nom"
514 _id
.short_description
= u
"#"
515 _id
.admin_order_field
= "id"
517 def _date_modification(self
, obj
):
518 return date(obj
.date_modification
) \
519 if obj
.date_modification
is not None else "(aucune)"
520 _date_modification
.short_description
= u
'date modification'
521 _date_modification
.admin_order_field
= 'date_modification'
523 def _dossiers_postes(self
, obj
):
525 for d
in obj
.rh_dossiers
.all().order_by('-date_debut'):
526 dossier
= u
"""<a title="Aperçu du dossier"
528 onclick="return showAddAnotherPopup(this);"
529 title="Aperçu du dossier">
530 <img src="%simg/loupe.png" />
532 <a href="%s">Dossier</a>
534 (reverse('dossier_apercu', args
=(d
.id,)),
536 reverse('admin:rh_dossier_change', args
=(d
.id,)))
538 poste
= u
"""<a title="Aperçu du poste"
540 onclick="return showAddAnotherPopup(this);"
541 title="Aperçu du poste">
542 <img src="%simg/loupe.png" />
544 <a href="%s">Poste</a>
546 (reverse('poste_apercu', args
=(d
.poste
.id,)),
548 reverse('admin:rh_poste_change', args
=(d
.poste
.id,)))
549 link
= u
"""<li>%s %s - %s : [%s] %s</li>""" % \
556 # Dossier terminé en gris non cliquable
557 if d
.date_fin
is not None and d
.date_fin
< datetime
.date
.today():
558 link
= u
"""<li style="color: grey">%s : [%s] %s</li>""" % \
565 return "<ul>%s</ul>" % "\n".join(l
)
566 _dossiers_postes
.allow_tags
= True
567 _dossiers_postes
.short_description
= u
"Dossiers et postes"
569 def queryset(self
, request
):
570 qs
= super(EmployeAdmin
, self
).queryset(request
)
571 return qs
.select_related(depth
=1).order_by('nom')
573 def save_formset(self
, request
, form
, formset
, change
):
574 instances
= formset
.save(commit
=False)
575 for instance
in instances
:
576 if instance
.__class__
== rh
.EmployeCommentaire
:
577 instance
.owner
= request
.user
578 instance
.date_creation
= datetime
.datetime
.now()
582 class EmployeProxyAdmin(EmployeAdmin
):
583 list_display
= ('_id', '_apercu', '_nom', '_organigramme')
584 list_display_links
= ('_nom',)
586 def has_add_permission(self
, obj
):
589 def _organigramme(self
, obj
):
591 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():
592 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" />""" % \
593 (d
.poste
.id, reverse('rho_employe_sans_niveau', args
=(d
.poste
.id,)), d
.poste
.id)
594 link
= u
"""<li>%s - [%s] %s : %s</li>""" % \
601 return "<ul>%s</ul>" % "\n".join(l
)
603 _organigramme
.allow_tags
= True
604 _organigramme
.short_description
= "Organigramme"
607 class EmployeCommentaireAdmin(admin
.ModelAdmin
):
611 class EmployePieceAdmin(admin
.ModelAdmin
):
615 class FamilleEmploiAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
616 list_display
= ('nom', '_date_modification', 'user_modification', )
617 inlines
= (TypePosteInline
,)
618 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
619 (None, {'fields': ('nom', )}),)
621 def _date_modification(self
, obj
):
622 return date(obj
.date_modification
) \
623 if obj
.date_modification
is not None else "(aucune)"
624 _date_modification
.short_description
= u
'date modification'
625 _date_modification
.admin_order_field
= 'date_modification'
628 class OrganismeBstgAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
629 search_fields
= ('nom',)
634 '_date_modification',
637 list_filter
= ('type', )
638 inlines
= (DossierROInline
,)
639 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
640 (None, {'fields': ('nom', 'type', 'pays',)}),
643 def _date_modification(self
, obj
):
644 return date(obj
.date_modification
) \
645 if obj
.date_modification
is not None else "(aucune)"
646 _date_modification
.short_description
= u
'date modification'
647 _date_modification
.admin_order_field
= 'date_modification'
650 class PosteAdmin(DateRangeMixin
, AUFMetadataAdminMixin
, \
651 ProtectRegionMixin
, admin
.ModelAdmin
, AjaxSelect
,):
652 form
= make_ajax_form(rh
.Poste
, {
653 'implantation': 'implantations',
654 'type_poste': 'typepostes',
655 'responsable': 'postes',
656 'valeur_point_min': 'valeurpoints',
657 'valeur_point_max': 'valeurpoints',
659 alphabet_filter
= 'nom'
664 'implantation__region__code',
665 'implantation__region__nom',
666 'rh_dossiers__employe__nom',
667 'rh_dossiers__employe__prenom',
679 '_date_modification',
683 'implantation__region',
687 'type_poste__famille_emploi',
690 list_display_links
= ('_nom',)
691 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
693 ('nom', 'nom_feminin'),
703 'regime_travail_nb_heure_semaine'),
707 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
710 'fields': (('classement_min',
723 ('Comparatifs de rémunération', {
724 'fields': ('devise_comparaison',
725 ('comp_locale_min', 'comp_locale_max'),
726 ('comp_universite_min', 'comp_universite_max'),
727 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
728 ('comp_ong_min', 'comp_ong_max'),
729 ('comp_autre_min', 'comp_autre_max'))}
732 'fields': ('justification',)}
734 ('Autres Méta-données', {
735 'fields': ('date_debut', 'date_fin')}
739 inlines
= (PosteFinancementInline
,
742 PosteComparaisonInline
,
743 PosteCommentaireInline
, )
745 def lookup_allowed(self
, key
, value
):
748 'date_debut__isnull',
751 'implantation__region__id__exact',
752 'implantation__id__exact',
753 'type_poste__id__exact',
754 'type_poste__famille_emploi__id__exact',
755 'service__id__exact',
762 def _apercu(self
, poste
):
763 view_link
= u
"""<a onclick="return showAddAnotherPopup(this);"
764 title="Aperçu du poste"
766 <img src="%simg/loupe.png" />
768 (reverse('poste_apercu', args
=(poste
.id,)),
769 settings
.STATIC_URL
,)
771 _apercu
.allow_tags
= True
772 _apercu
.short_description
= ''
776 _id
.short_description
= '#'
777 _id
.admin_order_field
= 'id'
779 def _service(self
, obj
):
780 if obj
.service
.supprime
:
781 return """<span style="color:red">%s</span>""" % obj
.service
784 _service
.short_description
= 'Service'
785 _service
.allow_tags
= True
787 def _responsable(self
, obj
):
789 responsable
= u
"""<a href="%s"
790 onclick="return showAddAnotherPopup(this)">
791 <img src="%simg/loupe.png"
792 title="Aperçu du poste" />
796 (reverse('poste_apercu', args
=(obj
.responsable
.id,)),
798 reverse('admin:rh_poste_change', args
=(obj
.responsable
.id,)),
804 employe_id
= obj
.responsable
.rh_dossiers
.all()[0].id
807 onclick="return showAddAnotherPopup(this)">
808 <img src="%simg/loupe.png"
809 title="Aperçu de l'employé">
811 <a href="%s">%s</a>""" % \
812 (reverse('employe_apercu', args
=(employe_id
,)),
814 reverse('admin:rh_employe_change', args
=(employe_id
,)),
819 return "%s %s" % (responsable
, employe
)
820 _responsable
.short_description
= 'Responsable'
821 _responsable
.allow_tags
= True
823 def _nom(self
, poste
):
824 return """<a href="%s">%s</a>""" % \
825 (reverse('admin:rh_poste_change', args
=(poste
.id,)),
827 _nom
.allow_tags
= True
828 _nom
.short_description
= u
'Nom'
829 _nom
.admin_order_field
= 'nom'
831 def _date_modification(self
, obj
):
832 return date(obj
.date_modification
)
833 _date_modification
.short_description
= u
'date modification'
834 _date_modification
.admin_order_field
= 'date_modification'
836 def _occupe_par(self
, obj
):
837 """Formatte la méthode Poste.occupe_par() pour l'admin"""
839 if obj
.date_fin
is not None and obj
.date_fin
< datetime
.date
.now():
841 employes
= obj
.occupe_par()
845 link
= u
"""<a href='%s'
846 title='Aperçu de l\'employer'
847 onclick='return showAddAnotherPopup(this)'>
848 <img src='%simg/loupe.png' />
850 <a href='%s'>%s</a>""" % \
851 (reverse('employe_apercu', args
=(e
.id,)),
853 reverse('admin:rh_employe_change', args
=(e
.id,)),
856 output
= "\n<br />".join(l
)
858 _occupe_par
.allow_tags
= True
859 _occupe_par
.short_description
= "Occupé par"
861 def save_formset(self
, request
, form
, formset
, change
):
862 instances
= formset
.save(commit
=False)
863 for instance
in instances
:
864 if instance
.__class__
== rh
.PosteCommentaire
:
865 instance
.owner
= request
.user
866 instance
.date_creation
= datetime
.datetime
.now()
871 class PosteCommentaireAdmin(admin
.ModelAdmin
):
875 class PosteFinancementAdmin(admin
.ModelAdmin
):
879 class PostePieceAdmin(admin
.ModelAdmin
):
883 class RemunerationAdmin(admin
.ModelAdmin
):
887 class ResponsableImplantationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
888 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
890 'fields': ('employe', 'implantation', ),
895 class ServiceAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
899 '_date_modification',
902 list_filter
= ('archive', )
903 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
905 'fields': ('nom', 'archive', ),
909 def _archive(self
, obj
):
914 _archive
.short_description
= u
'Archivé'
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_implantation', 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
):
1023 'nature_remuneration',
1024 '_date_modification',
1025 'user_modification',)
1026 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1027 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',)}),
1030 def _date_modification(self
, obj
):
1031 return date(obj
.date_modification
) \
1032 if obj
.date_modification
is not None else "(aucune)"
1033 _date_modification
.short_description
= u
'date modification'
1034 _date_modification
.admin_order_field
= 'date_modification'
1037 class TypeRevalorisationAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1038 list_display
= ('nom', '_date_modification', 'user_modification', )
1039 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1040 (None, {'fields': ('nom', )}),
1043 def _date_modification(self
, obj
):
1044 return date(obj
.date_modification
) \
1045 if obj
.date_modification
is not None else "(aucune)"
1046 _date_modification
.short_description
= u
'date modification'
1047 _date_modification
.admin_order_field
= 'date_modification'
1050 class ValeurPointAdmin(AUFMetadataAdminMixin
, admin
.ModelAdmin
):
1056 '_date_modification',
1057 'user_modification',
1059 list_filter
= ('annee', 'devise', )
1060 fieldsets
= AUFMetadataAdminMixin
.fieldsets
+ (
1061 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
1064 def _date_modification(self
, obj
):
1065 return date(obj
.date_modification
) \
1066 if obj
.date_modification
is not None else "(aucune)"
1067 _date_modification
.short_description
= u
'date modification'
1068 _date_modification
.admin_order_field
= 'date_modification'
1070 def _devise_code(self
, obj
):
1071 return obj
.devise
.code
1072 _devise_code
.short_description
= "Code de la devise"
1074 def _devise_nom(self
, obj
):
1075 return obj
.devise
.nom
1076 _devise_nom
.short_description
= "Nom de la devise"
1078 class ImplantationProxyAdmin(admin
.ModelAdmin
):
1079 list_display
= ('nom', '_organigramme')
1080 list_display_links
= ('nom',)
1082 def has_add_permission(self
, obj
):
1085 def _organigramme(self
, obj
):
1086 return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args
=(obj
.id,)))
1087 _organigramme
.allow_tags
= True
1088 _organigramme
.short_description
= "Organigramme"
1090 class RegionProxyAdmin(admin
.ModelAdmin
):
1091 list_display
= ('nom', '_organigramme')
1092 list_display_links
= ('nom',)
1094 def has_add_permission(self
, obj
):
1097 def _organigramme(self
, obj
):
1098 return """<a href="%s">Organigramme</a>""" % (reverse('rho_region', args
=(obj
.id,)))
1099 _organigramme
.allow_tags
= True
1100 _organigramme
.short_description
= "Organigramme"
1105 admin
.site
.register(rh
.Classement
, ClassementAdmin
)
1106 admin
.site
.register(rh
.Devise
, DeviseAdmin
)
1107 admin
.site
.register(rh
.Dossier
, DossierAdmin
)
1108 admin
.site
.register(EmployeProxy
, EmployeProxyAdmin
)
1109 admin
.site
.register(ServiceProxy
, ServiceProxyAdmin
)
1110 admin
.site
.register(rh
.Employe
, EmployeAdmin
)
1111 admin
.site
.register(rh
.FamilleEmploi
, FamilleEmploiAdmin
)
1112 admin
.site
.register(rh
.OrganismeBstg
, OrganismeBstgAdmin
)
1113 admin
.site
.register(rh
.Poste
, PosteAdmin
)
1114 admin
.site
.register(rh
.ResponsableImplantation
, ResponsableImplantationAdmin
)
1115 admin
.site
.register(rh
.Service
, ServiceAdmin
)
1116 admin
.site
.register(rh
.Statut
, StatutAdmin
)
1117 admin
.site
.register(rh
.TauxChange
, TauxChangeAdmin
)
1118 admin
.site
.register(rh
.TypeContrat
, TypeContratAdmin
)
1119 admin
.site
.register(rh
.TypePoste
, TypePosteAdmin
)
1120 admin
.site
.register(rh
.TypeRemuneration
, TypeRemunerationAdmin
)
1121 admin
.site
.register(rh
.TypeRevalorisation
, TypeRevalorisationAdmin
)
1122 admin
.site
.register(rh
.ValeurPoint
, ValeurPointAdmin
)
1123 admin
.site
.register(ImplantationProxy
, ImplantationProxyAdmin
)
1124 admin
.site
.register(RegionProxy
, RegionProxyAdmin
)