2020-07-13 11:30:18 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
2020-09-27 06:42:01 +00:00
|
|
|
from django.core.exceptions import PermissionDenied
|
|
|
|
|
2020-07-13 11:30:18 +00:00
|
|
|
from . import app_settings
|
|
|
|
|
|
|
|
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
|
|
|
|
def get_user_queryset(queryset, view):
|
2020-07-13 13:08:46 +00:00
|
|
|
custom_func = app_settings.GET_USER_QUERYSET_FUNC
|
2020-07-13 11:30:18 +00:00
|
|
|
if custom_func is not None:
|
|
|
|
return custom_func(queryset, view)
|
|
|
|
return queryset
|
2020-07-13 13:20:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
def create_user(*args, **kwargs):
|
|
|
|
custom_func = app_settings.CREATE_USER_FUNC
|
|
|
|
if custom_func is not None:
|
|
|
|
return custom_func(*args, **kwargs)
|
2020-11-14 15:04:41 +00:00
|
|
|
_ = kwargs.pop("view")
|
2020-07-13 13:20:46 +00:00
|
|
|
return User.objects.create_user(*args, **kwargs)
|
2020-09-27 06:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def create_user_blocked(*args, **kwargs):
|
2020-11-14 15:04:41 +00:00
|
|
|
raise PermissionDenied("Signup is disabled for this server. Please refer to the README for more information.")
|