@@ -55,17 +55,25 @@ def __call__(self, model_admin, request, *args, **kwargs):
5555
5656
5757class 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