diff --git a/django_datajsonar/admin.py b/django_datajsonar/admin.py index fa8d4c5..61edada 100644 --- a/django_datajsonar/admin.py +++ b/django_datajsonar/admin.py @@ -2,9 +2,10 @@ from __future__ import unicode_literals from django import forms +from django.contrib.contenttypes.models import ContentType from django.forms.models import modelformset_factory from django.contrib import admin, messages -from django.contrib.admin import helpers +from django.contrib.admin import helpers, SimpleListFilter from django.utils import timezone from django.conf.urls import url from django.contrib.contenttypes.admin import GenericTabularInline @@ -424,6 +425,31 @@ def new_process(self, request): return render(request, 'synchronizer.html', context) +class EnhancedMetaFilter(SimpleListFilter): + def lookups(self, request, model_admin): + return ( + ('catalog', 'Catálogo'), + ('dataset', 'Dataset'), + ('distribution', 'Distribución'), + ('field', 'Campo'), + ) + + title = 'Instancia' + parameter_name = 'content_object' + + def queryset(self, request, queryset): + if self.value() is None: + return queryset + return queryset.filter(content_type=ContentType.objects.get(app_label='django_datajsonar', + model=self.value())) + + +@admin.register(Metadata) +class MetadataAdmin(admin.ModelAdmin): + list_filter = (EnhancedMetaFilter, 'key') + list_display = ('content_type', 'key', 'value') + + admin.site.register(Catalog, CatalogAdmin) admin.site.register(Dataset, DatasetAdmin) admin.site.register(Distribution, DistributionAdmin) diff --git a/setup.py b/setup.py index 4b442a1..8dc6484 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='django_datajsonar', - version='0.1.7', + version='0.1.8', description="Paquete de django con herramientas para administrar modelos de catalogos.", author="Datos Argentina", author_email='datos@modernizacion.gob.ar',