forked from enviPath/enviPy
Implement Admin approval (#29)
This PR fixes #7 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#29
This commit is contained in:
@ -4,6 +4,7 @@ from typing import Union, List, Optional, Set, Dict
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import transaction
|
||||
from django.conf import settings as s
|
||||
|
||||
from epdb.models import User, Package, UserPackagePermission, GroupPackagePermission, Permission, Group, Setting, \
|
||||
EPModel, UserSettingPermission, Rule, Pathway, Node, Edge
|
||||
@ -12,11 +13,15 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class UserManager(object):
|
||||
@staticmethod
|
||||
def create_user(username, email, password):
|
||||
def create_user(username, email, password, *args, **kwargs):
|
||||
# avoid circular import :S
|
||||
from .tasks import send_registration_mail
|
||||
# TODO flip to False
|
||||
u = get_user_model().objects.create_user(username, email, password, is_active=True)
|
||||
|
||||
is_active = not s.ADMIN_APPROVAL_REQUIRED
|
||||
if 'is_active' in kwargs:
|
||||
is_active = kwargs['is_active']
|
||||
|
||||
u = get_user_model().objects.create_user(username, email, password, is_active=is_active)
|
||||
|
||||
# Create package
|
||||
package_name = f"{u.username}{'’' if u.username[-1] in 'sxzß' else 's'} Package"
|
||||
|
||||
Reference in New Issue
Block a user