Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9faf0a102e | ||
|
|
b747dd58c3 | ||
|
|
09e1b505e1 | ||
|
|
a6babffed8 | ||
|
|
0256e2dfbb | ||
|
|
7afa90b769 | ||
|
|
5796956235 | ||
|
|
67b492bcb7 | ||
|
|
360d1e2802 | ||
|
|
1cd76634a3 | ||
|
|
c65c5009e4 | ||
|
|
24fb6cefb9 | ||
|
|
d80e272b75 |
@@ -11,7 +11,7 @@ matrix:
|
|||||||
- python: 3.6
|
- python: 3.6
|
||||||
env: TOXENV=py36
|
env: TOXENV=py36
|
||||||
- python: 3.6
|
- python: 3.6
|
||||||
env: TOXENV=pep8
|
env: TOXENV=pycodestyle
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install --requirement requirements.txt
|
- pip install --requirement requirements.txt
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
Changelog
|
Changelog
|
||||||
#########
|
#########
|
||||||
|
|
||||||
|
* 1.1.0
|
||||||
|
* Fix for `#283`_, a redirect bug which broke interactions with
|
||||||
|
paperless-desktop. Thanks to `chris-aeviator`_ for reporting it.
|
||||||
|
* Addition of an optional new financial year filter, courtesy of
|
||||||
|
`David Martin`_ `#256`_
|
||||||
|
* Fixed a typo in how thumbnails were named in exports `#285`_, courtesy of
|
||||||
|
`Dan Panzarella`_
|
||||||
|
|
||||||
* 1.0.0
|
* 1.0.0
|
||||||
* Upgrade to Django 1.11. **You'll need to run
|
* Upgrade to Django 1.11. **You'll need to run
|
||||||
``pip install -r requirements.txt`` to after the usual ``git pull`` to
|
``pip install -r requirements.txt`` after the usual ``git pull`` to
|
||||||
properly update**.
|
properly update**.
|
||||||
* Replace the templatetag-based hack we had for document listing in favour of
|
* Replace the templatetag-based hack we had for document listing in favour of
|
||||||
a slightly less ugly solution in the form of another template tag with less
|
a slightly less ugly solution in the form of another template tag with less
|
||||||
@@ -258,6 +266,8 @@ Changelog
|
|||||||
.. _Stefan Hagen: https://github.com/xkpd3
|
.. _Stefan Hagen: https://github.com/xkpd3
|
||||||
.. _dev-rke: https://github.com/dev-rke
|
.. _dev-rke: https://github.com/dev-rke
|
||||||
.. _Lukas Winkler: https://github.com/Findus23
|
.. _Lukas Winkler: https://github.com/Findus23
|
||||||
|
.. _chris-aeviator: https://github.com/chris-aeviator
|
||||||
|
.. _Dan Panzarella: https://github.com/pzl
|
||||||
|
|
||||||
.. _#20: https://github.com/danielquinn/paperless/issues/20
|
.. _#20: https://github.com/danielquinn/paperless/issues/20
|
||||||
.. _#44: https://github.com/danielquinn/paperless/issues/44
|
.. _#44: https://github.com/danielquinn/paperless/issues/44
|
||||||
@@ -304,3 +314,6 @@ Changelog
|
|||||||
.. _#272: https://github.com/danielquinn/paperless/issues/272
|
.. _#272: https://github.com/danielquinn/paperless/issues/272
|
||||||
.. _#248: https://github.com/danielquinn/paperless/issues/248
|
.. _#248: https://github.com/danielquinn/paperless/issues/248
|
||||||
.. _#278: https://github.com/danielquinn/paperless/issues/248
|
.. _#278: https://github.com/danielquinn/paperless/issues/248
|
||||||
|
.. _#283: https://github.com/danielquinn/paperless/issues/283
|
||||||
|
.. _#256: https://github.com/danielquinn/paperless/pull/256
|
||||||
|
.. _#285: https://github.com/danielquinn/paperless/pull/285
|
||||||
|
|||||||
@@ -167,6 +167,12 @@ PAPERLESS_PASSPHRASE="secret"
|
|||||||
#PAPERLESS_TIME_ZONE=UTC
|
#PAPERLESS_TIME_ZONE=UTC
|
||||||
|
|
||||||
|
|
||||||
|
# If set, Paperless will show document filters per financial year.
|
||||||
|
# The dates must be in the format "mm-dd", for example "07-15" for July 15.
|
||||||
|
#PAPERLESS_FINANCIAL_YEAR_START="mm-dd"
|
||||||
|
#PAPERLESS_FINANCIAL_YEAR_END="mm-dd"
|
||||||
|
|
||||||
|
|
||||||
# The number of items on each page in the web UI. This value must be a
|
# The number of items on each page in the web UI. This value must be a
|
||||||
# positive integer, but if you don't define one in paperless.conf, a default of
|
# positive integer, but if you don't define one in paperless.conf, a default of
|
||||||
# 100 will be used.
|
# 100 will be used.
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
@@ -32,6 +34,71 @@ class MonthListFilter(admin.SimpleListFilter):
|
|||||||
return queryset.filter(created__year=year, created__month=month)
|
return queryset.filter(created__year=year, created__month=month)
|
||||||
|
|
||||||
|
|
||||||
|
class FinancialYearFilter(admin.SimpleListFilter):
|
||||||
|
|
||||||
|
title = "Financial Year"
|
||||||
|
parameter_name = "fy"
|
||||||
|
_fy_wraps = None
|
||||||
|
|
||||||
|
def _fy_start(self, year):
|
||||||
|
"""Return date of the start of financial year for the given year."""
|
||||||
|
fy_start = "{}-{}".format(str(year), settings.FY_START)
|
||||||
|
return datetime.strptime(fy_start, "%Y-%m-%d").date()
|
||||||
|
|
||||||
|
def _fy_end(self, year):
|
||||||
|
"""Return date of the end of financial year for the given year."""
|
||||||
|
fy_end = "{}-{}".format(str(year), settings.FY_END)
|
||||||
|
return datetime.strptime(fy_end, "%Y-%m-%d").date()
|
||||||
|
|
||||||
|
def _fy_does_wrap(self):
|
||||||
|
"""Return whether the financial year spans across two years."""
|
||||||
|
if self._fy_wraps is None:
|
||||||
|
start = "{}".format(settings.FY_START)
|
||||||
|
start = datetime.strptime(start, "%m-%d").date()
|
||||||
|
end = "{}".format(settings.FY_END)
|
||||||
|
end = datetime.strptime(end, "%m-%d").date()
|
||||||
|
self._fy_wraps = end < start
|
||||||
|
|
||||||
|
return self._fy_wraps
|
||||||
|
|
||||||
|
def _determine_fy(self, date):
|
||||||
|
"""Return a (query, display) financial year tuple of the given date."""
|
||||||
|
if self._fy_does_wrap():
|
||||||
|
fy_start = self._fy_start(date.year)
|
||||||
|
|
||||||
|
if date.date() >= fy_start:
|
||||||
|
query = "{}-{}".format(date.year, date.year + 1)
|
||||||
|
else:
|
||||||
|
query = "{}-{}".format(date.year - 1, date.year)
|
||||||
|
|
||||||
|
# To keep it simple we use the same string for both
|
||||||
|
# query parameter and the display.
|
||||||
|
return (query, query)
|
||||||
|
|
||||||
|
else:
|
||||||
|
query = "{0}-{0}".format(date.year)
|
||||||
|
display = "{}".format(date.year)
|
||||||
|
return (query, display)
|
||||||
|
|
||||||
|
def lookups(self, request, model_admin):
|
||||||
|
if not settings.FY_START or not settings.FY_END:
|
||||||
|
return None
|
||||||
|
|
||||||
|
r = []
|
||||||
|
for document in Document.objects.all():
|
||||||
|
r.append(self._determine_fy(document.created))
|
||||||
|
|
||||||
|
return sorted(set(r), key=lambda x: x[0], reverse=True)
|
||||||
|
|
||||||
|
def queryset(self, request, queryset):
|
||||||
|
if not self.value() or not settings.FY_START or not settings.FY_END:
|
||||||
|
return None
|
||||||
|
|
||||||
|
start, end = self.value().split("-")
|
||||||
|
return queryset.filter(created__gte=self._fy_start(start),
|
||||||
|
created__lte=self._fy_end(end))
|
||||||
|
|
||||||
|
|
||||||
class CommonAdmin(admin.ModelAdmin):
|
class CommonAdmin(admin.ModelAdmin):
|
||||||
list_per_page = settings.PAPERLESS_LIST_PER_PAGE
|
list_per_page = settings.PAPERLESS_LIST_PER_PAGE
|
||||||
|
|
||||||
@@ -59,7 +126,9 @@ class DocumentAdmin(CommonAdmin):
|
|||||||
|
|
||||||
search_fields = ("correspondent__name", "title", "content")
|
search_fields = ("correspondent__name", "title", "content")
|
||||||
list_display = ("title", "created", "thumbnail", "correspondent", "tags_")
|
list_display = ("title", "created", "thumbnail", "correspondent", "tags_")
|
||||||
list_filter = ("tags", "correspondent", MonthListFilter)
|
list_filter = ("tags", "correspondent", FinancialYearFilter,
|
||||||
|
MonthListFilter)
|
||||||
|
|
||||||
ordering = ["-created", "correspondent"]
|
ordering = ["-created", "correspondent"]
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Command(Renderable, BaseCommand):
|
|||||||
|
|
||||||
file_target = os.path.join(self.target, document.file_name)
|
file_target = os.path.join(self.target, document.file_name)
|
||||||
|
|
||||||
thumbnail_name = document.file_name + "-tumbnail.png"
|
thumbnail_name = document.file_name + "-thumbnail.png"
|
||||||
thumbnail_target = os.path.join(self.target, thumbnail_name)
|
thumbnail_target = os.path.join(self.target, thumbnail_name)
|
||||||
|
|
||||||
document_dict[EXPORTER_FILE_NAME] = document.file_name
|
document_dict[EXPORTER_FILE_NAME] = document.file_name
|
||||||
|
|||||||
@@ -255,3 +255,6 @@ POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
|
|||||||
# positive integer, but if you don't define one in paperless.conf, a default of
|
# positive integer, but if you don't define one in paperless.conf, a default of
|
||||||
# 100 will be used.
|
# 100 will be used.
|
||||||
PAPERLESS_LIST_PER_PAGE = int(os.getenv("PAPERLESS_LIST_PER_PAGE", 100))
|
PAPERLESS_LIST_PER_PAGE = int(os.getenv("PAPERLESS_LIST_PER_PAGE", 100))
|
||||||
|
|
||||||
|
FY_START = os.getenv("PAPERLESS_FINANCIAL_YEAR_START")
|
||||||
|
FY_END = os.getenv("PAPERLESS_FINANCIAL_YEAR_END")
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ urlpatterns = [
|
|||||||
# The Django admin
|
# The Django admin
|
||||||
url(r"admin/", admin.site.urls),
|
url(r"admin/", admin.site.urls),
|
||||||
|
|
||||||
# Catch all redirect back to /admin
|
# Redirect / to /admin
|
||||||
url(r"", RedirectView.as_view(permanent=True, url="/admin/")),
|
url(r"^$", RedirectView.as_view(permanent=True, url="/admin/")),
|
||||||
|
|
||||||
] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = (1, 0, 0)
|
__version__ = (1, 1, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user