Skip to content

Commit 91201b1

Browse files
committed
Merge branch 'release/1.5.3'
* release/1.5.3: Bump version: 1.5.2 → 1.5.3 customise view authentication handler bug fixes
2 parents 632a281 + 2140ab6 commit 91201b1

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.5.2
2+
current_version = 1.5.3
33
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
44
serialize = {major}.{minor}.{patch}
55
commit = True

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.5.3
2+
-----
3+
* bug fixing
4+
* add ability to customise view authentication handler
5+
6+
17
1.5.2
28
-----
39
* bug fixing
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
NAME = 'django-admin-extra-buttons'
2-
VERSION = __version__ = '1.5.2'
2+
VERSION = __version__ = '1.5.3'
33
__author__ = 'sax'

src/admin_extra_buttons/buttons.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ def enabled(self):
7676
try:
7777
return self._enabled(self)
7878
except Exception: # pragma: no cover
79-
raise
8079
return False
8180

8281
return self._enabled
8382

83+
@property
84+
def model_admin(self):
85+
return self.handler.model_admin
86+
8487
@property
8588
def visible(self):
8689
if not self.context: # pragma: no cover

src/admin_extra_buttons/handlers.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,25 @@ def __call__(self, model_admin, request, *args, **kwargs):
5555

5656

5757
class ViewHandler(BaseExtraHandler):
58-
def __init__(self, func, login_required=True, http_basic_auth=False, **kwargs):
58+
def __init__(self, func, login_required=True, http_basic_auth=False, http_auth_handler=None, **kwargs):
5959
self.login_required = login_required
60-
self.http_basic_auth = http_basic_auth
60+
if http_auth_handler:
61+
if http_basic_auth:
62+
raise ValueError("'http_basic_auth' and 'http_auth_handler' are mutually exclusive")
63+
self.http_auth_handler = http_auth_handler
64+
else:
65+
self.http_basic_auth = http_basic_auth
66+
self.http_auth_handler = handle_basic_auth
6167
super().__init__(func,
68+
http_auth_handler=http_auth_handler,
6269
http_basic_auth=http_basic_auth,
6370
login_required=login_required,
6471
**kwargs)
6572

6673
def __call__(self, model_admin, request, *args, **kwargs):
74+
self.model_admin = model_admin
6775
if self.login_required and self.http_basic_auth and not request.user.is_authenticated:
68-
handle_basic_auth(request)
76+
self.http_auth_handler(request)
6977
return super().__call__(model_admin, request, *args, **kwargs)
7078

7179
@cached_property

0 commit comments

Comments
 (0)