Apercu des postes, employés et dossiers
[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
02e69aa2 356 instance.date_creation = datetime.datetime.now()
53ae644d
OL
357 instance.save()
358
359
360class DossierPieceAdmin(admin.ModelAdmin):
361 pass
362
363
364class DossierCommentaireAdmin(admin.ModelAdmin):
365 pass
366
367
368class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
369 alphabet_filter = 'nom'
370 DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
371 search_fields = ('id', 'nom', 'prenom', 'nom_affichage', )
372 ordering = ('nom', )
373 form = EmployeAdminForm
b10920ea 374 list_display = ('_apercu', '_nom', '_dossiers', 'date_modification', 'user_modification', 'actif',)
a45e414b 375 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', 'actif', )
53ae644d
OL
376 inlines = (AyantDroitInline,
377 DossierROInline,
378 EmployePieceInline,
379 EmployeCommentaireInline)
380 fieldsets = AUFMetadataAdminMixin.fieldsets + (
381 ('Identification', {
382 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
383 }),
384 ('Informations personnelles', {
385 'fields': ('situation_famille', 'date_entree', )
386 }),
387 ('Coordonnées', {
388 'fields': (('tel_domicile', 'tel_cellulaire'), ('adresse', 'ville'), ('code_postal', 'province'), 'pays', )
389 }),
390 )
391
b10920ea
JPC
392 def _apercu(self, obj):
393 return u"""<a title="Aperçu de l'employé" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
822a2c33 394 (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL)
b10920ea
JPC
395 _apercu.allow_tags = True
396 _apercu.short_description = u""
397 _apercu.admin_order_field = ""
398
53ae644d 399 def _nom(self, obj):
53ae644d 400 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
b10920ea
JPC
401 return u"""<a href='%s'><strong>[%s] %s %s</strong></a>""" % \
402 (edit_link, obj.id, obj.nom.upper(), obj.prenom.title(),)
53ae644d
OL
403 _nom.allow_tags = True
404 _nom.short_description = u"Employé ([code] NOM Prénom)"
405 _nom.admin_order_field = "nom"
406
407 def _dossiers(self, obj):
408 l = []
409 for d in obj.rh_dossiers.all().order_by('-date_debut'):
b10920ea 410 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 411 (reverse('dossier_apercu', args=(d.id,)), settings.STATIC_URL,)
b5cc0357 412 link = u"""<li>%s<a href='%s'>%s : %s</a></li>""" % \
b10920ea 413 (apercu,
b10920ea 414 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d
OL
415 d.date_debut.year,
416 d.poste,
53ae644d 417 )
b5cc0357
OL
418
419 # Dossier terminé en gris non cliquable
420 if d.date_fin is not None:
421 link = u"""<li style="color: grey">%s : %s</li>""" % \
422 (d.date_debut.year,
423 d.poste,
424 )
425
53ae644d
OL
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
02e69aa2 440 instance.date_creation = datetime.datetime.now()
53ae644d
OL
441 instance.save()
442
443
444
445class EmployeCommentaireAdmin(admin.ModelAdmin):
446 pass
447
448
449class EmployePieceAdmin(admin.ModelAdmin):
450 pass
451
452
453class FamilleEmploiAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 454 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
455 inlines = (TypePosteInline,)
456 fieldsets = AUFMetadataAdminMixin.fieldsets + (
457 (None, {
458 'fields': ('nom', )
459 }),
460 )
461
462
95b630cf 463class OrganismeBstgAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
464 search_fields = ('nom',)
465 list_display = ('nom', 'type', 'pays', 'date_modification', 'user_modification', 'actif', )
466 list_filter = ('type', )
53ae644d
OL
467 inlines = (DossierROInline,)
468 fieldsets = AUFMetadataAdminMixin.fieldsets + (
469 (None, {
470 'fields': ('nom', 'type', 'pays', )
471 }),
472 )
473
474
475class PosteAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
476 form = make_ajax_form(rh.Poste, {
477 'implantation' : 'implantations',
478 'type_poste' : 'typepostes',
479 'responsable' : 'postes',
480 'valeur_point_min' : 'valeurpoints',
481 'valeur_point_max' : 'valeurpoints',
482 })
483 alphabet_filter = 'nom'
484 search_fields = ('nom',
485 'implantation__code',
486 'implantation__nom',
487 'implantation__region__code',
488 'implantation__region__nom',
489 )
490 list_display = (
8f3ca727 491 '_apercu',
53ae644d
OL
492 '_nom',
493 '_occupe_par',
494 'implantation',
c5964dc2 495 '_service',
53ae644d
OL
496 'date_debut',
497 'date_fin',
498 'date_modification',
499 'user_modification',
500 'actif',
501 )
502 list_filter = ('service',
503 'implantation__region',
504 'implantation',
505 'type_poste',
506 'type_poste__famille_emploi',
4c53dda4 507 'vacant',
53ae644d
OL
508 'actif',
509 )
510 fieldsets = AUFMetadataAdminMixin.fieldsets + (
511 (None, {
512 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste',
513 'service', 'responsable')
514 }),
515 ('Contrat', {
516 'fields': (('regime_travail', 'regime_travail_nb_heure_semaine'), )
517 }),
518 ('Recrutement', {
519 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)
520 }),
521 ('Rémunération', {
522 'fields': (('classement_min', 'valeur_point_min', 'devise_min', 'salaire_min', 'indemn_min', 'autre_min', ),
523 ('classement_max', 'valeur_point_max' ,'devise_max', 'salaire_max', 'indemn_max', 'autre_max', ),
524 )
525 }),
526 ('Comparatifs de rémunération', {
527 'fields': ('devise_comparaison',
528 ('comp_locale_min', 'comp_locale_max'),
529 ('comp_universite_min', 'comp_universite_max'),
530 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
531 ('comp_ong_min', 'comp_ong_max'),
532 ('comp_autre_min', 'comp_autre_max'))
533 }),
534 ('Justification', {
535 'fields': ('justification',)
536 }),
48a6df80 537 ('Autres Méta-données', {
53ae644d
OL
538 'fields': ('date_debut', 'date_fin')
539 }),
540 )
541
542 inlines = (PosteFinancementInline,
543 PostePieceInline,
544 DossierROInline,
6f037929 545 PosteComparaisonInline,
53ae644d
OL
546 PosteCommentaireInline, )
547
c5964dc2 548
8f3ca727 549 def _apercu(self, poste):
b10920ea 550 link = u"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /></a>""" % \
8f3ca727 551 (reverse('poste_apercu', args=(poste.id,)),
822a2c33 552 settings.STATIC_URL,
8f3ca727
JPC
553 )
554 return link
555 _apercu.allow_tags = True
556 _apercu.short_description = u''
557 _apercu.admin_order_field = ''
558
c5964dc2
OL
559 def _service(self, obj):
560 return obj.service
53ae644d
OL
561
562 def _nom(self, poste):
b10920ea 563 link = u"""<a href="%s" title="Modifier le poste"><strong>%s</strong></a>""" % \
8f3ca727 564 (reverse('admin:rh_poste_change', args=(poste.id,)),
53ae644d 565 poste.nom,
53ae644d
OL
566 )
567 return link
568 _nom.allow_tags = True
569 _nom.short_description = u'Nom'
570 _nom.admin_order_field = 'nom'
571
572 def _occupe_par(self, obj):
573 """Formatte la méthode Poste.occupe_par() pour l'admin"""
15c5f55a 574 output = u"Vacant"
bdc6d9ff 575 if obj.actif is False:
954ead19 576 return u"s/o"
53ae644d
OL
577 employes = obj.occupe_par()
578 if employes:
579 l = []
580 for e in employes:
b10920ea
JPC
581 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>" % \
582 (reverse('employe_apercu', args=(e.id,)),
822a2c33 583 settings.STATIC_URL,
b10920ea
JPC
584 reverse('admin:rh_employe_change', args=(e.id,)),
585 e
586 )
53ae644d
OL
587 l.append(link)
588 output = "\n<br />".join(l)
589 return output
590 _occupe_par.allow_tags = True
591 _occupe_par.short_description = "Occupé par"
592
593 def save_formset(self, request, form, formset, change):
594 instances = formset.save(commit=False)
595 for instance in instances:
596 if instance.__class__ == rh.PosteCommentaire:
597 instance.owner = request.user
02e69aa2 598 instance.date_creation = datetime.datetime.now()
53ae644d
OL
599 instance.save()
600 formset.save_m2m()
601
602
603class PosteCommentaireAdmin(admin.ModelAdmin):
604 pass
605
606
607class PosteFinancementAdmin(admin.ModelAdmin):
608 pass
609
610
611class PostePieceAdmin(admin.ModelAdmin):
612 fk_name = 'poste'
613
614
615class RemunerationAdmin(admin.ModelAdmin):
616 pass
617
618
619class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
620 fieldsets = AUFMetadataAdminMixin.fieldsets + (
621 (None, {
622 'fields': ('employe', 'implantation', ),
623 }),
624 )
625
626
627class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 628 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
629 fieldsets = AUFMetadataAdminMixin.fieldsets + (
630 (None, {
631 'fields': ('nom', ),
632 }),
633 )
634
635class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 636 list_display = ('code', 'nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
637 fieldsets = AUFMetadataAdminMixin.fieldsets + (
638 (None, {
639 'fields': ('code', 'nom', ),
640 }),
641 )
642
643class TauxChangeAdmin(admin.ModelAdmin):
c5964dc2 644 list_display = ('taux', 'devise', 'annee', 'date_modification', 'user_modification', )
53ae644d
OL
645 list_filter = ('devise', )
646 fieldsets = AUFMetadataAdminMixin.fieldsets + (
647 (None, {
648 'fields': ('taux', 'devise', 'annee', ),
649 }),
650 )
651
652class TypeContratAdmin(admin.ModelAdmin):
c5964dc2 653 list_display = ('nom', 'nom_long', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
654 fieldsets = AUFMetadataAdminMixin.fieldsets + (
655 (None, {
656 'fields': ('nom', 'nom_long', ),
657 }),
658 )
659
660
661class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
662 search_fields = ('nom', 'nom_feminin', )
c5964dc2 663 list_display = ('nom', 'famille_emploi', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
664 list_filter = ('famille_emploi', )
665 fieldsets = AUFMetadataAdminMixin.fieldsets + (
666 (None, {
667 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
668 }),
669 )
670
671
672class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 673 list_display = ('nom', 'type_paiement', 'nature_remuneration', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
674 fieldsets = AUFMetadataAdminMixin.fieldsets + (
675 (None, {
676 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
677 }),
678 )
679
680
681class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 682 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
683 fieldsets = AUFMetadataAdminMixin.fieldsets + (
684 (None, {
685 'fields': ('nom', )
686 }),
687 )
688
689
690class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
691 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', 'date_modification', 'user_modification', )
692 list_filter = ('annee', 'devise', )
53ae644d
OL
693 fieldsets = AUFMetadataAdminMixin.fieldsets + (
694 (None, {
695 'fields': ('valeur', 'devise', 'implantation', 'annee', )
696 }),
697 )
698
699 def _devise_code(self, obj):
700 return obj.devise.code
701 _devise_code.short_description = "Code de la devise"
702
703 def _devise_nom(self, obj):
704 return obj.devise.nom
705 _devise_nom.short_description = "Nom de la devise"
706
707
708admin.site.register(rh.Classement, ClassementAdmin)
709admin.site.register(rh.Devise, DeviseAdmin)
710admin.site.register(rh.Dossier, DossierAdmin)
711admin.site.register(rh.Employe, EmployeAdmin)
712admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
713admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
714admin.site.register(rh.Poste, PosteAdmin)
715admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
716admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 717admin.site.register(rh.Statut, StatutAdmin)
53ae644d 718admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 719admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
720admin.site.register(rh.TypePoste, TypePosteAdmin)
721admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
722admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
723admin.site.register(rh.ValeurPoint, ValeurPointAdmin)