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