diff --git a/src/documents/admin.py b/src/documents/admin.py index a85b087a3..3afb71667 100755 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -12,31 +12,6 @@ from documents.actions import add_tag_to_selected, remove_tag_from_selected, set from .models import Correspondent, Tag, Document, Log -class MonthListFilter(admin.SimpleListFilter): - - title = "Month" - - # Parameter for the filter that will be used in the URL query. - parameter_name = "month" - - def lookups(self, request, model_admin): - r = [] - for document in Document.objects.all(): - r.append(( - document.created.strftime("%Y-%m"), - document.created.strftime("%B %Y") - )) - return sorted(set(r), key=lambda x: x[0], reverse=True) - - def queryset(self, request, queryset): - - if not self.value(): - return None - - year, month = self.value().split("-") - return queryset.filter(created__year=year, created__month=month) - - class FinancialYearFilter(admin.SimpleListFilter): title = "Financial Year" @@ -154,13 +129,14 @@ class DocumentAdmin(CommonAdmin): readonly_fields = ("added",) list_display = ("title", "created", "added", "thumbnail", "correspondent", "tags_", "archive_serial_number") - list_filter = ("tags", "correspondent", FinancialYearFilter, - MonthListFilter) + list_filter = ("tags", "correspondent", FinancialYearFilter) ordering = ["-created", "correspondent"] actions = [add_tag_to_selected, remove_tag_from_selected, set_correspondent_on_selected, remove_correspondent_from_selected] + date_hierarchy = 'created' + def has_add_permission(self, request): return False