pass
-class ResponsableImplantationAdmin(AUFMetadataAdminMixin, admin.ModelAdmin):
- fieldsets = AUFMetadataAdminMixin.fieldsets + (
- (None, {
- 'fields': ('employe', 'implantation', ),
- }),
- )
+class ResponsableInline(admin.TabularInline):
+ model = rh.ResponsableImplantation
+ extra = 0
+ fk_name = "implantation"
+class ResponsableImplantationAdmin(admin.ModelAdmin):
+ actions = None
+ list_filter = ('region', 'statut', )
+ list_display = ('nom', 'statut', '_responsable', )
+ readonly_fields = ('nom', )
+ fields = ('nom', )
+ inlines = (ResponsableInline, )
+
+ def _responsable(self, obj):
+ try:
+ employe = obj.responsable.employe
+ dossiers = employe.dossiers_encours()
+ if len(dossiers) == 0:
+ return u"<span style='color: red;'>%s %s </span>" % (
+ employe, u"sans dossier actif")
+ else:
+ return employe
+ except Exception, e:
+ if obj.statut in (1, 2): # ouverte, ouverture imminente
+ css = "style='color: red;'"
+ else:
+ css = ""
+ return u"<span %s>Pas de responsable</span>" % css
+ _responsable.allow_tags = True
+ _responsable.short_description = u"Responsable"
+
+ def has_add_permission(self, request=None):
+ return False
+
+ def has_change_permission(self, request, obj=None):
+ return in_drh_or_admin(request.user)
+
+ def has_delete_permission(self, request, obj=None):
+ return False
class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin, ArchiveMixin):
list_display = (
admin.site.register(rh.FamilleEmploi, FamilleEmploiAdmin)
admin.site.register(rh.OrganismeBstg, OrganismeBstgAdmin)
admin.site.register(rh.Poste, PosteAdmin)
-admin.site.register(rh.ResponsableImplantation, ResponsableImplantationAdmin)
+admin.site.register(rh.ResponsableImplantationProxy, ResponsableImplantationAdmin)
admin.site.register(rh.Service, ServiceAdmin)
admin.site.register(rh.Statut, StatutAdmin)
admin.site.register(rh.TauxChange, TauxChangeAdmin)
### AUTRES
-class ResponsableImplantation(AUFMetadata):
+class ResponsableImplantationProxy(ref.Implantation):
+ class Meta:
+ proxy = True
+ verbose_name = u"Responsable d'implantation"
+ verbose_name_plural = u"Responsables d'implantation"
+
+
+class ResponsableImplantation(models.Model):
"""Le responsable d'une implantation.
Anciennement géré sur le Dossier du responsable.
"""
employe = models.ForeignKey('Employe', db_column='employe',
related_name='+',
null=True, blank=True)
- implantation = models.ForeignKey(ref.Implantation,
- db_column='implantation', related_name='+',
+ implantation = models.OneToOneField("ResponsableImplantationProxy",
+ db_column='implantation', related_name='responsable',
unique=True)
def __unicode__(self):