filtre nb postes
[auf_rh_dae.git] / project / rh / admin.py
CommitLineData
53ae644d
OL
1# -*- encoding: utf-8 -*-
2
3from collections import defaultdict
4import datetime
5
6from django.db import models
7from django import forms
8from django.core.urlresolvers import reverse
50fa9bc1 9from django.contrib import admin
53ae644d
OL
10from django.conf import settings
11from django.db.models import Q
12from ajax_select import make_ajax_form
13from auf.django.metadata.admin import AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, AUF_METADATA_READONLY_FIELDS
14from forms import ContratForm, AyantDroitForm, EmployeAdminForm, AjaxSelect
15from dae.utils import get_employe_from_user
16import models as rh
17
18# Override of the InlineModelAdmin to support the link in the tabular inline
19class LinkedInline(admin.options.InlineModelAdmin):
20 template = "admin/linked.html"
21 admin_model_path = None
22
23 def __init__(self, *args):
24 super(LinkedInline, self).__init__(*args)
25 if self.admin_model_path is None:
26 self.admin_model_path = self.model.__name__.lower()
27
28
29class ProtectRegionMixin(object):
30
31 def queryset(self, request):
32 from dae.workflow import grp_drh, grp_correspondants_rh
33 qs = super(ProtectRegionMixin, self).queryset(request)
34
35 if request.user.is_superuser:
36 return qs
37
38 user_groups = request.user.groups.all()
39
40 if grp_drh in user_groups:
41 return qs
42
43 if grp_correspondants_rh in user_groups:
44 employe = get_employe_from_user(request.user)
45 q = Q(**{self.model.prefix_implantation: employe.implantation.region})
46 qs = qs.filter(q).distinct()
47 return qs
48 return qs.none()
49
50 def has_change_permission(self, request, obj=None):
51 if obj is None:
52 return True
53 ids = [o.id for o in self.queryset(request)]
54 return obj.id in ids
55
56
57# Inlines
58
59class ReadOnlyInlineMixin(object):
60 def get_readonly_fields(self, request, obj=None):
61 return [f.name for f in self.model._meta.fields if f.name not in AUF_METADATA_READONLY_FIELDS]
62
63
64class AyantDroitInline(AUFMetadataInlineAdminMixin, admin.StackedInline):
65 model = rh.AyantDroit
66 form = AyantDroitForm
67 extra = 0
68
69 fieldsets = (
70 (None, {
71 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', 'lien_parente', )
72 }),
73 )
74
75
76class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
77 readonly_fields = ('owner', )
78 model = rh.AyantDroitCommentaire
79 extra = 1
80
81
82class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
83 form = ContratForm
84 model = rh.Contrat
85 extra = 1
86
87
88class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
89 template = "admin/rh/dossier/linked.html"
90 exclude = AUF_METADATA_READONLY_FIELDS
91 model = rh.Dossier
92 extra = 0
93 can_delete = False
94
95 def has_add_permission(self, request=None):
96 return False
97
98 def has_change_permission(self, request, obj=None):
99 return False
100
101 def has_delete_permission(self, request, obj=None):
102 return False
103
104
105class DossierCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
106 readonly_fields = ('owner', )
107 model = rh.DossierCommentaire
108 extra = 1
109
110
111class DossierPieceInline(admin.TabularInline):
112 model = rh.DossierPiece
113 extra = 4
114
115
116class EmployeInline(admin.TabularInline):
117 model = rh.Employe
118
119class EmployeCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
120 readonly_fields = ('owner', )
121 model = rh.EmployeCommentaire
122 extra = 1
123
124
125class EmployePieceInline(admin.TabularInline):
126 model = rh.EmployePiece
127 extra = 4
128
129
53ae644d
OL
130class PosteCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
131 readonly_fields = ('owner', )
132 model = rh.PosteCommentaire
133 extra = 1
134
135
136class PosteFinancementInline(admin.TabularInline):
137 model = rh.PosteFinancement
138
139
140class PostePieceInline(admin.TabularInline):
141 model = rh.PostePiece
142
143
144class RemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
145 model = rh.Remuneration
146 extra = 1
147
148
149class RemunerationROInline(ReadOnlyInlineMixin, RemunerationInline):
150 pass
151
152
153class TypePosteInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
154 model = rh.TypePoste
155
156
6f037929
OL
157class PosteComparaisonInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
158 model = rh.PosteComparaison
159
53ae644d
OL
160class AyantDroitAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
161 """
162 L'ajout d'un nouvel ayantdroit se fait dans l'admin de l'employé.
163 """
164 alphabet_filter = 'nom'
165 search_fields = ('nom', 'prenom', 'employe__nom', 'employe__prenom', )
166 list_display = ('_employe', 'lien_parente', '_ayantdroit', )
167 inlines = (AyantDroitCommentaireInline,)
168 readonly_fields = AUFMetadataAdminMixin.readonly_fields + ('employe',)
169 fieldsets = AUFMetadataAdminMixin.fieldsets + (
170 ("Lien avec l'employé", {
171 'fields': (('employe', 'lien_parente'), )
172 }),
173
174 ('Identification', {
175 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
176 }),
177 )
178
179 def save_formset(self, request, form, formset, change):
180 instances = formset.save(commit=False)
181 for instance in instances:
182 if instance.__class__ == rh.AyantDroitCommentaire:
183 instance.owner = request.user
184 instance.save()
185
186 def _ayantdroit(self, obj):
187 return unicode(obj)
188 _ayantdroit.short_description = u'Ayant droit'
189
190 def _employe(self, obj):
191 return unicode(obj.employe)
192 _employe.short_description = u'Employé'
193
194 def has_add_permission(self, request):
195 return False
196
197class AyantDroitCommentaireAdmin(admin.ModelAdmin):
198 pass
199
200
201class ClassementAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 202 list_display = ('_classement', 'date_modification', 'user_modification', )
53ae644d
OL
203 fieldsets = AUFMetadataAdminMixin.fieldsets + (
204 (None, {
205 'fields': ('type', 'echelon', 'degre', 'coefficient', )
206 }),
207 )
208
c5964dc2
OL
209 def _classement(self, obj):
210 return unicode(obj)
211 _classement.short_description = u"Classement"
53ae644d
OL
212
213class CommentaireAdmin(admin.ModelAdmin):
214 pass
215
216
53ae644d 217class DeviseAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 218 list_display = ('code', 'nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
219 fieldsets = AUFMetadataAdminMixin.fieldsets + (
220 (None, {
221 'fields': ('code', 'nom', ),
222 }),
223 )
224
225
226class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
227 alphabet_filter = 'employe__nom'
228 search_fields = ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin')
229 list_display = (
b10920ea 230 '_apercu',
53ae644d
OL
231 '_id',
232 '_poste',
233 '_employe',
234 '_date_debut',
235 '_date_fin',
236 'date_modification',
c5964dc2 237 'user_modification',
53ae644d
OL
238 'actif',
239 )
240 list_filter = (
241 'poste__implantation__region',
242 'poste__implantation',
243 'poste__type_poste',
244 'poste__type_poste__famille_emploi',
245 'rh_contrats__type_contrat',
246 'actif',
247 )
248 inlines = (DossierPieceInline, ContratInline,
249 RemunerationInline,
53ae644d
OL
250 DossierCommentaireInline,
251 )
252 fieldsets = AUFMetadataAdminMixin.fieldsets + (
253 (None, {
254 'fields': ('employe', 'poste', 'statut', 'organisme_bstg',)
255 }),
256 ('Recrutement', {
257 'fields': ('statut_residence', 'remplacement', 'remplacement_de', )
258 }),
259 ('Rémunération', {
260 'fields': ('classement', ('regime_travail', 'regime_travail_nb_heure_semaine'),)
261 }),
262 ('Occupation du Poste par cet Employe', {
263 'fields': (('date_debut', 'date_fin'), )
264 }),
265 )
266 form = make_ajax_form(rh.Dossier, {
267 'employe' : 'employes',
268 'poste' : 'postes',
269 'remplacement_de' : 'dossiers',
270 })
271
272 def lookup_allowed(self, key, value):
273 if key in (
274 'employe__nom__istartswith',
275 'actif__exact',
276 'poste__implantation__region__id__exact',
277 'poste__implantation__id__exact',
278 'poste__type_poste__id__exact',
279 'poste__type_poste__famille_emploi__id__exact',
280 'rh_contrats__type_contrat__id__exact',
281 ):
282 return True
283
b10920ea
JPC
284 def _apercu(self, d):
285 link = u"""<a title="Aperçu du dossier" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
286 (reverse('dossier_apercu', args=(d.id,)),
287 settings.MEDIA_URL,
288 )
289 return link
290 _apercu.allow_tags = True
291 _apercu.short_description = u''
292 _apercu.admin_order_field = ''
293
53ae644d 294 def _id(self, d):
b10920ea
JPC
295 link = u"""<a href="%s" title="Modifier le dossier"><strong>%s</strong></a>""" % \
296 (reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d 297 d.id,
53ae644d
OL
298 )
299 return link
300 _id.allow_tags = True
301 _id.short_description = u'#'
302 _id.admin_order_field = 'id'
303
304
305 def _actif(self, dossier):
306 if dossier.employe.actif:
307 html = """<img alt="True" src="%simg/admin/icon-yes.gif">"""
308 else:
309 html = """<img alt="False" src="%simg/admin/icon-no.gif">"""
310 return html % settings.ADMIN_MEDIA_PREFIX
311 _actif.allow_tags = True
312 _actif.short_description = u'Employé actif'
313 _actif.admin_order_field = 'employe__actif'
314
315 def _date_debut(self, obj):
316 return obj.date_debut
317 _date_debut.short_description = u'Occupation début'
318 _date_debut.admin_order_field = 'date_debut'
319
320 def _date_fin(self, obj):
321 return obj.date_fin
322 _date_fin.short_description = u'Occupation fin'
323 _date_fin.admin_order_field = 'date_fin'
324
325 def _poste(self, dossier):
211a0e56 326 link = u"""<a title="Aperçu du poste" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a> <a href="%s" title="Modifier le poste">%s</a>""" % \
53ae644d 327 (reverse('poste_apercu', args=(dossier.poste.id,)),
53ae644d 328 settings.MEDIA_URL,
211a0e56
JPC
329 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
330 dossier.poste,
53ae644d
OL
331 )
332 return link
333 _poste.allow_tags = True
334 _poste.short_description = u'Poste'
335 _poste.admin_order_field = 'poste__nom'
336
337 def _employe(self, obj):
338 employe = obj.employe
339 view_link = reverse('employe_apercu', args=(employe.id,))
340 edit_link = reverse('admin:rh_employe_change', args=(employe.id,))
341
342 if employe.actif == False:
343 style = "color: grey";
211a0e56 344 view = ""
53ae644d
OL
345 else:
346 style = ""
211a0e56
JPC
347 view = u"""<a href="%s" title="Aperçu l'employé" onclick="return showAddAnotherPopup(this);"><img src="%simg/loupe.png" /></a>""" % (view_link, settings.MEDIA_URL,)
348 return u"""%s<a href='%s' style="%s;">[%s] %s %s</a>""" % \
349 (view, edit_link, style, employe.id, employe.nom.upper(), employe.prenom.title())
53ae644d
OL
350 _employe.allow_tags = True
351 _employe.short_description = u"Employé ([code] NOM Prénom)"
352 _employe.admin_order_field = "employe__nom"
353
354 def save_formset(self, request, form, formset, change):
355 instances = formset.save(commit=False)
356 for instance in instances:
357 if instance.__class__ == rh.DossierCommentaire:
358 instance.owner = request.user
359 instance.save()
360
361
362class DossierPieceAdmin(admin.ModelAdmin):
363 pass
364
365
366class DossierCommentaireAdmin(admin.ModelAdmin):
367 pass
368
369
370class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
371 alphabet_filter = 'nom'
372 DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
373 search_fields = ('id', 'nom', 'prenom', 'nom_affichage', )
374 ordering = ('nom', )
375 form = EmployeAdminForm
b10920ea 376 list_display = ('_apercu', '_nom', '_dossiers', 'date_modification', 'user_modification', 'actif',)
a45e414b 377 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', 'actif', )
53ae644d
OL
378 inlines = (AyantDroitInline,
379 DossierROInline,
380 EmployePieceInline,
381 EmployeCommentaireInline)
382 fieldsets = AUFMetadataAdminMixin.fieldsets + (
383 ('Identification', {
384 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
385 }),
386 ('Informations personnelles', {
387 'fields': ('situation_famille', 'date_entree', )
388 }),
389 ('Coordonnées', {
390 'fields': (('tel_domicile', 'tel_cellulaire'), ('adresse', 'ville'), ('code_postal', 'province'), 'pays', )
391 }),
392 )
393
b10920ea
JPC
394 def _apercu(self, obj):
395 return u"""<a title="Aperçu de l'employé" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
396 (reverse('employe_apercu', args=(obj.id,)), settings.MEDIA_URL)
397 _apercu.allow_tags = True
398 _apercu.short_description = u""
399 _apercu.admin_order_field = ""
400
53ae644d 401 def _nom(self, obj):
53ae644d 402 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
b10920ea
JPC
403 return u"""<a href='%s'><strong>[%s] %s %s</strong></a>""" % \
404 (edit_link, obj.id, obj.nom.upper(), obj.prenom.title(),)
53ae644d
OL
405 _nom.allow_tags = True
406 _nom.short_description = u"Employé ([code] NOM Prénom)"
407 _nom.admin_order_field = "nom"
408
409 def _dossiers(self, obj):
410 l = []
411 for d in obj.rh_dossiers.all().order_by('-date_debut'):
412 style = ""
b10920ea
JPC
413 apercu = u"""<a title="Aperçu du dossier" href="%s" onclick="return showAddAnotherPopup(this);" title="Aperçu du dossier"><img src="%simg/loupe.png" /></a>""" % \
414 (reverse('dossier_apercu', args=(d.id,)), settings.MEDIA_URL,)
415
53ae644d 416 if d.date_fin is not None:
b10920ea 417 apercu = ""
53ae644d 418 style = u"color: grey";
b10920ea
JPC
419 link = u"""<li>%s<a style="%s;" href='%s'>%s : %s</a></li>""" % \
420 (apercu,
421 style,
422 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d
OL
423 d.date_debut.year,
424 d.poste,
53ae644d
OL
425 )
426 l.append(link)
427 return "<ul>%s</ul>" % "\n".join(l)
428 _dossiers.allow_tags = True
429 _dossiers.short_description = u"Dossiers"
430
431 def queryset(self, request):
432 qs = super(EmployeAdmin, self).queryset(request)
433 return qs.select_related(depth=1).order_by('nom')
434
435 def save_formset(self, request, form, formset, change):
436 instances = formset.save(commit=False)
437 for instance in instances:
438 if instance.__class__ == rh.EmployeCommentaire:
439 instance.owner = request.user
440 instance.save()
441
442
443
444class EmployeCommentaireAdmin(admin.ModelAdmin):
445 pass
446
447
448class EmployePieceAdmin(admin.ModelAdmin):
449 pass
450
451
452class FamilleEmploiAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 453 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
454 inlines = (TypePosteInline,)
455 fieldsets = AUFMetadataAdminMixin.fieldsets + (
456 (None, {
457 'fields': ('nom', )
458 }),
459 )
460
461
462class OrganismeBstgAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
c5964dc2
OL
463 search_fields = ('nom',)
464 list_display = ('nom', 'type', 'pays', 'date_modification', 'user_modification', 'actif', )
465 list_filter = ('type', )
53ae644d
OL
466 inlines = (DossierROInline,)
467 fieldsets = AUFMetadataAdminMixin.fieldsets + (
468 (None, {
469 'fields': ('nom', 'type', 'pays', )
470 }),
471 )
472
473
474class PosteAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
475 form = make_ajax_form(rh.Poste, {
476 'implantation' : 'implantations',
477 'type_poste' : 'typepostes',
478 'responsable' : 'postes',
479 'valeur_point_min' : 'valeurpoints',
480 'valeur_point_max' : 'valeurpoints',
481 })
482 alphabet_filter = 'nom'
483 search_fields = ('nom',
484 'implantation__code',
485 'implantation__nom',
486 'implantation__region__code',
487 'implantation__region__nom',
488 )
489 list_display = (
8f3ca727 490 '_apercu',
53ae644d
OL
491 '_nom',
492 '_occupe_par',
493 'implantation',
c5964dc2 494 '_service',
53ae644d
OL
495 'date_debut',
496 'date_fin',
497 'date_modification',
498 'user_modification',
499 'actif',
500 )
501 list_filter = ('service',
502 'implantation__region',
503 'implantation',
504 'type_poste',
505 'type_poste__famille_emploi',
4c53dda4 506 'vacant',
53ae644d
OL
507 'actif',
508 )
509 fieldsets = AUFMetadataAdminMixin.fieldsets + (
510 (None, {
511 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste',
512 'service', 'responsable')
513 }),
514 ('Contrat', {
515 'fields': (('regime_travail', 'regime_travail_nb_heure_semaine'), )
516 }),
517 ('Recrutement', {
518 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)
519 }),
520 ('Rémunération', {
521 'fields': (('classement_min', 'valeur_point_min', 'devise_min', 'salaire_min', 'indemn_min', 'autre_min', ),
522 ('classement_max', 'valeur_point_max' ,'devise_max', 'salaire_max', 'indemn_max', 'autre_max', ),
523 )
524 }),
525 ('Comparatifs de rémunération', {
526 'fields': ('devise_comparaison',
527 ('comp_locale_min', 'comp_locale_max'),
528 ('comp_universite_min', 'comp_universite_max'),
529 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
530 ('comp_ong_min', 'comp_ong_max'),
531 ('comp_autre_min', 'comp_autre_max'))
532 }),
533 ('Justification', {
534 'fields': ('justification',)
535 }),
48a6df80 536 ('Autres Méta-données', {
53ae644d
OL
537 'fields': ('date_debut', 'date_fin')
538 }),
539 )
540
541 inlines = (PosteFinancementInline,
542 PostePieceInline,
543 DossierROInline,
6f037929 544 PosteComparaisonInline,
53ae644d
OL
545 PosteCommentaireInline, )
546
c5964dc2 547
8f3ca727 548 def _apercu(self, poste):
b10920ea 549 link = u"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /></a>""" % \
8f3ca727
JPC
550 (reverse('poste_apercu', args=(poste.id,)),
551 settings.MEDIA_URL,
552 )
553 return link
554 _apercu.allow_tags = True
555 _apercu.short_description = u''
556 _apercu.admin_order_field = ''
557
c5964dc2
OL
558 def _service(self, obj):
559 return obj.service
53ae644d
OL
560
561 def _nom(self, poste):
b10920ea 562 link = u"""<a href="%s" title="Modifier le poste"><strong>%s</strong></a>""" % \
8f3ca727 563 (reverse('admin:rh_poste_change', args=(poste.id,)),
53ae644d 564 poste.nom,
53ae644d
OL
565 )
566 return link
567 _nom.allow_tags = True
568 _nom.short_description = u'Nom'
569 _nom.admin_order_field = 'nom'
570
571 def _occupe_par(self, obj):
572 """Formatte la méthode Poste.occupe_par() pour l'admin"""
15c5f55a 573 output = u"Vacant"
bdc6d9ff 574 if obj.actif is False:
954ead19 575 return u"s/o"
53ae644d
OL
576 employes = obj.occupe_par()
577 if employes:
578 l = []
579 for e in employes:
b10920ea
JPC
580 link = "<a href='%s' title='Aperçu de l\'employer' onclick='return showAddAnotherPopup(this)'><img src='%simg/loupe.png' /></a> <a href='%s'>%s</a>" % \
581 (reverse('employe_apercu', args=(e.id,)),
582 settings.MEDIA_URL,
583 reverse('admin:rh_employe_change', args=(e.id,)),
584 e
585 )
53ae644d
OL
586 l.append(link)
587 output = "\n<br />".join(l)
588 return output
589 _occupe_par.allow_tags = True
590 _occupe_par.short_description = "Occupé par"
591
592 def save_formset(self, request, form, formset, change):
593 instances = formset.save(commit=False)
594 for instance in instances:
595 if instance.__class__ == rh.PosteCommentaire:
596 instance.owner = request.user
597 instance.save()
598 formset.save_m2m()
599
600
601class PosteCommentaireAdmin(admin.ModelAdmin):
602 pass
603
604
605class PosteFinancementAdmin(admin.ModelAdmin):
606 pass
607
608
609class PostePieceAdmin(admin.ModelAdmin):
610 fk_name = 'poste'
611
612
613class RemunerationAdmin(admin.ModelAdmin):
614 pass
615
616
617class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
618 fieldsets = AUFMetadataAdminMixin.fieldsets + (
619 (None, {
620 'fields': ('employe', 'implantation', ),
621 }),
622 )
623
624
625class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 626 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
627 fieldsets = AUFMetadataAdminMixin.fieldsets + (
628 (None, {
629 'fields': ('nom', ),
630 }),
631 )
632
633class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 634 list_display = ('code', 'nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
635 fieldsets = AUFMetadataAdminMixin.fieldsets + (
636 (None, {
637 'fields': ('code', 'nom', ),
638 }),
639 )
640
641class TauxChangeAdmin(admin.ModelAdmin):
c5964dc2 642 list_display = ('taux', 'devise', 'annee', 'date_modification', 'user_modification', )
53ae644d
OL
643 list_filter = ('devise', )
644 fieldsets = AUFMetadataAdminMixin.fieldsets + (
645 (None, {
646 'fields': ('taux', 'devise', 'annee', ),
647 }),
648 )
649
650class TypeContratAdmin(admin.ModelAdmin):
c5964dc2 651 list_display = ('nom', 'nom_long', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
652 fieldsets = AUFMetadataAdminMixin.fieldsets + (
653 (None, {
654 'fields': ('nom', 'nom_long', ),
655 }),
656 )
657
658
659class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
660 search_fields = ('nom', 'nom_feminin', )
c5964dc2 661 list_display = ('nom', 'famille_emploi', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
662 list_filter = ('famille_emploi', )
663 fieldsets = AUFMetadataAdminMixin.fieldsets + (
664 (None, {
665 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
666 }),
667 )
668
669
670class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 671 list_display = ('nom', 'type_paiement', 'nature_remuneration', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
672 fieldsets = AUFMetadataAdminMixin.fieldsets + (
673 (None, {
674 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
675 }),
676 )
677
678
679class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 680 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
681 fieldsets = AUFMetadataAdminMixin.fieldsets + (
682 (None, {
683 'fields': ('nom', )
684 }),
685 )
686
687
688class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
689 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', 'date_modification', 'user_modification', )
690 list_filter = ('annee', 'devise', )
53ae644d
OL
691 fieldsets = AUFMetadataAdminMixin.fieldsets + (
692 (None, {
693 'fields': ('valeur', 'devise', 'implantation', 'annee', )
694 }),
695 )
696
697 def _devise_code(self, obj):
698 return obj.devise.code
699 _devise_code.short_description = "Code de la devise"
700
701 def _devise_nom(self, obj):
702 return obj.devise.nom
703 _devise_nom.short_description = "Nom de la devise"
704
705
706admin.site.register(rh.Classement, ClassementAdmin)
707admin.site.register(rh.Devise, DeviseAdmin)
708admin.site.register(rh.Dossier, DossierAdmin)
709admin.site.register(rh.Employe, EmployeAdmin)
710admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
711admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
712admin.site.register(rh.Poste, PosteAdmin)
713admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
714admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 715admin.site.register(rh.Statut, StatutAdmin)
53ae644d 716admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 717admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
718admin.site.register(rh.TypePoste, TypePosteAdmin)
719admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
720admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
721admin.site.register(rh.ValeurPoint, ValeurPointAdmin)