Skip to content
This repository was archived by the owner on Feb 19, 2021. It is now read-only.

Commit 0868390

Browse files
committed
Merge branch 'dadosch-django-v2'
2 parents 218809c + d5180fe commit 0868390

19 files changed

+72
-56
lines changed

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
4040

4141
## Attribution
4242

43-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4 to remove puritanical language. The original is available at [http://contributor-covenant.org/version/1/4][version]
4444

4545
[homepage]: http://contributor-covenant.org
4646
[version]: http://contributor-covenant.org/version/1/4/

Pipfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
django = "<2.0,>=1.11"
7+
django = "<2.1,>=2.0"
88
pillow = "*"
99
coveralls = "*"
1010
dateparser = "*"
1111
django-cors-headers = "*"
1212
django-crispy-forms = "*"
1313
django-extensions = "*"
1414
django-filter = "*"
15-
django-flat-responsive = "*"
1615
djangorestframework = "*"
1716
factory-boy = "*"
1817
filemagic = "*"

Pipfile.lock

Lines changed: 4 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/changelog.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
#########
33

4+
2.2.0
5+
=====
6+
7+
* Thanks to `dadosch`_ and `Wolfgang Mader`_, this is the first version of
8+
Paperless that supports Django 2.0! As a result of their hard work, you can
9+
now also run Paperless on Python 3.7 as well: `#386`_ & `#390`_.
10+
* `Stéphane Brunner`_ added a few lines of code that made tagging interface a lot
11+
easier on those of us with lots of different tags: `#391`_.
12+
* `Kilian Koeltzsch`_ noticed a bug in how we capture & automatically create
13+
tags, so that's fixed now too: `#384`_.
14+
415
2.1.0
516
=====
617

@@ -451,6 +462,10 @@ bulk of the work on this big change.
451462
.. _mcronce: https://github.com/mcronce
452463
.. _Enno Lohmeier: https://github.com/elohmeier
453464
.. _Mark McFate: https://github.com/SummittDweller
465+
.. _dadosch: https://github.com/dadosch
466+
.. _Wolfgang Mader: https://github.com/wmader
467+
.. _Stéphane Brunner: https://github.com/sbrunner
468+
.. _Kilian Koeltzsch: https://github.com/kiliankoe
454469

455470
.. _#20: https://github.com/danielquinn/paperless/issues/20
456471
.. _#44: https://github.com/danielquinn/paperless/issues/44
@@ -525,6 +540,10 @@ bulk of the work on this big change.
525540
.. _#374: https://github.com/danielquinn/paperless/pull/374
526541
.. _#375: https://github.com/danielquinn/paperless/pull/375
527542
.. _#376: https://github.com/danielquinn/paperless/pull/376
543+
.. _#384: https://github.com/danielquinn/paperless/issues/384
544+
.. _#386: https://github.com/danielquinn/paperless/issues/386
545+
.. _#391: https://github.com/danielquinn/paperless/pull/391
546+
.. _#390: https://github.com/danielquinn/paperless/pull/390
528547

529548
.. _pipenv: https://docs.pipenv.org/
530549
.. _a new home on Docker Hub: https://hub.docker.com/r/danielquinn/paperless/

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ django-cors-headers==2.4.0
1111
django-crispy-forms==1.7.2
1212
django-extensions==2.1.2
1313
django-filter==2.0.0
14-
django-flat-responsive==2.0
15-
django==1.11.15
14+
django==2.0.8
1615
djangorestframework==3.8.2
1716
docopt==0.6.2
1817
execnet==1.5.0; python_version != '3.1.*'

src/documents/admin.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
from django.conf import settings
44
from django.contrib import admin
55
from django.contrib.auth.models import User, Group
6-
from django.core.urlresolvers import reverse
6+
try:
7+
from django.core.urlresolvers import reverse
8+
except ImportError:
9+
from django.urls import reverse
710
from django.templatetags.static import static
11+
from django.utils.safestring import mark_safe
12+
from django.utils.html import format_html, format_html_join
813

914
from .models import Correspondent, Tag, Document, Log
1015

@@ -178,7 +183,7 @@ def tags_(self, obj):
178183
)
179184
}
180185
)
181-
return r
186+
return mark_safe(r)
182187
tags_.allow_tags = True
183188

