mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
from django.apps import apps
|
|
from django.contrib import admin
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
# SAPL business apps
|
|
# This is a dependency order: each entry depends only on previous ones
|
|
# The order is important for migration code
|
|
appconfs = [apps.get_app_config(n) for n in [
|
|
'parlamentares',
|
|
'comissoes',
|
|
'compilacao',
|
|
'materia',
|
|
'norma',
|
|
'sessao',
|
|
'lexml',
|
|
'protocoloadm', ]]
|
|
|
|
|
|
def register_all_models_in_admin(module_name):
|
|
appname = module_name.split('.')[0]
|
|
app = apps.get_app_config(appname)
|
|
for model in app.get_models():
|
|
class CustomModelAdmin(admin.ModelAdmin):
|
|
list_display = [f.name for f in model._meta.fields
|
|
if f.name != 'id']
|
|
|
|
if not admin.site.is_registered(model):
|
|
admin.site.register(model, CustomModelAdmin)
|
|
|
|
|
|
def make_choices(*choice_pairs):
|
|
assert len(choice_pairs) % 2 == 0
|
|
ipairs = iter(choice_pairs)
|
|
choices = list(zip(ipairs, ipairs))
|
|
yield choices
|
|
for key, value in choices:
|
|
yield key
|
|
|
|
YES_NO_CHOICES = [(True, _('Sim')), (False, _('Não'))]
|
|
|