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