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