Merge branch 'dev' of ssh://git.auf/auf_rh_dae into dev
[auf_rh_dae.git] / project / rh / admin.py
CommitLineData
53ae644d
OL
1# -*- encoding: utf-8 -*-
2
53ae644d
OL
3import datetime
4
fc4bf968
EMS
5from ajax_select import make_ajax_form
6from auf.django.metadata.admin import \
7 AUFMetadataAdminMixin, AUFMetadataInlineAdminMixin, \
8 AUF_METADATA_READONLY_FIELDS
53ae644d 9from django.core.urlresolvers import reverse
50fa9bc1 10from django.contrib import admin
53ae644d 11from django.conf import settings
f7badf51 12from django.db.models import Q, Count
5f36f262 13from django.template.defaultfilters import date
fc4bf968
EMS
14
15import auf.django.references.models as ref
16import models as rh
17from forms import \
18 ContratForm, AyantDroitForm, EmployeAdminForm, AjaxSelect, DossierForm
53ae644d 19from dae.utils import get_employe_from_user
a17e2236 20from change_list import ChangeList
a12ddd52
OL
21from groups import grp_correspondants_rh
22from decorators import in_drh_or_admin
fc4bf968 23
82af5c19 24
08a9b6fc
EMS
25class BaseAdmin(admin.ModelAdmin):
26
27 class Media:
28 css = {'screen': ('css/admin_custom.css',)}
29
30
7ba822a6
OL
31class ArchiveMixin(object):
32 """
33 Archive Mixin pour gérer le queryset et le display
34 NON COMPRIS : list_filter, et list_display, field à setter dans la classe.
35 """
36
37 def queryset(self, request):
38 return self.model._base_manager
39
40 def _archive(self, obj):
41 if obj.archive:
42 return "oui"
43 else:
44 return "non"
45 _archive.short_description = u'Archivé'
46 _archive.admin_order_field = 'archive'
47
fc4bf968 48
9da4c195
JPC
49class RegionProxy(ref.Region):
50 """ Proxy utilisé pour les organigrammes par région """
51 class Meta:
52 proxy = True
53 verbose_name = u"Organigramme par région"
54 verbose_name_plural = u"Organigramme par région"
55
56
82af5c19
JPC
57class ImplantationProxy(ref.Implantation):
58 """ Proxy utilisé pour les organigrammes par implantation """
59 class Meta:
60 proxy = True
61 verbose_name = u"Organigramme par implantations"
62 verbose_name_plural = u"Organigramme par implantations"
63
22343fe7 64
5c0f1778
JPC
65class ServiceProxy(rh.Service):
66 """ Proxy utilisé pour les organigrammes opar service """
f7badf51 67
5c0f1778
JPC
68 class Meta:
69 proxy = True
70 verbose_name = u"Organigramme par services"
71 verbose_name_plural = u"Organigramme par services"
72
22343fe7 73
5c0f1778
JPC
74class EmployeProxy(rh.Employe):
75 """ Proxy utilisé pour les organigrammes des employés """
22343fe7
OL
76 class Meta:
77 proxy = True
78 verbose_name = u"Organigramme des employés"
79 verbose_name_plural = u"Organigramme des employés"
80
f614ca5c 81
40b35603 82class DateRangeMixin(object):
a17e2236 83 prefixe_recherche_temporelle = ""
22343fe7 84
40b35603 85 def get_changelist(self, request, **kwargs):
22343fe7 86 if 'HTTP_REFERER' in request.META.keys():
910e39e5
OL
87 referer = request.META['HTTP_REFERER']
88 referer = "/".join(referer.split('/')[3:])
89 referer = "/%s" % referer.split('?')[0]
22343fe7
OL
90 change_list_view = 'admin:%s_%s_changelist' % (
91 self.model._meta.app_label,
92 self.model.__name__.lower(),)
910e39e5
OL
93 if referer != reverse(change_list_view):
94 params = request.GET.copy()
22343fe7 95 params.update({'statut': 'Actif'})
910e39e5 96 request.GET = params
40b35603 97 return ChangeList
3195667e 98
22343fe7 99
53ae644d
OL
100# Override of the InlineModelAdmin to support the link in the tabular inline
101class LinkedInline(admin.options.InlineModelAdmin):
102 template = "admin/linked.html"
103 admin_model_path = None
104
105 def __init__(self, *args):
106 super(LinkedInline, self).__init__(*args)
107 if self.admin_model_path is None:
108 self.admin_model_path = self.model.__name__.lower()
109
110
111class ProtectRegionMixin(object):
112
113 def queryset(self, request):
53ae644d
OL
114 qs = super(ProtectRegionMixin, self).queryset(request)
115
53ae644d 116 user_groups = request.user.groups.all()
a12ddd52 117 if in_drh_or_admin(request.user):
53ae644d
OL
118 return qs
119
120 if grp_correspondants_rh in user_groups:
121 employe = get_employe_from_user(request.user)
22343fe7
OL
122 q = Q(**{self.model.prefix_implantation: \
123 employe.implantation.region})
53ae644d
OL
124 qs = qs.filter(q).distinct()
125 return qs
126 return qs.none()
127
c0be8705
OL
128 def has_add_permission(self, request):
129 if not in_drh_or_admin(request.user):
130 return False
131 else:
132 return True
133
53ae644d 134 def has_change_permission(self, request, obj=None):
20b4867c 135 user_groups = request.user.groups.all()
a0d365ed 136
0309aeb4
DB
137 # Lock pour autoriser uniquement les DRH à utiliser RH
138 if not in_drh_or_admin(request.user):
139 return False
140
a18bc295 141 if len(user_groups) == 0 and not request.user.is_superuser:
20b4867c
OL
142 return False
143
53ae644d
OL
144 if obj is None:
145 return True
146 ids = [o.id for o in self.queryset(request)]
147 return obj.id in ids
148
149
150# Inlines
151
152class ReadOnlyInlineMixin(object):
22343fe7 153
53ae644d 154 def get_readonly_fields(self, request, obj=None):
22343fe7
OL
155 return [f.name for f in self.model._meta.fields \
156 if f.name not in AUF_METADATA_READONLY_FIELDS]
53ae644d
OL
157
158
159class AyantDroitInline(AUFMetadataInlineAdminMixin, admin.StackedInline):
160 model = rh.AyantDroit
161 form = AyantDroitForm
162 extra = 0
163
164 fieldsets = (
165 (None, {
22343fe7
OL
166 'fields': (
167 ('nom', 'prenom'),
168 ('nom_affichage', 'genre'),
169 'nationalite',
170 'date_naissance',
171 'lien_parente',
172 )}),
53ae644d
OL
173 )
174
175
22343fe7
OL
176class AyantDroitCommentaireInline(AUFMetadataInlineAdminMixin, \
177 admin.TabularInline):
53ae644d
OL
178 readonly_fields = ('owner', )
179 model = rh.AyantDroitCommentaire
180 extra = 1
181
182
183class ContratInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
184 form = ContratForm
185 model = rh.Contrat
186 extra = 1
187
188
189class DossierROInline(ReadOnlyInlineMixin, LinkedInline):
190 template = "admin/rh/dossier/linked.html"
191 exclude = AUF_METADATA_READONLY_FIELDS
192 model = rh.Dossier
193 extra = 0
194 can_delete = False
195
196 def has_add_permission(self, request=None):
197 return False
198
199 def has_change_permission(self, request, obj=None):
200 return False
201
202 def has_delete_permission(self, request, obj=None):
203 return False
204
205
22343fe7
OL
206class DossierCommentaireInline(AUFMetadataInlineAdminMixin, \
207 admin.TabularInline):
53ae644d
OL
208 readonly_fields = ('owner', )
209 model = rh.DossierCommentaire
210 extra = 1
211
212
213class DossierPieceInline(admin.TabularInline):
214 model = rh.DossierPiece
215 extra = 4
216
217
218class EmployeInline(admin.TabularInline):
219 model = rh.Employe
220
22343fe7
OL
221
222class EmployeCommentaireInline(AUFMetadataInlineAdminMixin, \
223 admin.TabularInline):
53ae644d
OL
224 readonly_fields = ('owner', )
225 model = rh.EmployeCommentaire
226 extra = 1
227
228
229class EmployePieceInline(admin.TabularInline):
230 model = rh.EmployePiece
231 extra = 4
232
233
53ae644d
OL
234class PosteCommentaireInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
235 readonly_fields = ('owner', )
236 model = rh.PosteCommentaire
237 extra = 1
238
239
240class PosteFinancementInline(admin.TabularInline):
241 model = rh.PosteFinancement
242
243
244class PostePieceInline(admin.TabularInline):
245 model = rh.PostePiece
246
247
248class RemunerationInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
249 model = rh.Remuneration
250 extra = 1
251
252
253class RemunerationROInline(ReadOnlyInlineMixin, RemunerationInline):
254 pass
255
256
257class TypePosteInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
258 model = rh.TypePoste
259
260
6f037929
OL
261class PosteComparaisonInline(AUFMetadataInlineAdminMixin, admin.TabularInline):
262 model = rh.PosteComparaison
263
53ae644d 264
08a9b6fc 265class ClassementAdmin(AUFMetadataAdminMixin, BaseAdmin):
33232787 266 list_display = ('_classement', '_date_modification', 'user_modification', )
53ae644d
OL
267 fieldsets = AUFMetadataAdminMixin.fieldsets + (
268 (None, {
22343fe7 269 'fields': ('type', 'echelon', 'degre', 'coefficient',)}),
53ae644d
OL
270 )
271
c5964dc2
OL
272 def _classement(self, obj):
273 return unicode(obj)
274 _classement.short_description = u"Classement"
53ae644d 275
33232787 276 def _date_modification(self, obj):
22343fe7
OL
277 return date(obj.date_modification) \
278 if obj.date_modification is not None else "(aucune)"
33232787
JPC
279 _date_modification.short_description = u'date modification'
280 _date_modification.admin_order_field = 'date_modification'
281
22343fe7 282
08a9b6fc 283class DeviseAdmin(AUFMetadataAdminMixin, BaseAdmin, ArchiveMixin):
22343fe7
OL
284 list_display = (
285 'code',
286 'nom',
287 '_archive',
288 '_date_modification',
289 'user_modification',
290 )
edb35076 291 list_filter = ('archive', )
53ae644d
OL
292 fieldsets = AUFMetadataAdminMixin.fieldsets + (
293 (None, {
edb35076 294 'fields': ('code', 'nom', 'archive', ),
53ae644d
OL
295 }),
296 )
297
33232787 298 def _date_modification(self, obj):
22343fe7
OL
299 return date(obj.date_modification) \
300 if obj.date_modification is not None else "(aucune)"
33232787
JPC
301 _date_modification.short_description = u'date modification'
302 _date_modification.admin_order_field = 'date_modification'
53ae644d 303
22343fe7 304
08a9b6fc
EMS
305class DossierAdmin(DateRangeMixin, AUFMetadataAdminMixin,
306 ProtectRegionMixin, BaseAdmin, AjaxSelect):
53ae644d 307 alphabet_filter = 'employe__nom'
22343fe7 308 search_fields = (
35cff4a7
EMS
309 'id',
310 'employe__id',
311 'poste__id',
312 'employe__nom',
313 'employe__prenom',
314 'poste__nom',
315 'poste__nom_feminin',
316 'poste__implantation__nom',
317 )
53ae644d
OL
318 list_display = (
319 '_id',
e49ac947
JPC
320 '_apercu',
321 '_nom',
53ae644d
OL
322 '_poste',
323 '_employe',
324 '_date_debut',
325 '_date_fin',
33232787 326 '_date_modification',
c5964dc2 327 'user_modification',
a47ed016 328 '_dae',
53ae644d 329 )
e49ac947 330 list_display_links = ('_nom',)
53ae644d
OL
331 list_filter = (
332 'poste__implantation__region',
333 'poste__implantation',
7bf28694 334 'poste__type_poste__categorie_emploi',
7baa5523 335 'poste__type_poste',
53ae644d 336 'rh_contrats__type_contrat',
6bee05ff 337 'principal',
53ae644d
OL
338 )
339 inlines = (DossierPieceInline, ContratInline,
340 RemunerationInline,
53ae644d
OL
341 DossierCommentaireInline,
342 )
343 fieldsets = AUFMetadataAdminMixin.fieldsets + (
344 (None, {
22343fe7
OL
345 'fields': (
346 'employe',
347 'poste',
6bee05ff 348 'principal',
22343fe7
OL
349 'statut',
350 'organisme_bstg',)}),
53ae644d 351 ('Recrutement', {
22343fe7
OL
352 'fields': (
353 'statut_residence',
354 'remplacement',
355 'remplacement_de', )}),
53ae644d 356 ('Rémunération', {
22343fe7
OL
357 'fields': (
358 'classement',
359 ('regime_travail', 'regime_travail_nb_heure_semaine'),)}),
53ae644d 360 ('Occupation du Poste par cet Employe', {
22343fe7
OL
361 'fields': (('date_debut', 'date_fin'), )}
362 ),
53ae644d 363 )
22343fe7
OL
364 form = make_ajax_form(rh.Dossier, {
365 'employe': 'employes',
366 'poste': 'postes',
367 'remplacement_de': 'dossiers',
6bee05ff 368 }, superclass=DossierForm)
53ae644d
OL
369
370 def lookup_allowed(self, key, value):
371 if key in (
372 'employe__nom__istartswith',
53ae644d
OL
373 'poste__implantation__region__id__exact',
374 'poste__implantation__id__exact',
375 'poste__type_poste__id__exact',
7bf28694 376 'poste__type_poste__categorie_emploi__id__exact',
53ae644d 377 'rh_contrats__type_contrat__id__exact',
6bee05ff
OL
378 'principal__exact',
379 'principal__isnull',
53ae644d
OL
380 ):
381 return True
382
e49ac947
JPC
383 def _id(self, obj):
384 return obj.id
385 _id.short_description = u"#"
386 _id.admin_order_field = "id"
387
388 def _nom(self, obj):
22343fe7
OL
389 return "%d : %s %s" % (
390 obj.date_debut.year,
391 obj.employe.nom.upper(),
392 obj.employe.prenom)
e49ac947
JPC
393 _nom.allow_tags = True
394 _nom.short_description = u"Dossier"
395
e49ac947 396 def _apercu(self, d):
22343fe7
OL
397 apercu_link = u"""<a title="Aperçu du dossier"
398 onclick="return showAddAnotherPopup(this);"
399 href='%s'>
400 <img src="%simg/loupe.png" />
401 </a>""" % \
b10920ea 402 (reverse('dossier_apercu', args=(d.id,)),
822a2c33 403 settings.STATIC_URL,
b10920ea 404 )
e49ac947
JPC
405 return apercu_link
406 _apercu.allow_tags = True
407 _apercu.short_description = u""
53ae644d 408
a47ed016
OL
409 def _dae(self, d):
410 apercu_link = ""
de151a1e
EMS
411 dossiers_dae = d.dossiers_dae.all()
412 if len(dossiers_dae) > 0:
413 dossier_dae = dossiers_dae[0]
a47ed016
OL
414 apercu_link = u"""<a title="Aperçu du dossier"
415 onclick="return showAddAnotherPopup(this);"
416 href='%s'>
417 <img src="%simg/loupe.png" />
418 </a>""" % \
de151a1e 419 (reverse('embauche_consulter', args=(dossier_dae.id,)),
a47ed016
OL
420 settings.STATIC_URL,
421 )
422 return apercu_link
423 _dae.allow_tags = True
424 _dae.short_description = u"DAE"
425
53ae644d 426 def _date_debut(self, obj):
5f36f262
OL
427 return date(obj.date_debut)
428
53ae644d
OL
429 _date_debut.short_description = u'Occupation début'
430 _date_debut.admin_order_field = 'date_debut'
431
432 def _date_fin(self, obj):
5f36f262 433 return date(obj.date_fin)
53ae644d
OL
434 _date_fin.short_description = u'Occupation fin'
435 _date_fin.admin_order_field = 'date_fin'
436
33232787 437 def _date_modification(self, obj):
22343fe7
OL
438 return date(obj.date_modification) \
439 if obj.date_modification is not None else "(aucune)"
33232787
JPC
440 _date_modification.short_description = u'date modification'
441 _date_modification.admin_order_field = 'date_modification'
442
53ae644d 443 def _poste(self, dossier):
22343fe7
OL
444 link = u"""<a title="Aperçu du poste"
445 onclick="return showAddAnotherPopup(this);"
446 href='%s'><img src="%simg/loupe.png" />
447 </a>
448 <a href="%s" title="Modifier le poste">%s</a>""" % \
53ae644d 449 (reverse('poste_apercu', args=(dossier.poste.id,)),
822a2c33 450 settings.STATIC_URL,
211a0e56
JPC
451 reverse('admin:rh_poste_change', args=(dossier.poste.id,)),
452 dossier.poste,
53ae644d
OL
453 )
454 return link
455 _poste.allow_tags = True
456 _poste.short_description = u'Poste'
457 _poste.admin_order_field = 'poste__nom'
458
459 def _employe(self, obj):
460 employe = obj.employe
461 view_link = reverse('employe_apercu', args=(employe.id,))
462 edit_link = reverse('admin:rh_employe_change', args=(employe.id,))
463
f614ca5c 464 style = ""
22343fe7
OL
465 view = u"""<a href="%s"
466 title="Aperçu l'employé"
467 onclick="return showAddAnotherPopup(this);">
468 <img src="%simg/loupe.png" />
469 </a>""" % (view_link, settings.STATIC_URL,)
e6c107de
JPC
470 return u"""%s<a href='%s' style="%s;">%s</a>""" % \
471 (view, edit_link, style, employe)
53ae644d 472 _employe.allow_tags = True
e49ac947 473 _employe.short_description = u"Employé"
53ae644d 474 _employe.admin_order_field = "employe__nom"
22343fe7 475
53ae644d
OL
476 def save_formset(self, request, form, formset, change):
477 instances = formset.save(commit=False)
478 for instance in instances:
479 if instance.__class__ == rh.DossierCommentaire:
480 instance.owner = request.user
02e69aa2 481 instance.date_creation = datetime.datetime.now()
53ae644d
OL
482 instance.save()
483
484
08a9b6fc
EMS
485class EmployeAdmin(DateRangeMixin, AUFMetadataAdminMixin,
486 ProtectRegionMixin, BaseAdmin):
7eb6b687 487 prefixe_recherche_temporelle = "rh_dossiers__"
53ae644d
OL
488 alphabet_filter = 'nom'
489 DEFAULT_ALPHABET = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
e23da9c3
EMS
490 search_fields = (
491 'id', 'nom', 'prenom', 'nom_affichage',
492 'rh_dossiers__poste__nom',
493 'rh_dossiers__poste__nom_feminin'
494 )
53ae644d
OL
495 ordering = ('nom', )
496 form = EmployeAdminForm
22343fe7
OL
497 list_display = (
498 '_id',
499 '_apercu',
500 '_nom',
501 '_dossiers_postes',
5aface22 502 'date_entree',
22343fe7
OL
503 '_date_modification',
504 'user_modification',
505 )
e49ac947 506 list_display_links = ('_nom',)
22343fe7
OL
507 list_filter = (
508 'rh_dossiers__poste__implantation__region',
509 'rh_dossiers__poste__implantation',
510 'nb_postes',
511 )
53ae644d
OL
512 inlines = (AyantDroitInline,
513 DossierROInline,
514 EmployePieceInline,
515 EmployeCommentaireInline)
516 fieldsets = AUFMetadataAdminMixin.fieldsets + (
517 ('Identification', {
22343fe7
OL
518 'fields': (
519 ('nom', 'prenom'),
520 ('nom_affichage', 'genre'),
521 'nationalite',
522 'date_naissance',
523 )}
524 ),
53ae644d 525 ('Informations personnelles', {
22343fe7
OL
526 'fields': ('situation_famille', 'date_entree', )}
527 ),
89a8df07 528 ('Coordonnées personnelles', {
22343fe7
OL
529 'fields': (
530 ('tel_domicile', 'tel_cellulaire'),
531 ('adresse', 'ville'),
532 ('code_postal', 'province'),
533 'pays',
89a8df07 534 'courriel_perso'
22343fe7
OL
535 )}
536 ),
53ae644d
OL
537 )
538
b10920ea 539 def _apercu(self, obj):
22343fe7
OL
540 return u"""<a title="Aperçu de l'employé"
541 onclick="return showAddAnotherPopup(this);"
542 href='%s'>
543 <img src="%simg/loupe.png" />
544 </a>""" % \
545 (reverse('employe_apercu', args=(obj.id,)), settings.STATIC_URL)
b10920ea
JPC
546 _apercu.allow_tags = True
547 _apercu.short_description = u""
b10920ea 548
53ae644d 549 def _nom(self, obj):
53ae644d 550 edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
e6c107de 551 return u"""<a href='%s'><strong>%s</strong></a>""" % \
e49ac947 552 (edit_link, "%s %s" % (obj.nom.upper(), obj.prenom))
53ae644d 553 _nom.allow_tags = True
e49ac947 554 _nom.short_description = u"Employé"
53ae644d
OL
555 _nom.admin_order_field = "nom"
556
e49ac947
JPC
557 def _id(self, obj):
558 return obj.id
559 _id.short_description = u"#"
560 _id.admin_order_field = "id"
561
33232787 562 def _date_modification(self, obj):
22343fe7
OL
563 return date(obj.date_modification) \
564 if obj.date_modification is not None else "(aucune)"
33232787
JPC
565 _date_modification.short_description = u'date modification'
566 _date_modification.admin_order_field = 'date_modification'
567
a7f013f5 568 def _dossiers_postes(self, obj):
53ae644d
OL
569 l = []
570 for d in obj.rh_dossiers.all().order_by('-date_debut'):
22343fe7
OL
571 dossier = u"""<a title="Aperçu du dossier"
572 href="%s"
573 onclick="return showAddAnotherPopup(this);"
574 title="Aperçu du dossier">
575 <img src="%simg/loupe.png" />
576 </a>
577 <a href="%s">Dossier</a>
578 &nbsp;""" % \
579 (reverse('dossier_apercu', args=(d.id,)),
580 settings.STATIC_URL,
581 reverse('admin:rh_dossier_change', args=(d.id,)))
582
583 poste = u"""<a title="Aperçu du poste"
584 href="%s"
585 onclick="return showAddAnotherPopup(this);"
586 title="Aperçu du poste">
587 <img src="%simg/loupe.png" />
588 </a>
589 <a href="%s">Poste</a>
590 &nbsp;""" % \
591 (reverse('poste_apercu', args=(d.poste.id,)),
592 settings.STATIC_URL,
593 reverse('admin:rh_poste_change', args=(d.poste.id,)))
a7f013f5
JPC
594 link = u"""<li>%s %s - %s : [%s] %s</li>""" % \
595 (dossier, poste,
53ae644d 596 d.date_debut.year,
a7f013f5
JPC
597 d.poste.id,
598 d.poste.nom,
53ae644d 599 )
b5cc0357
OL
600
601 # Dossier terminé en gris non cliquable
a4329fae 602 if d.date_fin is not None and d.date_fin < datetime.date.today():
a7f013f5 603 link = u"""<li style="color: grey">%s : [%s] %s</li>""" % \
b5cc0357 604 (d.date_debut.year,
a7f013f5
JPC
605 d.poste.id,
606 d.poste.nom,
b5cc0357
OL
607 )
608
53ae644d
OL
609 l.append(link)
610 return "<ul>%s</ul>" % "\n".join(l)
a7f013f5
JPC
611 _dossiers_postes.allow_tags = True
612 _dossiers_postes.short_description = u"Dossiers et postes"
53ae644d
OL
613
614 def queryset(self, request):
22343fe7 615 qs = super(EmployeAdmin, self).queryset(request)
53ae644d
OL
616 return qs.select_related(depth=1).order_by('nom')
617
618 def save_formset(self, request, form, formset, change):
619 instances = formset.save(commit=False)
620 for instance in instances:
621 if instance.__class__ == rh.EmployeCommentaire:
622 instance.owner = request.user
02e69aa2 623 instance.date_creation = datetime.datetime.now()
53ae644d
OL
624 instance.save()
625
22343fe7 626
08faf06e 627class EmployeProxyAdmin(EmployeAdmin):
22343fe7 628 list_display = ('_id', '_apercu', '_nom', '_organigramme')
bd917a45
JPC
629 actions = None
630
631 def __init__(self, *args, **kwargs):
632 super(EmployeProxyAdmin, self).__init__(*args, **kwargs)
633 self.list_display_links = (None, )
08faf06e 634
22343fe7
OL
635 def has_add_permission(self, obj):
636 return False
637
08faf06e
JPC
638 def _organigramme(self, obj):
639 l = []
fc4bf968
EMS
640 for d in rh.Dossier.objects.filter(
641 Q(date_fin__gt=datetime.date.today()) | Q(date_fin=None),
642 Q(date_debut__lt=datetime.date.today()) | Q(date_debut=None),
643 employe=obj.id
644 ):
645 organigramme = \
646 u'Organigramme, niveau: ' \
647 u'<input type="text" id="level_%s" ' \
648 u'style="width:30px;height:15px;" /> ' \
649 u'<input type="button" value="Générer" ' \
650 u"""onclick="window.location='%s' + """ \
651 u"""document.getElementById('level_%s').value" />""" % (
652 d.poste.id,
653 reverse('rho_employe_sans_niveau', args=(d.poste.id,)),
654 d.poste.id
655 )
656 link = u"""<li>%s - [%s] %s : %s</li>""" % (
657 d.date_debut.year,
658 d.poste.id,
659 d.poste.nom,
660 organigramme
661 )
08faf06e
JPC
662 l.append(link)
663 return "<ul>%s</ul>" % "\n".join(l)
664
665 _organigramme.allow_tags = True
666 _organigramme.short_description = "Organigramme"
667
53ae644d 668
08a9b6fc 669class CategorieEmploiAdmin(AUFMetadataAdminMixin, BaseAdmin):
33232787 670 list_display = ('nom', '_date_modification', 'user_modification', )
53ae644d 671 inlines = (TypePosteInline,)
22343fe7
OL
672 fieldsets = AUFMetadataAdminMixin.fieldsets + (
673 (None, {'fields': ('nom', )}),)
53ae644d 674
33232787 675 def _date_modification(self, obj):
22343fe7
OL
676 return date(obj.date_modification) \
677 if obj.date_modification is not None else "(aucune)"
33232787
JPC
678 _date_modification.short_description = u'date modification'
679 _date_modification.admin_order_field = 'date_modification'
53ae644d 680
22343fe7 681
08a9b6fc 682class OrganismeBstgAdmin(AUFMetadataAdminMixin, BaseAdmin):
c5964dc2 683 search_fields = ('nom',)
22343fe7
OL
684 list_display = (
685 'nom',
686 'type',
687 'pays',
688 '_date_modification',
689 'user_modification',
690 )
c5964dc2 691 list_filter = ('type', )
53ae644d 692 inlines = (DossierROInline,)
22343fe7
OL
693 fieldsets = AUFMetadataAdminMixin.fieldsets + (
694 (None, {'fields': ('nom', 'type', 'pays',)}),
53ae644d
OL
695 )
696
33232787 697 def _date_modification(self, obj):
22343fe7
OL
698 return date(obj.date_modification) \
699 if obj.date_modification is not None else "(aucune)"
33232787
JPC
700 _date_modification.short_description = u'date modification'
701 _date_modification.admin_order_field = 'date_modification'
702
53ae644d 703
08a9b6fc
EMS
704class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
705 ProtectRegionMixin, BaseAdmin, AjaxSelect):
22343fe7
OL
706 form = make_ajax_form(rh.Poste, {
707 'implantation': 'implantations',
708 'type_poste': 'typepostes',
709 'responsable': 'postes',
710 'valeur_point_min': 'valeurpoints',
711 'valeur_point_max': 'valeurpoints',
53ae644d
OL
712 })
713 alphabet_filter = 'nom'
22343fe7 714 search_fields = (
397bf8dd 715 'id',
22343fe7 716 'nom',
22343fe7
OL
717 'implantation__nom',
718 'implantation__region__code',
719 'implantation__region__nom',
720 'rh_dossiers__employe__nom',
721 'rh_dossiers__employe__prenom',
722 )
53ae644d 723 list_display = (
e49ac947 724 '_id',
8f3ca727 725 '_apercu',
22343fe7 726 '_nom',
53ae644d 727 '_occupe_par',
f3e3ac6f 728 '_implantation',
22343fe7 729 '_service',
1ce2ddb9 730 '_responsable',
352fa696 731 'date_debut',
53ae644d 732 'date_fin',
33232787 733 '_date_modification',
53ae644d 734 'user_modification',
a47ed016 735 '_dae',
53ae644d 736 )
f614ca5c 737 list_filter = (
22343fe7 738 'implantation__region',
53ae644d 739 'implantation',
22343fe7 740 'service',
53ae644d 741 'type_poste',
7bf28694 742 'type_poste__categorie_emploi',
118efe7a 743 'type_poste__famille_professionnelle',
4c53dda4 744 'vacant',
53ae644d 745 )
e49ac947 746 list_display_links = ('_nom',)
53ae644d 747 fieldsets = AUFMetadataAdminMixin.fieldsets + (
22343fe7
OL
748 (None, {'fields': (
749 ('nom', 'nom_feminin'),
750 'implantation',
751 'type_poste',
752 'service',
753 'responsable',
754 )}
755 ),
53ae644d 756 ('Contrat', {
22343fe7
OL
757 'fields': ((
758 'regime_travail',
759 'regime_travail_nb_heure_semaine'),
760 )}
761 ),
53ae644d 762 ('Recrutement', {
22343fe7
OL
763 'fields': (('local', 'expatrie', 'mise_a_disposition', 'appel'),)}
764 ),
53ae644d 765 ('Rémunération', {
22343fe7
OL
766 'fields': (('classement_min',
767 'valeur_point_min',
768 'devise_min',
769 'salaire_min',
770 'indemn_min',
771 'autre_min',),
772 ('classement_max',
773 'valeur_point_max',
774 'devise_max',
775 'salaire_max',
776 'indemn_max',
777 'autre_max',),
778 )}),
53ae644d
OL
779 ('Comparatifs de rémunération', {
780 'fields': ('devise_comparaison',
781 ('comp_locale_min', 'comp_locale_max'),
782 ('comp_universite_min', 'comp_universite_max'),
783 ('comp_fonctionpub_min', 'comp_fonctionpub_max'),
784 ('comp_ong_min', 'comp_ong_max'),
22343fe7
OL
785 ('comp_autre_min', 'comp_autre_max'))}
786 ),
53ae644d 787 ('Justification', {
22343fe7
OL
788 'fields': ('justification',)}
789 ),
48a6df80 790 ('Autres Méta-données', {
22343fe7
OL
791 'fields': ('date_debut', 'date_fin')}
792 ),
53ae644d
OL
793 )
794
795 inlines = (PosteFinancementInline,
796 PostePieceInline,
797 DossierROInline,
6f037929 798 PosteComparaisonInline,
53ae644d
OL
799 PosteCommentaireInline, )
800
f614ca5c 801 def lookup_allowed(self, key, value):
118efe7a
EMS
802 return key in (
803 'date_debut__gte', 'date_debut__isnull', 'date_fin__lte',
804 'date_fin__isnull', 'implantation__region__id__exact',
805 'implantation__id__exact', 'type_poste__id__exact',
806 'type_poste__categorie_emploi__id__exact', 'service__id__exact',
807 'service__isnull', 'vacant__exact', 'vacant__isnull',
808 ) or super(PosteAdmin, self).lookup_allowed(key, value)
f614ca5c 809
8f3ca727 810 def _apercu(self, poste):
22343fe7
OL
811 view_link = u"""<a onclick="return showAddAnotherPopup(this);"
812 title="Aperçu du poste"
813 href='%s'>
814 <img src="%simg/loupe.png" />
815 </a>""" % \
8f3ca727 816 (reverse('poste_apercu', args=(poste.id,)),
22343fe7
OL
817 settings.STATIC_URL,)
818 return view_link
8f3ca727 819 _apercu.allow_tags = True
e49ac947
JPC
820 _apercu.short_description = ''
821
a47ed016
OL
822 def _dae(self, poste):
823 apercu_link = ""
de151a1e
EMS
824 postes_dae = poste.postes_dae.all()
825 if len(postes_dae) > 0:
826 poste_dae = postes_dae[0]
827 apercu_link = \
828 u'<a title="Aperçu du dossier" href="%s" ' \
829 u'onclick="return showAddAnotherPopup(this);">' \
830 u'<img src="%simg/loupe.png" /></a>' % (reverse(
831 'poste_consulter', args=("dae-%s" % poste_dae.id,)
832 ), settings.STATIC_URL)
a47ed016
OL
833 return apercu_link
834 _dae.allow_tags = True
835 _dae.short_description = u"DAE"
836
e49ac947
JPC
837 def _id(self, obj):
838 return "%s" % obj.id
839 _id.short_description = '#'
840 _id.admin_order_field = 'id'
8f3ca727 841
c5964dc2 842 def _service(self, obj):
1b130b25
JPC
843 if obj.service.supprime:
844 return """<span style="color:red">%s</span>""" % obj.service
845 else:
846 return obj.service
6c2b1160 847 _service.short_description = 'Service'
1b130b25 848 _service.allow_tags = True
53ae644d 849
1ce2ddb9
JPC
850 def _responsable(self, obj):
851 try:
22343fe7
OL
852 responsable = u"""<a href="%s"
853 onclick="return showAddAnotherPopup(this)">
854 <img src="%simg/loupe.png"
855 title="Aperçu du poste" />
856 </a>
857 <a href="%s">%s</a>
858 <br />""" % \
859 (reverse('poste_apercu', args=(obj.responsable.id,)),
860 settings.STATIC_URL,
861 reverse('admin:rh_poste_change', args=(obj.responsable.id,)),
862 obj.responsable.nom)
1ce2ddb9
JPC
863 except:
864 responsable = ''
865
866 try:
60f34330
OL
867 dossier = obj.responsable.rh_dossiers.all().order_by('-date_debut')[0]
868 employe_id = dossier.employe.id
fc4bf968 869 employe_html = u"""<br />
22343fe7
OL
870 <a href="%s"
871 onclick="return showAddAnotherPopup(this)">
872 <img src="%simg/loupe.png"
873 title="Aperçu de l'employé">
874 </a>
875 <a href="%s">%s</a>""" % \
876 (reverse('employe_apercu', args=(employe_id,)),
877 settings.STATIC_URL,
878 reverse('admin:rh_employe_change', args=(employe_id,)),
60f34330 879 dossier.employe)
1ce2ddb9 880 except:
fc4bf968 881 employe_html = ""
1ce2ddb9 882
fc4bf968 883 return "%s %s" % (responsable, employe_html)
1ce2ddb9
JPC
884 _responsable.short_description = 'Responsable'
885 _responsable.allow_tags = True
886
f3e3ac6f
EMS
887 def _implantation(self, poste):
888 return poste.implantation.nom
3db01b49
EMS
889 _implantation.short_description = 'Implantation'
890 _implantation.admin_order_field = 'implantation'
f3e3ac6f 891
53ae644d 892 def _nom(self, poste):
e49ac947
JPC
893 return """<a href="%s">%s</a>""" % \
894 (reverse('admin:rh_poste_change', args=(poste.id,)),
22343fe7 895 poste.nom)
53ae644d 896 _nom.allow_tags = True
18978348 897 _nom.short_description = u'Poste'
53ae644d
OL
898 _nom.admin_order_field = 'nom'
899
33232787
JPC
900 def _date_modification(self, obj):
901 return date(obj.date_modification)
902 _date_modification.short_description = u'date modification'
903 _date_modification.admin_order_field = 'date_modification'
904
53ae644d
OL
905 def _occupe_par(self, obj):
906 """Formatte la méthode Poste.occupe_par() pour l'admin"""
15c5f55a 907 output = u"Vacant"
ae5d7df3 908 if obj.date_fin is not None and obj.date_fin < datetime.date.today():
954ead19 909 return u"s/o"
53ae644d
OL
910 employes = obj.occupe_par()
911 if employes:
912 l = []
913 for e in employes:
22343fe7
OL
914 link = u"""<a href='%s'
915 title='Aperçu de l\'employer'
916 onclick='return showAddAnotherPopup(this)'>
917 <img src='%simg/loupe.png' />
918 </a>
919 <a href='%s'>%s</a>""" % \
b10920ea 920 (reverse('employe_apercu', args=(e.id,)),
822a2c33 921 settings.STATIC_URL,
b10920ea 922 reverse('admin:rh_employe_change', args=(e.id,)),
22343fe7 923 e)
53ae644d
OL
924 l.append(link)
925 output = "\n<br />".join(l)
926 return output
927 _occupe_par.allow_tags = True
22343fe7 928 _occupe_par.short_description = "Occupé par"
53ae644d
OL
929
930 def save_formset(self, request, form, formset, change):
931 instances = formset.save(commit=False)
932 for instance in instances:
933 if instance.__class__ == rh.PosteCommentaire:
934 instance.owner = request.user
02e69aa2 935 instance.date_creation = datetime.datetime.now()
53ae644d
OL
936 instance.save()
937 formset.save_m2m()
938
939
8c8ffc4f
OL
940class ResponsableInline(admin.TabularInline):
941 model = rh.ResponsableImplantation
942 extra = 0
fc4bf968
EMS
943 fk_name = "implantation"
944
22343fe7 945
08a9b6fc 946class ResponsableImplantationAdmin(BaseAdmin):
8c8ffc4f
OL
947 actions = None
948 list_filter = ('region', 'statut', )
30dabdc3 949 list_display = ('_region', '_nom', 'statut', '_responsable', )
8c8ffc4f
OL
950 readonly_fields = ('nom', )
951 fields = ('nom', )
952 inlines = (ResponsableInline, )
30dabdc3
DB
953
954 def _region(self, obj):
955 return obj.region.code
956 _region.short_description = u"Région"
957 _region.admin_order_field = 'region__code'
958
959 def _nom(self, obj):
960 return obj.nom
961 _nom.short_description = u"Implantation"
962 _nom.admin_order_field = 'nom'
963
8c8ffc4f
OL
964 def _responsable(self, obj):
965 try:
966 employe = obj.responsable.employe
967 dossiers = employe.dossiers_encours()
968 if len(dossiers) == 0:
969 return u"<span style='color: red;'>%s %s </span>" % (
970 employe, u"sans dossier actif")
971 else:
972 return employe
fc4bf968
EMS
973 except Exception:
974 if obj.statut in (1, 2): # ouverte, ouverture imminente
8c8ffc4f
OL
975 css = "style='color: red;'"
976 else:
977 css = ""
978 return u"<span %s>Pas de responsable</span>" % css
979 _responsable.allow_tags = True
980 _responsable.short_description = u"Responsable"
981
982 def has_add_permission(self, request=None):
983 return False
984
985 def has_change_permission(self, request, obj=None):
986 return in_drh_or_admin(request.user)
987
988 def has_delete_permission(self, request, obj=None):
989 return False
53ae644d 990
fc4bf968 991
08a9b6fc 992class ServiceAdmin(AUFMetadataAdminMixin, BaseAdmin, ArchiveMixin):
22343fe7
OL
993 list_display = (
994 'nom',
995 '_archive',
996 '_date_modification',
997 'user_modification',
998 )
cbb0373e 999 list_filter = ('archive', )
22343fe7 1000 fieldsets = AUFMetadataAdminMixin.fieldsets + (
53ae644d 1001 (None, {
cbb0373e 1002 'fields': ('nom', 'archive', ),
53ae644d
OL
1003 }),
1004 )
1005
33232787 1006 def _date_modification(self, obj):
22343fe7
OL
1007 return date(obj.date_modification) \
1008 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1009 _date_modification.short_description = u'date modification'
1010 _date_modification.admin_order_field = 'date_modification'
1011
fc4bf968 1012
5c0f1778 1013class ServiceProxyAdmin(ServiceAdmin):
cfd5ac68 1014 list_display = ('nom', '_organigramme', '_archive', )
8135fc65
JPC
1015 actions = None
1016
1017 def __init__(self, *args, **kwargs):
1018 super(ServiceProxyAdmin, self).__init__(*args, **kwargs)
1019 self.list_display_links = (None, )
5c0f1778 1020
f7badf51
EMS
1021 def queryset(self, request):
1022 return super(ServiceProxyAdmin, self).queryset(request) \
1023 .annotate(num_postes=Count('rh_postes')) \
1024 .filter(num_postes__gt=0)
1025
5c0f1778
JPC
1026 def has_add_permission(self, obj):
1027 return False
1028
aa2c508e
JPC
1029 def has_change_permission(self, request, obj=None):
1030 return in_drh_or_admin(request.user)
1031
5c0f1778 1032 def _organigramme(self, obj):
8135fc65
JPC
1033 return """<a href="%s"><strong>Organigramme</strong></a>""" % \
1034 (reverse('rho_service', args=(obj.id,)))
5c0f1778
JPC
1035 _organigramme.allow_tags = True
1036 _organigramme.short_description = "Organigramme"
1037
8135fc65 1038
08a9b6fc 1039class StatutAdmin(AUFMetadataAdminMixin, BaseAdmin):
33232787 1040 list_display = ('code', 'nom', '_date_modification', 'user_modification', )
22343fe7 1041 fieldsets = AUFMetadataAdminMixin.fieldsets + (
53ae644d
OL
1042 (None, {
1043 'fields': ('code', 'nom', ),
1044 }),
1045 )
1046
33232787 1047 def _date_modification(self, obj):
22343fe7
OL
1048 return date(obj.date_modification) \
1049 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1050 _date_modification.short_description = u'date modification'
1051 _date_modification.admin_order_field = 'date_modification'
1052
22343fe7 1053
08a9b6fc 1054class TauxChangeAdmin(BaseAdmin):
22343fe7
OL
1055 list_display = (
1056 'taux',
1057 'devise',
1058 'annee',
1059 '_date_modification',
1060 'user_modification',
1061 )
53ae644d 1062 list_filter = ('devise', )
22343fe7 1063 fieldsets = AUFMetadataAdminMixin.fieldsets + (
53ae644d
OL
1064 (None, {
1065 'fields': ('taux', 'devise', 'annee', ),
1066 }),
1067 )
1068
33232787 1069 def _date_modification(self, obj):
22343fe7
OL
1070 return date(obj.date_modification) \
1071 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1072 _date_modification.short_description = u'date modification'
1073 _date_modification.admin_order_field = 'date_modification'
1074
22343fe7 1075
08a9b6fc 1076class TypeContratAdmin(BaseAdmin):
22343fe7
OL
1077 list_display = (
1078 'nom',
1079 'nom_long',
1080 '_date_modification',
1081 'user_modification',
1082 )
1083 fieldsets = AUFMetadataAdminMixin.fieldsets + (
53ae644d
OL
1084 (None, {
1085 'fields': ('nom', 'nom_long', ),
1086 }),
1087 )
1088
33232787 1089 def _date_modification(self, obj):
22343fe7
OL
1090 return date(obj.date_modification) \
1091 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1092 _date_modification.short_description = u'date modification'
1093 _date_modification.admin_order_field = 'date_modification'
1094
53ae644d 1095
08a9b6fc 1096class TypePosteAdmin(AUFMetadataAdminMixin, BaseAdmin):
53ae644d 1097 search_fields = ('nom', 'nom_feminin', )
22343fe7
OL
1098 list_display = (
1099 'nom',
7bf28694 1100 'categorie_emploi',
22343fe7
OL
1101 '_date_modification',
1102 'user_modification',
1103 )
321fe481 1104 list_filter = ('categorie_emploi', 'famille_professionnelle')
22343fe7 1105 fieldsets = AUFMetadataAdminMixin.fieldsets + (
53ae644d 1106 (None, {
22343fe7
OL
1107 'fields': (
1108 'nom',
1109 'nom_feminin',
1110 'is_responsable',
7bf28694 1111 'categorie_emploi',
321fe481 1112 'famille_professionnelle',
22343fe7
OL
1113 )}
1114 ),
53ae644d
OL
1115 )
1116
33232787 1117 def _date_modification(self, obj):
22343fe7
OL
1118 return date(obj.date_modification) \
1119 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1120 _date_modification.short_description = u'date modification'
1121 _date_modification.admin_order_field = 'date_modification'
1122
53ae644d 1123
08a9b6fc 1124class TypeRemunerationAdmin(AUFMetadataAdminMixin, BaseAdmin,
fc4bf968 1125 ArchiveMixin):
22343fe7
OL
1126 list_display = (
1127 'nom',
1128 'type_paiement',
1129 'nature_remuneration',
7ba822a6 1130 '_archive',
22343fe7
OL
1131 '_date_modification',
1132 'user_modification',)
7ba822a6 1133 list_filter = ('archive', )
22343fe7 1134 fieldsets = AUFMetadataAdminMixin.fieldsets + (
7ba822a6
OL
1135 (None, {'fields': ('nom', 'type_paiement', 'nature_remuneration',
1136 'archive')}),
53ae644d
OL
1137 )
1138
33232787 1139 def _date_modification(self, obj):
22343fe7
OL
1140 return date(obj.date_modification) \
1141 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1142 _date_modification.short_description = u'date modification'
1143 _date_modification.admin_order_field = 'date_modification'
1144
53ae644d 1145
08a9b6fc 1146class TypeRevalorisationAdmin(AUFMetadataAdminMixin, BaseAdmin):
33232787 1147 list_display = ('nom', '_date_modification', 'user_modification', )
22343fe7
OL
1148 fieldsets = AUFMetadataAdminMixin.fieldsets + (
1149 (None, {'fields': ('nom', )}),
53ae644d
OL
1150 )
1151
33232787 1152 def _date_modification(self, obj):
22343fe7
OL
1153 return date(obj.date_modification) \
1154 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1155 _date_modification.short_description = u'date modification'
1156 _date_modification.admin_order_field = 'date_modification'
1157
53ae644d 1158
08a9b6fc 1159class ValeurPointAdmin(AUFMetadataAdminMixin, BaseAdmin):
22343fe7
OL
1160 list_display = (
1161 '_devise_code',
1162 '_devise_nom',
1163 'annee',
88202dc3 1164 'implantation',
22343fe7
OL
1165 'valeur',
1166 '_date_modification',
1167 'user_modification',
1168 )
88202dc3 1169 list_filter = ('annee', 'devise', 'implantation__region', )
22343fe7
OL
1170 fieldsets = AUFMetadataAdminMixin.fieldsets + (
1171 (None, {'fields': ('valeur', 'devise', 'implantation', 'annee', )}),
53ae644d
OL
1172 )
1173
33232787 1174 def _date_modification(self, obj):
22343fe7
OL
1175 return date(obj.date_modification) \
1176 if obj.date_modification is not None else "(aucune)"
33232787
JPC
1177 _date_modification.short_description = u'date modification'
1178 _date_modification.admin_order_field = 'date_modification'
1179
53ae644d
OL
1180 def _devise_code(self, obj):
1181 return obj.devise.code
1182 _devise_code.short_description = "Code de la devise"
1183
1184 def _devise_nom(self, obj):
1185 return obj.devise.nom
1186 _devise_nom.short_description = "Nom de la devise"
1187
fc4bf968 1188
08a9b6fc 1189class ImplantationProxyAdmin(BaseAdmin):
82af5c19 1190 list_display = ('nom', '_organigramme')
8135fc65
JPC
1191 actions = None
1192
1193 def __init__(self, *args, **kwargs):
1194 super(ImplantationProxyAdmin, self).__init__(*args, **kwargs)
1195 self.list_display_links = (None, )
82af5c19
JPC
1196
1197 def has_add_permission(self, obj):
1198 return False
1199
aa2c508e
JPC
1200 def has_change_permission(self, request, obj=None):
1201 return in_drh_or_admin(request.user)
1202
82af5c19 1203 def _organigramme(self, obj):
fc4bf968
EMS
1204 return '<a href="%s"><strong>Organigramme</strong></a>' % (
1205 reverse('rho_implantation', args=(obj.id,))
1206 )
82af5c19
JPC
1207 _organigramme.allow_tags = True
1208 _organigramme.short_description = "Organigramme"
1209
fc4bf968 1210
08a9b6fc 1211class RegionProxyAdmin(BaseAdmin):
9da4c195 1212 list_display = ('nom', '_organigramme')
8135fc65
JPC
1213 actions = None
1214
1215 def __init__(self, *args, **kwargs):
1216 super(RegionProxyAdmin, self).__init__(*args, **kwargs)
1217 self.list_display_links = (None, )
9da4c195
JPC
1218
1219 def has_add_permission(self, obj):
1220 return False
1221
aa2c508e
JPC
1222 def has_change_permission(self, request, obj=None):
1223 return in_drh_or_admin(request.user)
1224
9da4c195 1225 def _organigramme(self, obj):
fc4bf968
EMS
1226 return """<a href="%s"><strong>Organigramme</strong></a>""" % (
1227 reverse('rho_region', args=(obj.id,))
1228 )
9da4c195
JPC
1229 _organigramme.allow_tags = True
1230 _organigramme.short_description = "Organigramme"
1231
1232
53ae644d
OL
1233admin.site.register(rh.Classement, ClassementAdmin)
1234admin.site.register(rh.Devise, DeviseAdmin)
1235admin.site.register(rh.Dossier, DossierAdmin)
22343fe7 1236admin.site.register(EmployeProxy, EmployeProxyAdmin)
5c0f1778 1237admin.site.register(ServiceProxy, ServiceProxyAdmin)
53ae644d 1238admin.site.register(rh.Employe, EmployeAdmin)
7bf28694 1239admin.site.register(rh.CategorieEmploi, CategorieEmploiAdmin)
321fe481 1240admin.site.register(rh.FamilleProfessionnelle)
53ae644d
OL
1241admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
1242admin.site.register(rh.Poste, PosteAdmin)
fc4bf968
EMS
1243admin.site.register(
1244 rh.ResponsableImplantationProxy, ResponsableImplantationAdmin
1245)
53ae644d 1246admin.site.register(rh.Service, ServiceAdmin)
c5964dc2 1247admin.site.register(rh.Statut, StatutAdmin)
53ae644d 1248admin.site.register(rh.TauxChange, TauxChangeAdmin)
c5964dc2 1249admin.site.register(rh.TypeContrat, TypeContratAdmin)
53ae644d
OL
1250admin.site.register(rh.TypePoste, TypePosteAdmin)
1251admin.site.register(rh.TypeRemuneration, TypeRemunerationAdmin)
1252admin.site.register(rh.TypeRevalorisation, TypeRevalorisationAdmin)
1253admin.site.register(rh.ValeurPoint, ValeurPointAdmin)
82af5c19 1254admin.site.register(ImplantationProxy, ImplantationProxyAdmin)
9da4c195 1255admin.site.register(RegionProxy, RegionProxyAdmin)