date range
[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
3195667e 10from django.contrib.admin.views.main import ChangeList as DjangoChangeList
53ae644d
OL
11from django.conf import settings
12from django.db.models import Q
5f36f262 13from django.template.defaultfilters import date
53ae644d
OL
14from ajax_select import make_ajax_form
15from auf.django.metadata.admin import AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, AUF_METADATA_READONLY_FIELDS
16from forms import ContratForm, AyantDroitForm, EmployeAdminForm, AjaxSelect
17from dae.utils import get_employe_from_user
a0d365ed 18from groups import grp_drh
53ae644d 19import models as rh
f614ca5c
OL
20import filters
21
53ae644d 22
3195667e
OL
23
24class ChangeList(DjangoChangeList):
25
26 def __init__(self, *args, **kwargs):
27 super(ChangeList, self).__init__(*args, **kwargs)
28
29 def get_query_set(self):
30 old = self.params.copy()
31 date_debut = None
32 date_fin = None
33 for k, v in self.params.items():
34 if k.startswith('date_debut'):
35 date_debut = v
36 del self.params[k]
37 elif k.startswith('date_fin'):
38 date_fin = v
39 del self.params[k]
40
41 qs = super(ChangeList, self).get_query_set()
42
43 if date_fin is None and date_debut is not None:
44 date_fin = date_debut
45 if date_debut is None and date_fin is not None:
46 date_debut = date_fin
47
48 if date_debut is not None and date_fin is not None:
49 q_left = (Q(date_debut__isnull=True) | Q(date_debut__lte=date_debut)) & (Q(date_fin__gte=date_debut) & Q(date_fin__lte=date_fin))
50 q_right = (Q(date_fin__isnull=True) | Q(date_fin__gte=date_fin)) & (Q(date_debut__gte=date_debut) & Q(date_debut__lte=date_fin))
627ea90b 51 q_both = Q(date_fin__isnull=True) | Q(date_fin__lte=date_fin) & (Q(date_debut__isnull=True) | Q(date_debut__gte=date_debut))
3195667e
OL
52 qs = qs.filter(q_left | q_right | q_both)
53
3195667e
OL
54 self.params = old
55 return qs
56
53ae644d
OL
57# Override of the InlineModelAdmin to support the link in the tabular inline
58class LinkedInline(admin.options.InlineModelAdmin):
59 template = "admin/linked.html"
60 admin_model_path = None
61
62 def __init__(self, *args):
63 super(LinkedInline, self).__init__(*args)
64 if self.admin_model_path is None:
65 self.admin_model_path = self.model.__name__.lower()
66
67
68class ProtectRegionMixin(object):
69
70 def queryset(self, request):
71 from dae.workflow import grp_drh, grp_correspondants_rh
72 qs = super(ProtectRegionMixin, self).queryset(request)
73
74 if request.user.is_superuser:
75 return qs
76
77 user_groups = request.user.groups.all()
78
79 if grp_drh in user_groups:
80 return qs
81
82 if grp_correspondants_rh in user_groups:
83 employe = get_employe_from_user(request.user)
84 q = Q(**{self.model.prefix_implantation: employe.implantation.region})
85 qs = qs.filter(q).distinct()
86 return qs
87 return qs.none()
88
89 def has_change_permission(self, request, obj=None):
20b4867c 90 user_groups = request.user.groups.all()
a0d365ed
OL
91
92 # Lock pour autoriser uniquement les DRH à utiliser RH
93 if not request.user.is_superuser and not grp_drh in user_groups:
94 return False
95
a18bc295 96 if len(user_groups) == 0 and not request.user.is_superuser:
20b4867c
OL
97 return False
98
53ae644d
OL
99 if obj is None:
100 return True
101 ids = [o.id for o in self.queryset(request)]
102 return obj.id in ids
103
104
105# Inlines
106
107class ReadOnlyInlineMixin(object):
108 def get_readonly_fields(self, request, obj=None):
109 return [f.name for f in self.model._meta.fields if f.name not in AUF_METADATA_READONLY_FIELDS]
110
111
112class AyantDroitInline(AUFMetadataInlineAdminMixin, admin.StackedInline):
113 model = rh.AyantDroit
114 form = AyantDroitForm
115 extra = 0
116
117 fieldsets = (
118 (None, {
119 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', 'lien_parente', )
120 }),
121 )
122
123
124class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
125 readonly_fields = ('owner', )
126 model = rh.AyantDroitCommentaire
127 extra = 1
128
129
130class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
131 form = ContratForm
132 model = rh.Contrat
133 extra = 1
134
135
136class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
137 template = "admin/rh/dossier/linked.html"
138 exclude = AUF_METADATA_READONLY_FIELDS
139 model = rh.Dossier
140 extra = 0
141 can_delete = False
142
143 def has_add_permission(self, request=None):
144 return False
145
146 def has_change_permission(self, request, obj=None):
147 return False
148
149 def has_delete_permission(self, request, obj=None):
150 return False
151
152
153class DossierCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
154 readonly_fields = ('owner', )
155 model = rh.DossierCommentaire
156 extra = 1
157
158
159class DossierPieceInline(admin.TabularInline):
160 model = rh.DossierPiece
161 extra = 4
162
163
164class EmployeInline(admin.TabularInline):
165 model = rh.Employe
166
167class EmployeCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
168 readonly_fields = ('owner', )
169 model = rh.EmployeCommentaire
170 extra = 1
171
172
173class EmployePieceInline(admin.TabularInline):
174 model = rh.EmployePiece
175 extra = 4
176
177
53ae644d
OL
178class PosteCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
179 readonly_fields = ('owner', )
180 model = rh.PosteCommentaire
181 extra = 1
182
183
184class PosteFinancementInline(admin.TabularInline):
185 model = rh.PosteFinancement
186
187
188class PostePieceInline(admin.TabularInline):
189 model = rh.PostePiece
190
191
192class RemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
193 model = rh.Remuneration
194 extra = 1
195
196
197class RemunerationROInline(ReadOnlyInlineMixin, RemunerationInline):
198 pass
199
200
201class TypePosteInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
202 model = rh.TypePoste
203
204
6f037929
OL
205class PosteComparaisonInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
206 model = rh.PosteComparaison
207
53ae644d
OL
208
209class ClassementAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 210 list_display = ('_classement', 'date_modification', 'user_modification', )
53ae644d
OL
211 fieldsets = AUFMetadataAdminMixin.fieldsets + (
212 (None, {
213 'fields': ('type', 'echelon', 'degre', 'coefficient', )
214 }),
215 )
216
c5964dc2
OL
217 def _classement(self, obj):
218 return unicode(obj)
219 _classement.short_description = u"Classement"
53ae644d
OL
220
221class CommentaireAdmin(admin.ModelAdmin):
222 pass
223
224
53ae644d 225class DeviseAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 226 list_display = ('code', 'nom', 'date_modification', 'user_modification', )
53ae644d
OL
227 fieldsets = AUFMetadataAdminMixin.fieldsets + (
228 (None, {
229 'fields': ('code', 'nom', ),
230 }),
231 )
232
233
234class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
235 alphabet_filter = 'employe__nom'
236 search_fields = ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin')
237 list_display = (
238 '_id',
239 '_poste',
240 '_employe',
241 '_date_debut',
242 '_date_fin',
243 'date_modification',
c5964dc2 244 'user_modification',
53ae644d
OL
245 )
246 list_filter = (
247 'poste__implantation__region',
248 'poste__implantation',
249 'poste__type_poste',
250 'poste__type_poste__famille_emploi',
251 'rh_contrats__type_contrat',
f614ca5c
OL
252 'date_debut',
253 'date_fin',
53ae644d
OL
254 )
255 inlines = (DossierPieceInline, ContratInline,
256 RemunerationInline,
53ae644d
OL
257 DossierCommentaireInline,
258 )
259 fieldsets = AUFMetadataAdminMixin.fieldsets + (
260 (None, {
261 'fields': ('employe', 'poste', 'statut', 'organisme_bstg',)
262 }),
263 ('Recrutement', {
264 'fields': ('statut_residence', 'remplacement', 'remplacement_de', )
265 }),
266 ('Rémunération', {
267 'fields': ('classement', ('regime_travail', 'regime_travail_nb_heure_semaine'),)
268 }),
269 ('Occupation du Poste par cet Employe', {
270 'fields': (('date_debut', 'date_fin'), )
271 }),
272 )
273 form = make_ajax_form(rh.Dossier, {
274 'employe' : 'employes',
275 'poste' : 'postes',
276 'remplacement_de' : 'dossiers',
277 })
278
279 def lookup_allowed(self, key, value):
280 if key in (
281 'employe__nom__istartswith',
53ae644d
OL
282 'poste__implantation__region__id__exact',
283 'poste__implantation__id__exact',
284 'poste__type_poste__id__exact',
285 'poste__type_poste__famille_emploi__id__exact',
286 'rh_contrats__type_contrat__id__exact',
f614ca5c
OL
287 'date_debut__gte',
288 'date_debut__isnull',
289 'date_fin__lte',
290 'date_fin__isnull',
53ae644d
OL
291 ):
292 return True
293
3195667e
OL
294 def get_changelist(self, request, **kwargs):
295 return ChangeList
5429c435
OL
296
297 def _id(self, d):
298 apercu_link = u"""<a title="Aperçu du dossier" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
b10920ea 299 (reverse('dossier_apercu', args=(d.id,)),
822a2c33 300 settings.STATIC_URL,
b10920ea 301 )
5429c435
OL
302 link = u"""%s&nbsp;<a href="%s" title="Modifier le dossier"><strong>%s</strong></a>""" % \
303 (apercu_link,
304 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d 305 d.id,
53ae644d
OL
306 )
307 return link
308 _id.allow_tags = True
5429c435 309 _id.short_description = u"Dossier__#"
53ae644d
OL
310 _id.admin_order_field = 'id'
311
312
53ae644d 313 def _date_debut(self, obj):
5f36f262
OL
314 return date(obj.date_debut)
315
53ae644d
OL
316 _date_debut.short_description = u'Occupation début'
317 _date_debut.admin_order_field = 'date_debut'
318
319 def _date_fin(self, obj):
5f36f262 320 return date(obj.date_fin)
53ae644d
OL
321 _date_fin.short_description = u'Occupation fin'
322 _date_fin.admin_order_field = 'date_fin'
323
324 def _poste(self, dossier):
211a0e56 325 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 326 (reverse('poste_apercu', args=(dossier.poste.id,)),
822a2c33 327 settings.STATIC_URL,
211a0e56
JPC
328 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
329 dossier.poste,
53ae644d
OL
330 )
331 return link
332 _poste.allow_tags = True
333 _poste.short_description = u'Poste'
334 _poste.admin_order_field = 'poste__nom'
335
336 def _employe(self, obj):
337 employe = obj.employe
338 view_link = reverse('employe_apercu', args=(employe.id,))
339 edit_link = reverse('admin:rh_employe_change', args=(employe.id,))
340
f614ca5c
OL
341 style = ""
342 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
343 return u"""%s<a href='%s' style="%s;">[%s] %s %s</a>""" % \
344 (view, edit_link, style, employe.id, employe.nom.upper(), employe.prenom.title())
53ae644d
OL
345 _employe.allow_tags = True
346 _employe.short_description = u"Employé ([code] NOM Prénom)"
347 _employe.admin_order_field = "employe__nom"
348
349 def save_formset(self, request, form, formset, change):
350 instances = formset.save(commit=False)
351 for instance in instances:
352 if instance.__class__ == rh.DossierCommentaire:
353 instance.owner = request.user
02e69aa2 354 instance.date_creation = datetime.datetime.now()
53ae644d
OL
355 instance.save()
356
357
358class DossierPieceAdmin(admin.ModelAdmin):
359 pass
360
361
362class DossierCommentaireAdmin(admin.ModelAdmin):
363 pass
364
365
366class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
367 alphabet_filter = 'nom'
368 DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
369 search_fields = ('id', 'nom', 'prenom', 'nom_affichage', )
370 ordering = ('nom', )
371 form = EmployeAdminForm
f614ca5c
OL
372 list_display = ('_apercu', '_nom', '_dossiers', 'date_modification', 'user_modification', )
373 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', )
53ae644d
OL
374 inlines = (AyantDroitInline,
375 DossierROInline,
376 EmployePieceInline,
377 EmployeCommentaireInline)
378 fieldsets = AUFMetadataAdminMixin.fieldsets + (
379 ('Identification', {
380 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', )
381 }),
382 ('Informations personnelles', {
383 'fields': ('situation_famille', 'date_entree', )
384 }),
385 ('Coordonnées', {
386 'fields': (('tel_domicile', 'tel_cellulaire'), ('adresse', 'ville'), ('code_postal', 'province'), 'pays', )
387 }),
388 )
389
b10920ea
JPC
390 def _apercu(self, obj):
391 return u"""<a title="Aperçu de l'employé" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
822a2c33 392 (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL)
b10920ea
JPC
393 _apercu.allow_tags = True
394 _apercu.short_description = u""
395 _apercu.admin_order_field = ""
396
53ae644d 397 def _nom(self, obj):
53ae644d 398 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
b10920ea
JPC
399 return u"""<a href='%s'><strong>[%s] %s %s</strong></a>""" % \
400 (edit_link, obj.id, obj.nom.upper(), obj.prenom.title(),)
53ae644d
OL
401 _nom.allow_tags = True
402 _nom.short_description = u"Employé ([code] NOM Prénom)"
403 _nom.admin_order_field = "nom"
404
405 def _dossiers(self, obj):
406 l = []
407 for d in obj.rh_dossiers.all().order_by('-date_debut'):
b10920ea 408 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 409 (reverse('dossier_apercu', args=(d.id,)), settings.STATIC_URL,)
b5cc0357 410 link = u"""<li>%s<a href='%s'>%s : %s</a></li>""" % \
b10920ea 411 (apercu,
b10920ea 412 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d
OL
413 d.date_debut.year,
414 d.poste,
53ae644d 415 )
b5cc0357
OL
416
417 # Dossier terminé en gris non cliquable
418 if d.date_fin is not None:
419 link = u"""<li style="color: grey">%s : %s</li>""" % \
420 (d.date_debut.year,
421 d.poste,
422 )
423
53ae644d
OL
424 l.append(link)
425 return "<ul>%s</ul>" % "\n".join(l)
426 _dossiers.allow_tags = True
427 _dossiers.short_description = u"Dossiers"
428
429 def queryset(self, request):
430 qs = super(EmployeAdmin, self).queryset(request)
431 return qs.select_related(depth=1).order_by('nom')
432
433 def save_formset(self, request, form, formset, change):
434 instances = formset.save(commit=False)
435 for instance in instances:
436 if instance.__class__ == rh.EmployeCommentaire:
437 instance.owner = request.user
02e69aa2 438 instance.date_creation = datetime.datetime.now()
53ae644d
OL
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):
f614ca5c 452 list_display = ('nom', 'date_modification', 'user_modification', )
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 462 search_fields = ('nom',)
f614ca5c 463 list_display = ('nom', 'type', 'pays', 'date_modification', 'user_modification', )
c5964dc2 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',
53ae644d 498 )
f614ca5c
OL
499 list_filter = (
500 'service',
53ae644d
OL
501 'implantation__region',
502 'implantation',
503 'type_poste',
504 'type_poste__famille_emploi',
f614ca5c
OL
505 'date_debut',
506 'date_fin',
4c53dda4 507 'vacant',
53ae644d
OL
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
f614ca5c
OL
547 def lookup_allowed(self, key, value):
548 if key in (
549 'date_debut__gte',
550 'date_debut__isnull',
551 'date_fin__lte',
552 'date_fin__isnull',
553 ):
554 return True
555
c5964dc2 556
8f3ca727 557 def _apercu(self, poste):
5c9d5e55 558 link = u"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /> %s</a>""" % \
8f3ca727 559 (reverse('poste_apercu', args=(poste.id,)),
822a2c33 560 settings.STATIC_URL,
5c9d5e55 561 poste.id,
8f3ca727
JPC
562 )
563 return link
564 _apercu.allow_tags = True
5c9d5e55
OL
565 _apercu.short_description = 'Poste __#'
566 _apercu.admin_order_field = 'id'
8f3ca727 567
c5964dc2
OL
568 def _service(self, obj):
569 return obj.service
53ae644d
OL
570
571 def _nom(self, poste):
b10920ea 572 link = u"""<a href="%s" title="Modifier le poste"><strong>%s</strong></a>""" % \
8f3ca727 573 (reverse('admin:rh_poste_change', args=(poste.id,)),
53ae644d 574 poste.nom,
53ae644d
OL
575 )
576 return link
577 _nom.allow_tags = True
578 _nom.short_description = u'Nom'
579 _nom.admin_order_field = 'nom'
580
581 def _occupe_par(self, obj):
582 """Formatte la méthode Poste.occupe_par() pour l'admin"""
15c5f55a 583 output = u"Vacant"
3195667e 584 if obj.date_fin is not None and obj.date_fin < datetime.date.now():
954ead19 585 return u"s/o"
53ae644d
OL
586 employes = obj.occupe_par()
587 if employes:
588 l = []
589 for e in employes:
b10920ea
JPC
590 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>" % \
591 (reverse('employe_apercu', args=(e.id,)),
822a2c33 592 settings.STATIC_URL,
b10920ea
JPC
593 reverse('admin:rh_employe_change', args=(e.id,)),
594 e
595 )
53ae644d
OL
596 l.append(link)
597 output = "\n<br />".join(l)
598 return output
599 _occupe_par.allow_tags = True
600 _occupe_par.short_description = "Occupé par"
601
602 def save_formset(self, request, form, formset, change):
603 instances = formset.save(commit=False)
604 for instance in instances:
605 if instance.__class__ == rh.PosteCommentaire:
606 instance.owner = request.user
02e69aa2 607 instance.date_creation = datetime.datetime.now()
53ae644d
OL
608 instance.save()
609 formset.save_m2m()
610
611
612class PosteCommentaireAdmin(admin.ModelAdmin):
613 pass
614
615
616class PosteFinancementAdmin(admin.ModelAdmin):
617 pass
618
619
620class PostePieceAdmin(admin.ModelAdmin):
621 fk_name = 'poste'
622
623
624class RemunerationAdmin(admin.ModelAdmin):
625 pass
626
627
628class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
629 fieldsets = AUFMetadataAdminMixin.fieldsets + (
630 (None, {
631 'fields': ('employe', 'implantation', ),
632 }),
633 )
634
635
636class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 637 list_display = ('nom', 'date_modification', 'user_modification', )
53ae644d
OL
638 fieldsets = AUFMetadataAdminMixin.fieldsets + (
639 (None, {
640 'fields': ('nom', ),
641 }),
642 )
643
644class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 645 list_display = ('code', 'nom', 'date_modification', 'user_modification', )
53ae644d
OL
646 fieldsets = AUFMetadataAdminMixin.fieldsets + (
647 (None, {
648 'fields': ('code', 'nom', ),
649 }),
650 )
651
652class TauxChangeAdmin(admin.ModelAdmin):
c5964dc2 653 list_display = ('taux', 'devise', 'annee', 'date_modification', 'user_modification', )
53ae644d
OL
654 list_filter = ('devise', )
655 fieldsets = AUFMetadataAdminMixin.fieldsets + (
656 (None, {
657 'fields': ('taux', 'devise', 'annee', ),
658 }),
659 )
660
661class TypeContratAdmin(admin.ModelAdmin):
f614ca5c 662 list_display = ('nom', 'nom_long', 'date_modification', 'user_modification', )
53ae644d
OL
663 fieldsets = AUFMetadataAdminMixin.fieldsets + (
664 (None, {
665 'fields': ('nom', 'nom_long', ),
666 }),
667 )
668
669
670class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
671 search_fields = ('nom', 'nom_feminin', )
f614ca5c 672 list_display = ('nom', 'famille_emploi', 'date_modification', 'user_modification', )
53ae644d
OL
673 list_filter = ('famille_emploi', )
674 fieldsets = AUFMetadataAdminMixin.fieldsets + (
675 (None, {
676 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
677 }),
678 )
679
680
681class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 682 list_display = ('nom', 'type_paiement', 'nature_remuneration', 'date_modification', 'user_modification', )
53ae644d
OL
683 fieldsets = AUFMetadataAdminMixin.fieldsets + (
684 (None, {
685 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
686 }),
687 )
688
689
690class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 691 list_display = ('nom', 'date_modification', 'user_modification', )
53ae644d
OL
692 fieldsets = AUFMetadataAdminMixin.fieldsets + (
693 (None, {
694 'fields': ('nom', )
695 }),
696 )
697
698
699class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
700 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', 'date_modification', 'user_modification', )
701 list_filter = ('annee', 'devise', )
53ae644d
OL
702 fieldsets = AUFMetadataAdminMixin.fieldsets + (
703 (None, {
704 'fields': ('valeur', 'devise', 'implantation', 'annee', )
705 }),
706 )
707
708 def _devise_code(self, obj):
709 return obj.devise.code
710 _devise_code.short_description = "Code de la devise"
711
712 def _devise_nom(self, obj):
713 return obj.devise.nom
714 _devise_nom.short_description = "Nom de la devise"
715
716
717admin.site.register(rh.Classement, ClassementAdmin)
718admin.site.register(rh.Devise, DeviseAdmin)
719admin.site.register(rh.Dossier, DossierAdmin)
720admin.site.register(rh.Employe, EmployeAdmin)
721admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
722admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
723admin.site.register(rh.Poste, PosteAdmin)
724admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
725admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 726admin.site.register(rh.Statut, StatutAdmin)
53ae644d 727admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 728admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
729admin.site.register(rh.TypePoste, TypePosteAdmin)
730admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
731admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
732admin.site.register(rh.ValeurPoint, ValeurPointAdmin)