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

Commit

Permalink
Merge branch 'dadosch-django-v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielquinn committed Sep 2, 2018
2 parents 218809c + d5180fe commit 0868390
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 56 deletions.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
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]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ verify_ssl = true
name = "pypi"

[packages]
django = "<2.0,>=1.11"
django = "<2.1,>=2.0"
pillow = "*"
coveralls = "*"
dateparser = "*"
django-cors-headers = "*"
django-crispy-forms = "*"
django-extensions = "*"
django-filter = "*"
django-flat-responsive = "*"
djangorestframework = "*"
factory-boy = "*"
filemagic = "*"
Expand Down
15 changes: 4 additions & 11 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
#########

2.2.0
=====

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

2.1.0
=====

Expand Down Expand Up @@ -451,6 +462,10 @@ bulk of the work on this big change.
.. _mcronce: https://github.com/mcronce
.. _Enno Lohmeier: https://github.com/elohmeier
.. _Mark McFate: https://github.com/SummittDweller
.. _dadosch: https://github.com/dadosch
.. _Wolfgang Mader: https://github.com/wmader
.. _Stéphane Brunner: https://github.com/sbrunner
.. _Kilian Koeltzsch: https://github.com/kiliankoe

.. _#20: https://github.com/danielquinn/paperless/issues/20
.. _#44: https://github.com/danielquinn/paperless/issues/44
Expand Down Expand Up @@ -525,6 +540,10 @@ bulk of the work on this big change.
.. _#374: https://github.com/danielquinn/paperless/pull/374
.. _#375: https://github.com/danielquinn/paperless/pull/375
.. _#376: https://github.com/danielquinn/paperless/pull/376
.. _#384: https://github.com/danielquinn/paperless/issues/384
.. _#386: https://github.com/danielquinn/paperless/issues/386
.. _#391: https://github.com/danielquinn/paperless/pull/391
.. _#390: https://github.com/danielquinn/paperless/pull/390

.. _pipenv: https://docs.pipenv.org/
.. _a new home on Docker Hub: https://hub.docker.com/r/danielquinn/paperless/
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ django-cors-headers==2.4.0
django-crispy-forms==1.7.2
django-extensions==2.1.2
django-filter==2.0.0
django-flat-responsive==2.0
django==1.11.15
django==2.0.8
djangorestframework==3.8.2
docopt==0.6.2
execnet==1.5.0; python_version != '3.1.*'
Expand Down
20 changes: 11 additions & 9 deletions src/documents/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User, Group
from django.core.urlresolvers 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.safestring import mark_safe
from django.utils.html import format_html, format_html_join

from .models import Correspondent, Tag, Document, Log

Expand Down Expand Up @@ -178,7 +183,7 @@ def tags_(self, obj):
)
}
)
return r
return mark_safe(r)
tags_.allow_tags = True

def document(self, obj):
Expand All @@ -198,16 +203,13 @@ def document(self, obj):

@staticmethod
def _html_tag(kind, inside=None, **kwargs):

attributes = []
for lft, rgt in kwargs.items():
attributes.append('{}="{}"'.format(lft, rgt))
attributes = format_html_join(' ', '{}="{}"', kwargs.items())

if inside is not None:
return "<{kind} {attributes}>{inside}</{kind}>".format(
kind=kind, attributes=" ".join(attributes), inside=inside)
return format_html("<{kind} {attributes}>{inside}</{kind}>",
kind=kind, attributes=attributes, inside=inside)

return "<{} {}/>".format(kind, " ".join(attributes))
return format_html("<{} {}/>", kind, attributes)


class LogAdmin(CommonAdmin):
Expand Down
23 changes: 13 additions & 10 deletions src/documents/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class CorrespondentFilterSet(FilterSet):

class Meta(object):
class Meta:
model = Correspondent
fields = {
"name": [
Expand All @@ -18,7 +18,7 @@ class Meta(object):

class TagFilterSet(FilterSet):

class Meta(object):
class Meta:
model = Tag
fields = {
"name": [
Expand All @@ -42,15 +42,18 @@ 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)
tags__empty = BooleanFilter(name='tags',
lookup_expr='isnull',
distinct=True)
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)

class Meta(object):
class Meta:
model = Document
fields = {
"title": [
Expand Down
1 change: 0 additions & 1 deletion src/documents/migrations/0003_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def realign_senders(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
('documents', '0002_auto_20151226_1316'),
]
Expand Down
2 changes: 1 addition & 1 deletion src/documents/migrations/0011_auto_20160303_1929.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Migration(migrations.Migration):

atomic = False
dependencies = [
('documents', '0010_log'),
]
Expand Down
1 change: 0 additions & 1 deletion src/documents/migrations/0012_auto_20160305_0040.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def move_documents_and_create_thumbnails(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
('documents', '0011_auto_20160303_1929'),
]
Expand Down
1 change: 0 additions & 1 deletion src/documents/migrations/0014_document_checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def do_nothing(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
('documents', '0013_auto_20160325_2111'),
]
Expand Down
1 change: 0 additions & 1 deletion src/documents/migrations/0019_add_consumer_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def reverse_func(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
('documents', '0018_auto_20170715_1712'),
]
Expand Down
2 changes: 1 addition & 1 deletion src/documents/migrations/0020_document_added.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def set_added_time_to_created_time(apps, schema_editor):
doc.added = doc.created
doc.save()

class Migration(migrations.Migration):

class Migration(migrations.Migration):
dependencies = [
('documents', '0019_add_consumer_user'),
]
Expand Down
5 changes: 4 additions & 1 deletion src/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from fuzzywuzzy import fuzz

from django.conf import settings
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError:
from django.urls import reverse
from django.db import models
from django.template.defaultfilters import slugify
from django.utils import timezone
Expand Down
8 changes: 4 additions & 4 deletions src/documents/serialisers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

class CorrespondentSerializer(serializers.HyperlinkedModelSerializer):

class Meta(object):
class Meta:
model = Correspondent
fields = ("id", "slug", "name")


class TagSerializer(serializers.HyperlinkedModelSerializer):

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

class Meta(object):
class Meta:
model = Document
fields = (
"id",
Expand All @@ -57,7 +57,7 @@ class LogSerializer(serializers.ModelSerializer):
time = serializers.DateTimeField()
messages = serializers.CharField()

class Meta(object):
class Meta:
model = Log
fields = (
"time",
Expand Down
10 changes: 4 additions & 6 deletions src/paperless/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"reminders.apps.RemindersConfig",
"paperless_tesseract.apps.PaperlessTesseractConfig",

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

"rest_framework",
Expand All @@ -82,14 +81,13 @@



MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Expand All @@ -99,9 +97,9 @@

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

ROOT_URLCONF = 'paperless.urls'

Expand Down
6 changes: 4 additions & 2 deletions src/paperless/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
# API
url(
r"^api/auth/",
include('rest_framework.urls', namespace="rest_framework")
include(
('rest_framework.urls', 'rest_framework'),
namespace="rest_framework")
),
url(r"^api/", include(router.urls, namespace="drf")),
url(r"^api/", include((router.urls, 'drf'), namespace="drf")),

# File downloads
url(
Expand Down
2 changes: 1 addition & 1 deletion src/paperless/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = (2, 1, 0)
__version__ = (2, 2, 0)
4 changes: 3 additions & 1 deletion src/reminders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class Reminder(models.Model):

document = models.ForeignKey("documents.Document")
document = models.ForeignKey(
"documents.Document", on_delete=models.PROTECT
)
date = models.DateTimeField()
note = models.TextField(blank=True)

0 comments on commit 0868390

Please sign in to comment.