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