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