...
 
Commits (4)
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# This file is part of Radar Legislativo
# Copyright © 2016 codingrights
#
......@@ -21,4 +21,10 @@ from markdownx.admin import MarkdownxModelAdmin
from .models import Evento
admin.site.register(Evento, MarkdownxModelAdmin)
class EventoAdmin(MarkdownxModelAdmin):
list_select_related = ('comissao', )
raw_id_fields = ['comissao']
admin.site.register(Evento, EventoAdmin)
......@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django.contrib import admin
from .models import (
Comissao,
ComissaoCamara,
ComissaoSenado,
Deputado,
......@@ -12,6 +13,11 @@ from .models import (
)
class ComissaoAdmin(admin.ModelAdmin):
search_fields = ('nome', )
admin.site.register(Comissao, ComissaoAdmin)
admin.site.register(ComissaoCamara)
admin.site.register(ComissaoSenado)
admin.site.register(Deputado)
......
......@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.text import Truncator
@python_2_unicode_compatible
......@@ -91,11 +92,14 @@ class Comissao(models.Model):
verbose_name_plural = "Comissões"
def __str__(self):
return '{} - {}'.format(self.nome, self.origem)
return '{} - {}'.format(Truncator(self.nome).chars(100), self.origem)
@property
def origem(self):
camara = self.__dict__.get('_comissaocamaracache')
try:
camara = self.comissaocamara
except Exception:
camara = False
return 'Câmara' if camara else 'Senado'
......@@ -119,4 +123,3 @@ class ComissaoCamara(Comissao):
class Meta:
verbose_name = 'Comissão da Câmara'
verbose_name_plural = 'Comissões da Câmara'