Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Merge branch 'master' into dev

Jonas Winkler13725ef8ee7e
diff --cc paperless.conf.example
index d42d5ca5f,8aa33216f..0434b590d
mode 100755,100644..100755
--- a/paperless.conf.example
+++ b/paperless.conf.example
diff --cc src/documents/admin.py
index 65548d91f,02e9cd56b..df0811f2d
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@@ -1,20 -1,42 +1,22 @@@
-from datetime import datetime
+from datetime import datetime, timedelta
from django.conf import settings
-from django.contrib import admin
+from django.contrib import admin, messages
+from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.auth.models import User, Group
- from django.http import HttpResponseRedirect
- from django.urls import reverse
+ try:
+ from django.core.urlresolvers import reverse
+ except ImportError:
+ from django.urls import reverse
from django.templatetags.static import static
+from django.utils.html import format_html
+from django.utils.http import urlquote
from django.utils.safestring import mark_safe
-from django.utils.html import format_html, format_html_join
+from django.db import models
-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)
+from documents.actions import add_tag_to_selected, remove_tag_from_selected, set_correspondent_on_selected, \
+ remove_correspondent_from_selected, set_document_type_on_selected, remove_document_type_from_selected
+from .models import Correspondent, Tag, Document, Log, DocumentType
class FinancialYearFilter(admin.SimpleListFilter):
@@@ -186,17 -139,13 +188,19 @@@ class DocumentAdmin(CommonAdmin)
search_fields = ("correspondent__name", "title", "content", "tags__name")
readonly_fields = ("added",)
list_display = ("title", "created", "added", "thumbnail", "correspondent",
- "tags_")
- list_filter = ("tags", "correspondent", FinancialYearFilter,
- MonthListFilter)
+ "tags_", "archive_serial_number", "document_type")
+ list_filter = ("document_type", "tags", ('correspondent', RecentCorrespondentFilter), "correspondent", FinancialYearFilter)
+
+ filter_horizontal = ("tags",)
+
ordering = ["-created", "correspondent"]
+ actions = [add_tag_to_selected, remove_tag_from_selected, set_correspondent_on_selected, remove_correspondent_from_selected, set_document_type_on_selected, remove_document_type_from_selected]
+
+ date_hierarchy = 'created'
+
+ document_queue = None
+
def has_add_permission(self, request):
return False
diff --cc src/documents/filters.py
index 77f14928b,68861d967..780491a14
mode 100755,100644..100755
--- a/src/documents/filters.py
+++ b/src/documents/filters.py
@@@ -1,6 -1,6 +1,6 @@@
- from django_filters.rest_framework import CharFilter, FilterSet
+ from django_filters.rest_framework import CharFilter, FilterSet, BooleanFilter
-from .models import Correspondent, Document, Tag
+from .models import Correspondent, Document, Tag, DocumentType
class CorrespondentFilterSet(FilterSet):
@@@ -55,14 -42,18 +55,22 @@@ class DocumentFilterSet(FilterSet)
)
}
- correspondent__name = CharFilter(name="correspondent__name", **CHAR_KWARGS)
- correspondent__slug = CharFilter(name="correspondent__slug", **CHAR_KWARGS)
- tags__name = CharFilter(name="tags__name", **CHAR_KWARGS)
- tags__slug = CharFilter(name="tags__slug", **CHAR_KWARGS)
- document_type__name = CharFilter(name="document_type__name", **CHAR_KWARGS)
- document_type__slug = CharFilter(name="document_type__slug", **CHAR_KWARGS)
+ correspondent__name = CharFilter(
+ field_name="correspondent__name", **CHAR_KWARGS)
+ correspondent__slug = CharFilter(
+ field_name="correspondent__slug", **CHAR_KWARGS)
+ tags__name = CharFilter(
+ field_name="tags__name", **CHAR_KWARGS)
+ tags__slug = CharFilter(
+ field_name="tags__slug", **CHAR_KWARGS)
+ tags__empty = BooleanFilter(
+ field_name="tags", lookup_expr="isnull", distinct=True)
++ document_type__name = CharFilter(
++ name="document_type__name", **CHAR_KWARGS)
++ document_type__slug = CharFilter(
++ name="document_type__slug", **CHAR_KWARGS)
- class Meta(object):
+ class Meta:
model = Document
fields = {
"title": [
diff --cc src/documents/serialisers.py
index 99e71917f,f71a0c5ab..61cdea8c7
mode 100755,100644..100755
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@@ -10,16 -10,9 +10,16 @@@ class CorrespondentSerializer(serialize
fields = ("id", "slug", "name")
+class DocumentTypeSerializer(serializers.HyperlinkedModelSerializer):
+
+ class Meta(object):
+ model = DocumentType
+ fields = ("id", "slug", "name")
+
+
class TagSerializer(serializers.HyperlinkedModelSerializer):
- class Meta(object):
+ class Meta:
model = Tag
fields = (
"id", "slug", "name", "colour", "match", "matching_algorithm")
@@@ -45,10 -33,8 +45,10 @@@ class DocumentSerializer(serializers.Mo
correspondent = CorrespondentField(
view_name="drf:correspondent-detail", allow_null=True)
tags = TagsField(view_name="drf:tag-detail", many=True)
+ document_type = DocumentTypeField(
+ view_name="drf:documenttype-detail", allow_null=True)
- class Meta(object):
+ class Meta:
model = Document
fields = (
"id",