Commits

jgsogo committed ef556c7 Draft

filtros escalonados

  • Participants
  • Parent commits 7c1871b

Comments (0)

Files changed (2)

File linneo/admin.py

     exclude = ('rank',)
     list_display = ('name', 'rank',)
     mptt_level_indent = 20
-    list_filter = (InRankListFilter,)
+    list_filter = ()
 
 admin.site.register(DomainTaxon, MajorTaxonomicRankAdmin)
 admin.site.register(KingdomTaxon, MajorTaxonomicRankAdmin)
 
 class TaxonAdmin(TaxonAdmin):
     list_display = ('name', 'rank',)
-    list_filter = (RankListFilter,)
+    list_filter = (RankListFilter, InRankListFilter)
     mptt_level_indent = 20
 
 admin.site.register(Taxon, TaxonAdmin)

File linneo/filters.py

 from taxonomy.models import TaxonRank
 
 class RankListFilter(SimpleListFilter):
-    title = _('taxonomic rank')
+    title = _('taxonomic rank group')
 
     parameter_name = 'taxo_rank'
 
     parameter_name = 'minortaxo_rank'
 
     def lookups(self, request, model_admin):
-        rank = model_admin.model.objects._get_rank().rank
-        return ( (it.in_rank_order, it) for it in TaxonRank.objects.filter(rank=rank))
+        if request.GET.get('taxo_rank', False):
+            rank = request.GET.get('taxo_rank')
+            return ( (it.in_rank_order, it) for it in TaxonRank.objects.filter(rank=rank))
 
     def queryset(self, request, queryset):
         if self.value():