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