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