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
OL
52 user_groups = request.user.groups.all()
53 if len(user_groups) == 0:
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
165class 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
202class AyantDroitCommentaireAdmin(admin.ModelAdmin):
203 pass
204
205
206class ClassementAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 207 list_display = ('_classement', 'date_modification', 'user_modification', )
53ae644d
OL
208 fieldsets = AUFMetadataAdminMixin.fieldsets + (
209 (None, {
210 'fields': ('type', 'echelon', 'degre', 'coefficient', )
211 }),
212 )
213
c5964dc2
OL
214 def _classement(self, obj):
215 return unicode(obj)
216 _classement.short_description = u"Classement"
53ae644d
OL
217
218class CommentaireAdmin(admin.ModelAdmin):
219 pass
220
221
53ae644d 222class DeviseAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 223 list_display = ('code', 'nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
224 fieldsets = AUFMetadataAdminMixin.fieldsets + (
225 (None, {
226 'fields': ('code', 'nom', ),
227 }),
228 )
229
230
231class 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',
c5964dc2 241 'user_modification',
53ae644d
OL
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,
53ae644d
OL
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
5429c435
OL
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>""" % \
b10920ea 291 (reverse('dossier_apercu', args=(d.id,)),
822a2c33 292 settings.STATIC_URL,
b10920ea 293 )
5429c435
OL
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,)),
53ae644d 297 d.id,
53ae644d
OL
298 )
299 return link
300 _id.allow_tags = True
5429c435 301 _id.short_description = u"Dossier__#"
53ae644d
OL
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):
5f36f262
OL
316 return date(obj.date_debut)
317
53ae644d
OL
318 _date_debut.short_description = u'Occupation début'
319 _date_debut.admin_order_field = 'date_debut'
320
321 def _date_fin(self, obj):
5f36f262 322 return date(obj.date_fin)
53ae644d
OL
323 _date_fin.short_description = u'Occupation fin'
324 _date_fin.admin_order_field = 'date_fin'
325
326 def _poste(self, dossier):
211a0e56 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>""" % \
53ae644d 328 (reverse('poste_apercu', args=(dossier.poste.id,)),
822a2c33 329 settings.STATIC_URL,
211a0e56
JPC
330 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
331 dossier.poste,
53ae644d
OL
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";
211a0e56 345 view = ""
53ae644d
OL
346 else:
347 style = ""
822a2c33 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,)
211a0e56
JPC
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())
53ae644d
OL
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
02e69aa2 360 instance.date_creation = datetime.datetime.now()
53ae644d
OL
361 instance.save()
362
363
364class DossierPieceAdmin(admin.ModelAdmin):
365 pass
366
367
368class DossierCommentaireAdmin(admin.ModelAdmin):
369 pass
370
371
372class 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
b10920ea 378 list_display = ('_apercu', '_nom', '_dossiers', 'date_modification', 'user_modification', 'actif',)
a45e414b 379 list_filter = ('rh_dossiers__poste__implantation__region', 'rh_dossiers__poste__implantation', 'nb_postes', 'actif', )
53ae644d
OL
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
b10920ea
JPC
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>""" % \
822a2c33 398 (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL)
b10920ea
JPC
399 _apercu.allow_tags = True
400 _apercu.short_description = u""
401 _apercu.admin_order_field = ""
402
53ae644d 403 def _nom(self, obj):
53ae644d 404 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
b10920ea
JPC
405 return u"""<a href='%s'><strong>[%s] %s %s</strong></a>""" % \
406 (edit_link, obj.id, obj.nom.upper(), obj.prenom.title(),)
53ae644d
OL
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'):
b10920ea 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>""" % \
822a2c33 415 (reverse('dossier_apercu', args=(d.id,)), settings.STATIC_URL,)
b5cc0357 416 link = u"""<li>%s<a href='%s'>%s : %s</a></li>""" % \
b10920ea 417 (apercu,
b10920ea 418 reverse('admin:rh_dossier_change', args=(d.id,)),
53ae644d
OL
419 d.date_debut.year,
420 d.poste,
53ae644d 421 )
b5cc0357
OL
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
53ae644d
OL
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
02e69aa2 444 instance.date_creation = datetime.datetime.now()
53ae644d
OL
445 instance.save()
446
447
448
449class EmployeCommentaireAdmin(admin.ModelAdmin):
450 pass
451
452
453class EmployePieceAdmin(admin.ModelAdmin):
454 pass
455
456
457class FamilleEmploiAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 458 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
459 inlines = (TypePosteInline,)
460 fieldsets = AUFMetadataAdminMixin.fieldsets + (
461 (None, {
462 'fields': ('nom', )
463 }),
464 )
465
466
95b630cf 467class OrganismeBstgAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
468 search_fields = ('nom',)
469 list_display = ('nom', 'type', 'pays', 'date_modification', 'user_modification', 'actif', )
470 list_filter = ('type', )
53ae644d
OL
471 inlines = (DossierROInline,)
472 fieldsets = AUFMetadataAdminMixin.fieldsets + (
473 (None, {
474 'fields': ('nom', 'type', 'pays', )
475 }),
476 )
477
478
479class 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 = (
8f3ca727 495 '_apercu',
53ae644d
OL
496 '_nom',
497 '_occupe_par',
498 'implantation',
c5964dc2 499 '_service',
53ae644d
OL
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',
4c53dda4 511 'vacant',
53ae644d
OL
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 }),
48a6df80 541 ('Autres Méta-données', {
53ae644d
OL
542 'fields': ('date_debut', 'date_fin')
543 }),
544 )
545
546 inlines = (PosteFinancementInline,
547 PostePieceInline,
548 DossierROInline,
6f037929 549 PosteComparaisonInline,
53ae644d
OL
550 PosteCommentaireInline, )
551
c5964dc2 552
8f3ca727 553 def _apercu(self, poste):
5c9d5e55 554 link = u"""<a onclick="return showAddAnotherPopup(this);" title="Aperçu du poste" href='%s'><img src="%simg/loupe.png" /> %s</a>""" % \
8f3ca727 555 (reverse('poste_apercu', args=(poste.id,)),
822a2c33 556 settings.STATIC_URL,
5c9d5e55 557 poste.id,
8f3ca727
JPC
558 )
559 return link
560 _apercu.allow_tags = True
5c9d5e55
OL
561 _apercu.short_description = 'Poste __#'
562 _apercu.admin_order_field = 'id'
8f3ca727 563
c5964dc2
OL
564 def _service(self, obj):
565 return obj.service
53ae644d
OL
566
567 def _nom(self, poste):
b10920ea 568 link = u"""<a href="%s" title="Modifier le poste"><strong>%s</strong></a>""" % \
8f3ca727 569 (reverse('admin:rh_poste_change', args=(poste.id,)),
53ae644d 570 poste.nom,
53ae644d
OL
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"""
15c5f55a 579 output = u"Vacant"
bdc6d9ff 580 if obj.actif is False:
954ead19 581 return u"s/o"
53ae644d
OL
582 employes = obj.occupe_par()
583 if employes:
584 l = []
585 for e in employes:
b10920ea
JPC
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,)),
822a2c33 588 settings.STATIC_URL,
b10920ea
JPC
589 reverse('admin:rh_employe_change', args=(e.id,)),
590 e
591 )
53ae644d
OL
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
02e69aa2 603 instance.date_creation = datetime.datetime.now()
53ae644d
OL
604 instance.save()
605 formset.save_m2m()
606
607
608class PosteCommentaireAdmin(admin.ModelAdmin):
609 pass
610
611
612class PosteFinancementAdmin(admin.ModelAdmin):
613 pass
614
615
616class PostePieceAdmin(admin.ModelAdmin):
617 fk_name = 'poste'
618
619
620class RemunerationAdmin(admin.ModelAdmin):
621 pass
622
623
624class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
625 fieldsets = AUFMetadataAdminMixin.fieldsets + (
626 (None, {
627 'fields': ('employe', 'implantation', ),
628 }),
629 )
630
631
632class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 633 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
634 fieldsets = AUFMetadataAdminMixin.fieldsets + (
635 (None, {
636 'fields': ('nom', ),
637 }),
638 )
639
640class StatutAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 641 list_display = ('code', 'nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
642 fieldsets = AUFMetadataAdminMixin.fieldsets + (
643 (None, {
644 'fields': ('code', 'nom', ),
645 }),
646 )
647
648class TauxChangeAdmin(admin.ModelAdmin):
c5964dc2 649 list_display = ('taux', 'devise', 'annee', 'date_modification', 'user_modification', )
53ae644d
OL
650 list_filter = ('devise', )
651 fieldsets = AUFMetadataAdminMixin.fieldsets + (
652 (None, {
653 'fields': ('taux', 'devise', 'annee', ),
654 }),
655 )
656
657class TypeContratAdmin(admin.ModelAdmin):
c5964dc2 658 list_display = ('nom', 'nom_long', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
659 fieldsets = AUFMetadataAdminMixin.fieldsets + (
660 (None, {
661 'fields': ('nom', 'nom_long', ),
662 }),
663 )
664
665
666class TypePosteAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
667 search_fields = ('nom', 'nom_feminin', )
c5964dc2 668 list_display = ('nom', 'famille_emploi', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
669 list_filter = ('famille_emploi', )
670 fieldsets = AUFMetadataAdminMixin.fieldsets + (
671 (None, {
672 'fields': ('nom', 'nom_feminin', 'is_responsable', 'famille_emploi', )
673 }),
674 )
675
676
677class TypeRemunerationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 678 list_display = ('nom', 'type_paiement', 'nature_remuneration', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
679 fieldsets = AUFMetadataAdminMixin.fieldsets + (
680 (None, {
681 'fields': ('nom', 'type_paiement', 'nature_remuneration', )
682 }),
683 )
684
685
686class TypeRevalorisationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2 687 list_display = ('nom', 'date_modification', 'user_modification', 'actif', )
53ae644d
OL
688 fieldsets = AUFMetadataAdminMixin.fieldsets + (
689 (None, {
690 'fields': ('nom', )
691 }),
692 )
693
694
695class ValeurPointAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
c5964dc2
OL
696 list_display = ('_devise_code', '_devise_nom', 'annee', 'valeur', 'date_modification', 'user_modification', )
697 list_filter = ('annee', 'devise', )
53ae644d
OL
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
713admin.site.register(rh.Classement, ClassementAdmin)
714admin.site.register(rh.Devise, DeviseAdmin)
715admin.site.register(rh.Dossier, DossierAdmin)
716admin.site.register(rh.Employe, EmployeAdmin)
717admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
718admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
719admin.site.register(rh.Poste, PosteAdmin)
720admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
721admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 722admin.site.register(rh.Statut, StatutAdmin)
53ae644d 723admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 724admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
725admin.site.register(rh.TypePoste, TypePosteAdmin)
726admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
727admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
728admin.site.register(rh.ValeurPoint, ValeurPointAdmin)