Skip to content

Commit

Permalink
Merge branch 'metadata'
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslavandeira committed Dec 5, 2018
2 parents 1a1e02f + c711d5c commit e3643b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion django_datajsonar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
Expand Down

0 comments on commit e3643b1

Please sign in to comment.