Browse Source

corrige admin p/ sapl func c/ app externa em outros projetos

pull/1744/head
LeandroRoberto 7 years ago
parent
commit
abab47e17c
  1. 34
      sapl/materia/admin.py

34
sapl/materia/admin.py

@ -3,11 +3,9 @@ from django.contrib import admin
from sapl.base.models import TipoAutor from sapl.base.models import TipoAutor
from sapl.comissoes.models import TipoComissao from sapl.comissoes.models import TipoComissao
from sapl.materia.models import Proposicao, TipoMateriaLegislativa from sapl.materia.models import Proposicao
from sapl.norma.models import TipoNormaJuridica, TipoVinculoNormaJuridica from sapl.parlamentares.models import TipoAfastamento, SituacaoMilitar, \
from sapl.parlamentares.models import TipoAfastamento, SituacaoMilitar, TipoDependente TipoDependente
from sapl.protocoloadm.models import TipoDocumentoAdministrativo
from sapl.sessao.models import TipoSessaoPlenaria, TipoExpediente, TipoResultadoVotacao
from sapl.utils import register_all_models_in_admin from sapl.utils import register_all_models_in_admin
@ -15,13 +13,6 @@ register_all_models_in_admin(__name__)
if not settings.DEBUG: if not settings.DEBUG:
admin.site.unregister(Proposicao)
admin.site.unregister(TipoAutor)
admin.site.unregister(TipoComissao)
admin.site.unregister(TipoAfastamento)
admin.site.unregister(SituacaoMilitar)
admin.site.unregister(TipoDependente)
class RestricaoAdmin(admin.ModelAdmin): class RestricaoAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None): def has_add_permission(self, request, obj=None):
@ -33,9 +24,16 @@ if not settings.DEBUG:
def has_delete_permission(self, request, obj=None): def has_delete_permission(self, request, obj=None):
return False return False
admin.site.register(Proposicao, RestricaoAdmin) models = (
admin.site.register(TipoAutor, RestricaoAdmin) Proposicao,
admin.site.register(TipoComissao, RestricaoAdmin) TipoAutor,
admin.site.register(TipoAfastamento, RestricaoAdmin) TipoComissao,
admin.site.register(SituacaoMilitar, RestricaoAdmin) TipoAfastamento,
admin.site.register(TipoDependente, RestricaoAdmin) SituacaoMilitar,
TipoDependente
)
for model in models:
if admin.site.is_registered(model):
admin.site.unregister(model)
admin.site.register(model, RestricaoAdmin)

Loading…
Cancel
Save