Skip to content

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

Rejiggering for more pycodestyle issues...

Matt4bde14368c0e
diff --git a/src/paperless/middleware.py b/src/paperless/middleware.py
index c2a74cc51..8fed7da8f 100644
--- a/src/paperless/middleware.py
+++ b/src/paperless/middleware.py
@@ -1,14 +1,14 @@
from django.utils.deprecation import MiddlewareMixin
from .models import User
+
class Middleware (MiddlewareMixin):
"""
This is a dummy authentication middleware class that creates what
is roughly an Anonymous authenticated user so we can disable login
- and not interfere with existing user ID's. It's only used if
+ and not interfere with existing user ID's. It's only used if
login is disabled in paperless.conf (default is to require login)
"""
def process_request(self, request):
request.user = User()
-
diff --git a/src/paperless/models.py b/src/paperless/models.py
index 1728d6822..4001d3468 100644
--- a/src/paperless/models.py
+++ b/src/paperless/models.py
@@ -7,13 +7,20 @@ class User:
is_active = True
is_staff = True
is_authenticated = True
- has_module_perms = lambda *_: True
- has_perm = lambda *_: True
- #Must be -1 to avoid colliding with real user ID's (which start at 1)
+ # Must be -1 to avoid colliding with real user ID's (which start at 1)
id = -1
@property
def pk(self):
- return self.id
-
+ return self.id
+
+
+"""
+ NOTE: These are here as a hack instead of being in the User definition
+ above due to the way pycodestyle handles lamdbdas.
+ See https://github.com/PyCQA/pycodestyle/issues/379 for more.
+"""
+
+User.has_module_perms = lambda *_: True
+User.has_perm = lambda *_: True