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