184189
def document(self, obj):
@@ -198,16 +203,13 @@ def document(self, obj):
198203

199204
@staticmethod
200205
def _html_tag(kind, inside=None, **kwargs):
201-
202-
attributes = []
203-
for lft, rgt in kwargs.items():
204-
attributes.append('{}="{}"'.format(lft, rgt))
206+
attributes = format_html_join(' ', '{}="{}"', kwargs.items())
205207

206208
if inside is not None:
207-
return "<{kind} {attributes}>{inside}</{kind}>".format(
208-
kind=kind, attributes=" ".join(attributes), inside=inside)
209+
return format_html("<{kind} {attributes}>{inside}</{kind}>",
210+
kind=kind, attributes=attributes, inside=inside)
209211

210-
return "<{} {}/>".format(kind, " ".join(attributes))
212+
return format_html("<{} {}/>", kind, attributes)
211213

212214

213215
class LogAdmin(CommonAdmin):

src/documents/filters.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class CorrespondentFilterSet(FilterSet):
77

8-
class Meta(object):
8+
class Meta:
99
model = Correspondent
1010
fields = {
1111
"name": [
@@ -18,7 +18,7 @@ class Meta(object):
1818

1919
class TagFilterSet(FilterSet):
2020

21-
class Meta(object):
21+
class Meta:
2222
model = Tag
2323
fields = {
2424
"name": [
@@ -42,15 +42,18 @@ class DocumentFilterSet(FilterSet):
4242
)
4343
}
4444

45-
correspondent__name = CharFilter(name="correspondent__name", **CHAR_KWARGS)
46-
correspondent__slug = CharFilter(name="correspondent__slug", **CHAR_KWARGS)
47-
tags__name = CharFilter(name="tags__name", **CHAR_KWARGS)
48-
tags__slug = CharFilter(name="tags__slug", **CHAR_KWARGS)
49-
tags__empty = BooleanFilter(name='tags',
50-
lookup_expr='isnull',
51-
distinct=True)
45+
correspondent__name = CharFilter(
46+
field_name="correspondent__name", **CHAR_KWARGS)
47+
correspondent__slug = CharFilter(
48+
field_name="correspondent__slug", **CHAR_KWARGS)
49+
tags__name = CharFilter(
50+
field_name="tags__name", **CHAR_KWARGS)
51+
tags__slug = CharFilter(
52+
field_name="tags__slug", **CHAR_KWARGS)
53+
tags__empty = BooleanFilter(
54+
field_name="tags", lookup_expr="isnull", distinct=True)
5255

53-
class Meta(object):
56+
class Meta:
5457
model = Document
5558
fields = {
5659
"title": [

src/documents/migrations/0003_sender.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def realign_senders(apps, schema_editor):
3232

3333

3434
class Migration(migrations.Migration):
35-
3635
dependencies = [
3736
('documents', '0002_auto_20151226_1316'),
3837
]

src/documents/migrations/0011_auto_20160303_1929.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Migration(migrations.Migration):
9-
9+
atomic = False
1010
dependencies = [
1111
('documents', '0010_log'),
1212
]

src/documents/migrations/0012_auto_20160305_0040.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def move_documents_and_create_thumbnails(apps, schema_editor):
112112

113113

114114
class Migration(migrations.Migration):
115-
116115
dependencies = [
117116
('documents', '0011_auto_20160303_1929'),
118117
]

src/documents/migrations/0014_document_checksum.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def do_nothing(apps, schema_editor):
128128

129129

130130
class Migration(migrations.Migration):
131-
132131
dependencies = [
133132
('documents', '0013_auto_20160325_2111'),
134133
]

src/documents/migrations/0019_add_consumer_user.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def reverse_func(apps, schema_editor):
1515

1616

1717
class Migration(migrations.Migration):
18-
1918
dependencies = [
2019
('documents', '0018_auto_20170715_1712'),
2120
]

src/documents/migrations/0020_document_added.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def set_added_time_to_created_time(apps, schema_editor):
1111
doc.added = doc.created
1212
doc.save()
1313

14-
class Migration(migrations.Migration):
1514

15+
class Migration(migrations.Migration):
1616
dependencies = [
1717
('documents', '0019_add_consumer_user'),
1818
]

src/documents/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from fuzzywuzzy import fuzz
1111

1212
from django.conf import settings
13-
from django.core.urlresolvers import reverse
13+
try:
14+
from django.core.urlresolvers import reverse
15+
except ImportError:
16+
from django.urls import reverse
1417
from django.db import models
1518
from django.template.defaultfilters import slugify
1619
from django.utils import timezone

src/documents/serialisers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
class CorrespondentSerializer(serializers.HyperlinkedModelSerializer):
77

8-
class Meta(object):
8+
class Meta:
99
model = Correspondent
1010
fields = ("id", "slug", "name")
1111

1212

1313
class TagSerializer(serializers.HyperlinkedModelSerializer):
1414

15-
class Meta(object):
15+
class Meta:
1616
model = Tag
1717
fields = (
1818
"id", "slug", "name", "colour", "match", "matching_algorithm")
@@ -34,7 +34,7 @@ class DocumentSerializer(serializers.ModelSerializer):
3434
view_name="drf:correspondent-detail", allow_null=True)
3535
tags = TagsField(view_name="drf:tag-detail", many=True)
3636

37-
class Meta(object):
37+
class Meta:
3838
model = Document
3939
fields = (
4040
"id",
@@ -57,7 +57,7 @@ class LogSerializer(serializers.ModelSerializer):
5757
time = serializers.DateTimeField()
5858
messages = serializers.CharField()
5959

60-
class Meta(object):
60+
class Meta:
6161
model = Log
6262
fields = (
6363
"time",

src/paperless/settings.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"reminders.apps.RemindersConfig",
6969
"paperless_tesseract.apps.PaperlessTesseractConfig",
7070

71-
"flat_responsive", # TODO: Remove as of Django 2.x
7271
"django.contrib.admin",
7372

7473
"rest_framework",
@@ -82,14 +81,13 @@
8281

8382

8483

85-
MIDDLEWARE_CLASSES = [
84+
MIDDLEWARE = [
8685
'django.middleware.security.SecurityMiddleware',
8786
'django.contrib.sessions.middleware.SessionMiddleware',
8887
'corsheaders.middleware.CorsMiddleware',
8988
'django.middleware.common.CommonMiddleware',
9089
'django.middleware.csrf.CsrfViewMiddleware',
9190
'django.contrib.auth.middleware.AuthenticationMiddleware',
92-
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
9391
'django.contrib.messages.middleware.MessageMiddleware',
9492
'django.middleware.clickjacking.XFrameOptionsMiddleware',
9593
]
@@ -99,9 +97,9 @@
9997

10098
# If auth is disabled, we just use our "bypass" authentication middleware
10199
if bool(os.getenv("PAPERLESS_DISABLE_LOGIN", "false").lower() in ("yes", "y", "1", "t", "true")):
102-
_index = MIDDLEWARE_CLASSES.index("django.contrib.auth.middleware.AuthenticationMiddleware")
103-
MIDDLEWARE_CLASSES[_index] = "paperless.middleware.Middleware"
104-
MIDDLEWARE_CLASSES.remove("django.contrib.auth.middleware.SessionAuthenticationMiddleware")
100+
_index = MIDDLEWARE.index("django.contrib.auth.middleware.AuthenticationMiddleware")
101+
MIDDLEWARE[_index] = "paperless.middleware.Middleware"
102+
MIDDLEWARE.remove("django.contrib.auth.middleware.SessionAuthenticationMiddleware")
105103

106104
ROOT_URLCONF = 'paperless.urls'
107105

src/paperless/urls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
# API
2929
url(
3030
r"^api/auth/",
31-
include('rest_framework.urls', namespace="rest_framework")
31+
include(
32+
('rest_framework.urls', 'rest_framework'),
33+
namespace="rest_framework")
3234
),
33-
url(r"^api/", include(router.urls, namespace="drf")),
35+
url(r"^api/", include((router.urls, 'drf'), namespace="drf")),
3436

3537
# File downloads
3638
url(

src/paperless/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = (2, 1, 0)
1+
__version__ = (2, 2, 0)

src/reminders/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
class Reminder(models.Model):
55

6-
document = models.ForeignKey("documents.Document")
6+
document = models.ForeignKey(
7+
"documents.Document", on_delete=models.PROTECT
8+
)
79
date = models.DateTimeField()
810
note = models.TextField(blank=True)

0 commit comments

Comments
 (0)