Commit 33188c4a authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

have access to group PendingAccountUser's name

parent 4427bd3e
Pipeline #45826 passed with stage
in 57 seconds
......@@ -28,6 +28,10 @@ from basetheme_bootstrap.forms import UserCreationFormWithMore, \
logger = logging.getLogger(__name__)
__PENDING_ACCOUNT_USER = "PendingAccountUser"
def get_pending_account_user_group_name():
return __PENDING_ACCOUNT_USER
def about_page(request):
context = {}
......@@ -67,10 +71,10 @@ def signup(request):
user.is_superuser = True
user.is_staff = True
user.is_active = True
Group.objects.get_or_create(name="PendingAccountUser")
Group.objects.get_or_create(name=__PENDING_ACCOUNT_USER)
else:
if not auto_active:
g, created = Group.objects.get_or_create(name="PendingAccountUser")
g, created = Group.objects.get_or_create(name=__PENDING_ACCOUNT_USER)
user.groups.add(g)
user.is_active = auto_active
user.save()
......@@ -88,7 +92,7 @@ def signup(request):
login(request, user)
return redirect('home')
else:
user = get_user_model().objects.filter(groups__name="PendingAccountUser",
user = get_user_model().objects.filter(groups__name=__PENDING_ACCOUNT_USER,
email=request.POST['email']).first()
if user is not None:
send_account_created(request, user, auto_active=not is_validating_email())
......@@ -240,10 +244,10 @@ def activate(request, uidb64, token):
user = get_user_model().objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, get_user_model().DoesNotExist):
user = None
if user is not None and user.groups.filter(name="PendingAccountUser").exists():
if user is not None and user.groups.filter(name=__PENDING_ACCOUNT_USER).exists():
if tokens.account_activation_token.check_token(user, token):
user.is_active = True
user.groups.remove(user.groups.get(name="PendingAccountUser"))
user.groups.remove(user.groups.get(name=__PENDING_ACCOUNT_USER))
user.save()
login(request, user)
# return redirect('home')
......
......@@ -7,7 +7,7 @@ readme = open('README.rst').read()
setup(
name='django-basetheme-bootstrap',
version='0.2.52',
version='0.2.53',
description='Django Basetheme Bootstrap',
long_description=readme,
author='Bryan Brancotte',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment