date range filter
[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))
51 q_both = Q(date_fin__isnull=True) | Q(date_fin__gte=date_fin) & (Q(date_debut__isnull=True) | Q(date_debut__lte=date_debut))
52 qs = qs.filter(q_left | q_right | q_both)
53
54
55
56 self.params = old
57 return qs
58
53ae644d
OL
59# Override of the InlineModelAdmin to support the link in the tabular inline
60class LinkedInline(admin.options.InlineModelAdmin):
61 template = "admin/linked.html"
62 admin_model_path = None
63
64 def __init__(self, *args):
65 super(LinkedInline, self).__init__(*args)
66 if self.admin_model_path is None:
67 self.admin_model_path = self.model.__name__.lower()
68
69
70class ProtectRegionMixin(object):
71
72 def queryset(self, request):
73 from dae.workflow import grp_drh, grp_correspondants_rh
74 qs = super(ProtectRegionMixin, self).queryset(request)
75
76 if request.user.is_superuser:
77 return qs
78
79 user_groups = request.user.groups.all()
80
81 if grp_drh in user_groups:
82 return qs
83
84 if grp_correspondants_rh in user_groups:
85 employe = get_employe_from_user(request.user)
86 q = Q(**{self.model.prefix_implantation: employe.implantation.region})
87 qs = qs.filter(q).distinct()
88 return qs
89 return qs.none()
90
91 def has_change_permission(self, request, obj=None):
20b4867c 92 user_groups = request.user.groups.all()
a0d365ed
OL
93
94 # Lock pour autoriser uniquement les DRH à utiliser RH
95 if not request.user.is_superuser and not grp_drh in user_groups:
96 return False
97
a18bc295 98 if len(user_groups) == 0 and not request.user.is_superuser:
20b4867c
OL
99 return False
100
53ae644d
OL
101 if obj is None:
102 return True
103 ids = [o.id for o in self.queryset(request)]
104 return obj.id in ids
105
106
107# Inlines
108
109class ReadOnlyInlineMixin(object):
110 def get_readonly_fields(self, request, obj=None):
111 return [f.name for f in self.model._meta.fields if f.name not in AUF_METADATA_READONLY_FIELDS]
112
113
114class AyantDroitInline(AUFMetadataInlineAdminMixin, admin.StackedInline):
115 model = rh.AyantDroit
116 form = AyantDroitForm
117 extra = 0
118
119 fieldsets = (
120 (None, {
121 'fields': (('nom', 'prenom'), ('nom_affichage', 'genre'), 'nationalite', 'date_naissance', 'lien_parente', )
122 }),
123 )
124
125
126class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
127 readonly_fields = ('owner', )
128 model = rh.AyantDroitCommentaire
129 extra = 1
130
131
132class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
133 form = ContratForm
134 model = rh.Contrat
135 extra = 1
136
137
138class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
139 template = "admin/rh/dossier/linked.html"
140 exclude = AUF_METADATA_READONLY_FIELDS
141 model = rh.Dossier
142 extra = 0
143 can_delete = False
144
145 def has_add_permission(self, request=None):
146 return False
147
148 def has_change_permission(self, request, obj=None):
149 return False
150
151 def has_delete_permission(self, request, obj=None):
152 return False
153
154
155class DossierCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
156 readonly_fields = ('owner', )
157 model = rh.DossierCommentaire
158 extra = 1
159
160
161class DossierPieceInline(admin.TabularInline):
162 model = rh.DossierPiece
163 extra = 4
164
165
166class EmployeInline(admin.TabularInline):
167 model = rh.Employe
168
169class EmployeCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
170 readonly_fields = ('owner', )
171 model = rh.EmployeCommentaire
172 extra = 1
173
174
175class EmployePieceInline(admin.TabularInline):
176 model = rh.EmployePiece
177 extra = 4
178
179
53ae644d
OL
180class PosteCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
181 readonly_fields = ('owner', )
182 model = rh.PosteCommentaire
183 extra = 1
184
185
186class PosteFinancementInline(admin.TabularInline):
187 model = rh.PosteFinancement
188
189
190class PostePieceInline(admin.TabularInline):
191 model = rh.PostePiece
192
193
194class RemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
195 model = rh.Remuneration
196 extra = 1
197
198
199class RemunerationROInline(ReadOnlyInlineMixin, RemunerationInline):
200 pass
201
202
203class TypePosteInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
204 model = rh.TypePoste
205
206
6f037929
OL
207class PosteComparaisonInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
208 model = rh.PosteComparaison
209
53ae644d
OL
210
211class ClassementAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 212 list_display = ('_classement', 'date_modification', 'user_modification', )
53ae644d
OL
213 fieldsets = AUFMetadataAdminMixin.fieldsets + (
214 (None, {
215 'fields': ('type', 'echelon', 'degre', 'coefficient', )
216 }),
217 )
218
c5964dc2
OL
219 def _classement(self, obj):
220 return unicode(obj)
221 _classement.short_description = u"Classement"
53ae644d
OL
222
223class CommentaireAdmin(admin.ModelAdmin):
224 pass
225
226
53ae644d 227class DeviseAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 228 list_display = ('code', 'nom', 'date_modification', 'user_modification', )
53ae644d
OL
229 fieldsets = AUFMetadataAdminMixin.fieldsets + (
230 (None, {
231 'fields': ('code', 'nom', ),
232 }),
233 )
234
235
236class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin, AjaxSelect):
237 alphabet_filter = 'employe__nom'
238 search_fields = ('employe__nom', 'employe__prenom', 'poste__nom', 'poste__nom_feminin')
239 list_display = (
240 '_id',
241 '_poste',
242 '_employe',
243 '_date_debut',
244 '_date_fin',
245 'date_modification',
c5964dc2 246 'user_modification',
53ae644d
OL
247 )
248 list_filter = (
249 'poste__implantation__region',
250 'poste__implantation',
251 'poste__type_poste',
252 'poste__type_poste__famille_emploi',
253 'rh_contrats__type_contrat',
f614ca5c
OL
254 'date_debut',
255 'date_fin',
53ae644d
OL
256 )
257 inlines = (DossierPieceInline, ContratInline,
258 RemunerationInline,
53ae644d
OL
259 DossierCommentaireInline,
260 )
261 fieldsets = AUFMetadataAdminMixin.fieldsets + (
262 (None, {
263 'fields': ('employe', 'poste', 'statut', 'organisme_bstg',)
264 }),
265 ('Recrutement', {
266 'fields': ('statut_residence', 'remplacement', 'remplacement_de', )
267 }),
268 ('Rémunération', {
269 'fields': ('classement', ('regime_travail', 'regime_travail_nb_heure_semaine'),)
270 }),
271 ('Occupation du Poste par cet Employe', {
272 'fields': (('date_debut', 'date_fin'), )
273 }),
274 )
275 form = make_ajax_form(rh.Dossier, {
276 'employe' : 'employes',
277 'poste' : 'postes',
278 'remplacement_de' : 'dossiers',
279 })
280
281 def lookup_allowed(self, key, value):
282 if key in (
283 'employe__nom__istartswith',
53ae644d
OL
284 'poste__implantation__region__id__exact',
285 'poste__implantation__id__exact',
286 'poste__type_poste__id__exact',
287 'poste__type_poste__famille_emploi__id__exact',
288 'rh_contrats__type_contrat__id__exact',
f614ca5c
OL
289 'date_debut__gte',
290 'date_debut__isnull',
291 'date_fin__lte',
292 'date_fin__isnull',
53ae644d
OL
293 ):
294 return True
295
3195667e
OL
296 def get_changelist(self, request, **kwargs):
297 return ChangeList
5429c435
OL
298
299 def _id(self, d):
300 apercu_link = u"""<a title="Aperçu du dossier" onclick="return showAddAnotherPopup(this);" href='%s'><img src="%simg/loupe.png" /></a>""" % \
b10920ea 301 (reverse('dossier_apercu', args=(d.id,)),
822a2c33 302 settings.STATIC_URL,
b10920ea 303 )
5429c435
OL
304 link = u"""%s&nbsp;<a href="%s" title="Modifier le dossier"><strong>%s</strong></a>""" % \
305 (apercu_link,
306 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d 307 d.id,
53ae644d
OL
308 )
309 return link
310 _id.allow_tags = True
5429c435 311 _id.short_description = u"Dossier__#"
53ae644d
OL
312 _id.admin_order_field = 'id'
313
314
53ae644d 315 def _date_debut(self, obj):
5f36f262
OL
316 return date(obj.date_debut)
317
53ae644d
OL
318 _date_debut.short_description = u'Occupation début'
319 _date_debut.admin_order_field = 'date_debut'
320
321 def _date_fin(self, obj):
5f36f262 322 return date(obj.date_fin)
53ae644d
OL
323 _date_fin.short_description = u'Occupation fin'
324 _date_fin.admin_order_field = 'date_fin'
325
326 def _poste(self, dossier):
211a0e56 327 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 328 (reverse('poste_apercu', args=(dossier.poste.id,)),
822a2c33 329 settings.STATIC_URL,
211a0e56
JPC
330 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
331 dossier.poste,
53ae644d
OL
332 )
333 return link
334 _poste.allow_tags = True
335 _poste.short_description = u'Poste'
336 _poste.admin_order_field = 'poste__nom'
337
338 def _employe(self, obj):
339 employe = obj.employe
340 view_link = reverse('employe_apercu', args=(employe.id,))
341 edit_link = reverse('admin:rh_employe_change', args=(employe.id,))
342
f614ca5c
OL
343 style = ""
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
f614ca5c
OL
374 list_display = ('_apercu', '_nom', '_dossiers', 'date_modification', 'user_modification', )
375 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', )
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):
f614ca5c 454 list_display = ('nom', 'date_modification', 'user_modification', )
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 464 search_fields = ('nom',)
f614ca5c 465 list_display = ('nom', 'type', 'pays', 'date_modification', 'user_modification', )
c5964dc2 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',
53ae644d 500 )
f614ca5c
OL
501 list_filter = (
502 'service',
53ae644d
OL
503 'implantation__region',
504 'implantation',
505 'type_poste',
506 'type_poste__famille_emploi',
f614ca5c
OL
507 'date_debut',
508 'date_fin',
4c53dda4 509 'vacant',
53ae644d
OL
510 )
511 fieldsets = AUFMetadataAdminMixin.fieldsets + (
512 (None, {
513 'fields': (('nom', 'nom_feminin'), 'implantation', 'type_poste',
514 'service', 'responsable')
515 }),
516 ('Contrat', {
517 'fields': (('regime_travail', 'regime_travail_nb_heure_semaine'), )
518 }),
519 ('Recrutement', {
520 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)
521 }),
522 ('Rémunération', {
523 'fields': (('classement_min', 'valeur_point_min', 'devise_min', 'salaire_min', 'indemn_min', 'autre_min', ),
524 ('classement_max', 'valeur_point_max' ,'devise_max', 'salaire_max', 'indemn_max', 'autre_max', ),
525 )
526 }),
527 ('Comparatifs de rémunération', {
528 'fields': ('devise_comparaison',
529 ('comp_locale_min', 'comp_locale_max'),
530 ('comp_universite_min', 'comp_universite_max'),
531 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
532 ('comp_ong_min', 'comp_ong_max'),
533 ('comp_autre_min', 'comp_autre_max'))
534 }),
535 ('Justification', {
536 'fields': ('justification',)
537 }),
48a6df80 538 ('Autres Méta-données', {
53ae644d
OL
539 'fields': ('date_debut', 'date_fin')
540 }),
541 )
542
543 inlines = (PosteFinancementInline,
544 PostePieceInline,
545 DossierROInline,
6f037929 546 PosteComparaisonInline,
53ae644d
OL
547 PosteCommentaireInline, )
548
f614ca5c
OL
549 def lookup_allowed(self, key, value):
550 if key in (
551 'date_debut__gte',
552 'date_debut__isnull',
553 'date_fin__lte',
554 'date_fin__isnull',
555 ):
556 return True
557
c5964dc2 558
8f3ca727 559 def _apercu(self, poste):
5c9d5e55 560 link = u"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /> %s</a>""" % \
8f3ca727 561 (reverse('poste_apercu', args=(poste.id,)),
822a2c33 562 settings.STATIC_URL,
5c9d5e55 563 poste.id,
8f3ca727
JPC
564 )
565 return link
566 _apercu.allow_tags = True
5c9d5e55
OL
567 _apercu.short_description = 'Poste __#'
568 _apercu.admin_order_field = 'id'
8f3ca727 569
c5964dc2
OL
570 def _service(self, obj):
571 return obj.service
53ae644d
OL
572
573 def _nom(self, poste):
b10920ea 574 link = u"""<a href="%s" title="Modifier le poste"><strong>%s</strong></a>""" % \
8f3ca727 575 (reverse('admin:rh_poste_change', args=(poste.id,)),
53ae644d 576 poste.nom,
53ae644d
OL
577 )
578 return link
579 _nom.allow_tags = True
580 _nom.short_description = u'Nom'
581 _nom.admin_order_field = 'nom'
582
583 def _occupe_par(self, obj):
584 """Formatte la méthode Poste.occupe_par() pour l'admin"""
15c5f55a 585 output = u"Vacant"
3195667e 586 if obj.date_fin is not None and obj.date_fin < datetime.date.now():
954ead19 587 return u"s/o"
53ae644d
OL
588 employes = obj.occupe_par()
589 if employes:
590 l = []
591 for e in employes:
b10920ea
JPC
592 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>" % \
593 (reverse('employe_apercu', args=(e.id,)),
822a2c33 594 settings.STATIC_URL,
b10920ea
JPC
595 reverse('admin:rh_employe_change', args=(e.id,)),
596 e
597 )
53ae644d
OL
598 l.append(link)
599 output = "\n<br />".join(l)
600 return output
601 _occupe_par.allow_tags = True
602 _occupe_par.short_description = "Occupé par"
603
604 def save_formset(self, request, form, formset, change):
605 instances = formset.save(commit=False)
606 for instance in instances:
607 if instance.__class__ == rh.PosteCommentaire:
608 instance.owner = request.user
02e69aa2 609 instance.date_creation = datetime.datetime.now()
53ae644d
OL
610 instance.save()
611 formset.save_m2m()
612
613
614class PosteCommentaireAdmin(admin.ModelAdmin):
615 pass
616
617
618class PosteFinancementAdmin(admin.ModelAdmin):
619 pass
620
621
622class PostePieceAdmin(admin.ModelAdmin):
623 fk_name = 'poste'
624
625
626class RemunerationAdmin(admin.ModelAdmin):
627 pass
628
629
630class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
631 fieldsets = AUFMetadataAdminMixin.fieldsets + (
632 (None, {
633 'fields': ('employe', 'implantation', ),
634 }),
635 )
636
637
638class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 639 list_display = ('nom', 'date_modification', 'user_modification', )
53ae644d
OL
640 fieldsets = AUFMetadataAdminMixin.fieldsets + (
641 (None, {
642 'fields': ('nom', ),
643 }),
644 )
645
646class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 647 list_display = ('code', 'nom', 'date_modification', 'user_modification', )
53ae644d
OL
648 fieldsets = AUFMetadataAdminMixin.fieldsets + (
649 (None, {
650 'fields': ('code', 'nom', ),
651 }),
652 )
653
654class TauxChangeAdmin(admin.ModelAdmin):
c5964dc2 655 list_display = ('taux', 'devise', 'annee', 'date_modification', 'user_modification', )
53ae644d
OL
656 list_filter = ('devise', )
657 fieldsets = AUFMetadataAdminMixin.fieldsets + (
658 (None, {
659 'fields': ('taux', 'devise', 'annee', ),
660 }),
661 )
662
663class TypeContratAdmin(admin.ModelAdmin):
f614ca5c 664 list_display = ('nom', 'nom_long', 'date_modification', 'user_modification', )
53ae644d
OL
665 fieldsets = AUFMetadataAdminMixin.fieldsets + (
666 (None, {
667 'fields': ('nom', 'nom_long', ),
668 }),
669 )
670
671
672class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
673 search_fields = ('nom', 'nom_feminin', )
f614ca5c 674 list_display = ('nom', 'famille_emploi', 'date_modification', 'user_modification', )
53ae644d
OL
675 list_filter = ('famille_emploi', )
676 fieldsets = AUFMetadataAdminMixin.fieldsets + (
677 (None, {
678 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
679 }),
680 )
681
682
683class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 684 list_display = ('nom', 'type_paiement', 'nature_remuneration', 'date_modification', 'user_modification', )
53ae644d
OL
685 fieldsets = AUFMetadataAdminMixin.fieldsets + (
686 (None, {
687 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
688 }),
689 )
690
691
692class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
f614ca5c 693 list_display = ('nom', 'date_modification', 'user_modification', )
53ae644d
OL
694 fieldsets = AUFMetadataAdminMixin.fieldsets + (
695 (None, {
696 'fields': ('nom', )
697 }),
698 )
699
700
701class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
702 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', 'date_modification', 'user_modification', )
703 list_filter = ('annee', 'devise', )
53ae644d
OL
704 fieldsets = AUFMetadataAdminMixin.fieldsets + (
705 (None, {
706 'fields': ('valeur', 'devise', 'implantation', 'annee', )
707 }),
708 )
709
710 def _devise_code(self, obj):
711 return obj.devise.code
712 _devise_code.short_description = "Code de la devise"
713
714 def _devise_nom(self, obj):
715 return obj.devise.nom
716 _devise_nom.short_description = "Nom de la devise"
717
718
719admin.site.register(rh.Classement, ClassementAdmin)
720admin.site.register(rh.Devise, DeviseAdmin)
721admin.site.register(rh.Dossier, DossierAdmin)
722admin.site.register(rh.Employe, EmployeAdmin)
723admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
724admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
725admin.site.register(rh.Poste, PosteAdmin)
726admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
727admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 728admin.site.register(rh.Statut, StatutAdmin)
53ae644d 729admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 730admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
731admin.site.register(rh.TypePoste, TypePosteAdmin)
732admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
733admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
734admin.site.register(rh.ValeurPoint, ValeurPointAdmin)