Commit 06cc5092 authored by David Haynes's avatar David Haynes 🙆
Browse files

Merge branch 'issue85' into 'master'

Issue85

See merge request !50
parents a43612f9 875af15c
Pipeline #598 passed with stage
in 1 minute and 24 seconds
...@@ -314,17 +314,16 @@ def useradmin(request): ...@@ -314,17 +314,16 @@ def useradmin(request):
if request.POST: if request.POST:
# Get a list of the potential victims (users) # Get a list of the potential victims (users)
userlist = request.POST.getlist('username') userlist = request.POST.getlist('username')
# If we're approving users # If we're approving users
if '_approve' in request.POST: if '_approve' in request.POST:
for name in userlist: for name in userlist:
toapprove = RegisteredUser.objects.get(user__username__exact=name) toApprove = RegisteredUser.objects.get(user__username__exact=name)
toapprove.approved = True toApprove.approved = True
toapprove.save() toApprove.save()
# Send an email letting them know they are approved # Send an email letting them know they are approved
if settings.EMAIL_HOST and settings.EMAIL_PORT: if settings.EMAIL_HOST and settings.EMAIL_PORT:
user_mail = toapprove.user.username + settings.EMAIL_DOMAIN user_mail = toApprove.user.username + settings.EMAIL_DOMAIN
send_mail( send_mail(
'Your Account has been Approved!', 'Your Account has been Approved!',
###################### ######################
...@@ -333,7 +332,7 @@ def useradmin(request): ...@@ -333,7 +332,7 @@ def useradmin(request):
'approved you to use Go!\n\n' 'approved you to use Go!\n\n'
'Head over to go.gmu.edu to create your first address.\n\n' 'Head over to go.gmu.edu to create your first address.\n\n'
'- Go Admins' '- Go Admins'
% (str(toapprove.full_name)), % (str(toApprove.full_name)),
###################### ######################
settings.EMAIL_FROM, settings.EMAIL_FROM,
[user_mail] [user_mail]
...@@ -341,9 +340,9 @@ def useradmin(request): ...@@ -341,9 +340,9 @@ def useradmin(request):
# If we're denying users # If we're denying users
elif '_deny' in request.POST: elif '_deny' in request.POST:
for name in userlist: for name in userlist:
todeny = RegisteredUser.objects.get(user__username__exact=name) toDeny = RegisteredUser.objects.get(user__username__exact=name)
if settings.EMAIL_HOST and settings.EMAIL_PORT: if settings.EMAIL_HOST and settings.EMAIL_PORT:
user_mail = todeny.user.username + settings.EMAIL_DOMAIN user_mail = toDeny.user.username + settings.EMAIL_DOMAIN
# Send an email letting them know they are denied # Send an email letting them know they are denied
send_mail( send_mail(
...@@ -355,19 +354,20 @@ def useradmin(request): ...@@ -355,19 +354,20 @@ def useradmin(request):
'Please reach out to srct@gmu.edu to appeal ' 'Please reach out to srct@gmu.edu to appeal '
'this decision.\n\n' 'this decision.\n\n'
'- Go Admins' '- Go Admins'
% (str(todeny.full_name)), % (str(toDeny.full_name)),
###################### ######################
settings.EMAIL_FROM, settings.EMAIL_FROM,
[user_mail] [user_mail]
) )
# Delete their associated RegisteredUsers # Delete their associated RegisteredUsers
todeny.user.delete() toDeny.user.delete()
return HttpResponseRedirect('useradmin') return HttpResponseRedirect('useradmin')
# If we're blocking users
elif '_block' in request.POST: elif '_block' in request.POST:
for name in userlist: for name in userlist:
toblock = RegisteredUser.objects.get(user__username__exact=name) toBlock = RegisteredUser.objects.get(user__username__exact=name)
if settings.EMAIL_HOST and settings.EMAIL_PORT: if settings.EMAIL_HOST and settings.EMAIL_PORT:
user_mail = toblock.user.username + settings.EMAIL_DOMAIN user_mail = toBlock.user.username + settings.EMAIL_DOMAIN
send_mail( send_mail(
'Your Account has been Blocked!', 'Your Account has been Blocked!',
###################### ######################
...@@ -377,45 +377,47 @@ def useradmin(request): ...@@ -377,45 +377,47 @@ def useradmin(request):
'Please reach out to srct@gmu.edu to appeal ' 'Please reach out to srct@gmu.edu to appeal '
'this decision.\n\n' 'this decision.\n\n'
'- Go Admins' '- Go Admins'
% (str(toblock.full_name)), % (str(toBlock.full_name)),
###################### ######################
settings.EMAIL_FROM, settings.EMAIL_FROM,
[user_mail] [user_mail]
) )
# toblock.user.delete() # toBlock.user.delete()
toblock.blocked = True toBlock.blocked = True
toblock.approved = False toBlock.approved = False
toblock.registered = False toBlock.registered = False
toblock.save() toBlock.save()
# If we're un-blocking users
elif '_unblock' in request.POST: elif '_unblock' in request.POST:
for name in userlist: for name in userlist:
toUNblock = RegisteredUser.objects.get(user__username__exact=name) toUnBlock = RegisteredUser.objects.get(user__username__exact=name)
if settings.EMAIL_HOST and settings.EMAIL_PORT: if settings.EMAIL_HOST and settings.EMAIL_PORT:
user_mail = toUNblock.user.username + settings.EMAIL_DOMAIN user_mail = toUnBlock.user.username + settings.EMAIL_DOMAIN
send_mail( send_mail(
'Your Account has been Blocked!', 'Your Account has been Un-Blocked!',
###################### ######################
'Hey there %s,\n\n' 'Hey there %s,\n\n'
'The Go admins have reviewed your application and have ' 'The Go admins have reviewed your application and have '
'unblocked you from using Go.\n\n' 'Un-Blocked you from using Go.\n\n'
'If you wish to continue Go use please register again. \n\n' 'If you wish to continue Go use please register again. \n\n'
'Congratulations! ' 'Congratulations! '
'- Go Admins' '- Go Admins'
% (str(toblock.full_name)), % (str(toUnBlock.full_name)),
###################### ######################
settings.EMAIL_FROM, settings.EMAIL_FROM,
[user_mail] [user_mail]
) )
toUNblock.user.delete() # toUNblock.user.delete()
toUnBlock.blocked = False
toUnBlock.save()
return HttpResponseRedirect('useradmin') return HttpResponseRedirect('useradmin')
# toUNblock.blocked = False
# toUNblock.approved = False # If we're removing existing users
# toUNblock.save()
elif '_remove' in request.POST: elif '_remove' in request.POST:
for name in userlist: for name in userlist:
toremove = RegisteredUser.objects.get(user__username__exact=name) toRemove = RegisteredUser.objects.get(user__username__exact=name)
if settings.EMAIL_HOST and settings.EMAIL_PORT: if settings.EMAIL_HOST and settings.EMAIL_PORT:
user_mail = toremove.user.username + settings.EMAIL_DOMAIN user_mail = toRemove.user.username + settings.EMAIL_DOMAIN
send_mail( send_mail(
'Your Account has been Deleted!', 'Your Account has been Deleted!',
###################### ######################
...@@ -424,17 +426,17 @@ def useradmin(request): ...@@ -424,17 +426,17 @@ def useradmin(request):
'Please reach out to srct@gmu.edu to appeal ' 'Please reach out to srct@gmu.edu to appeal '
'this decision.\n\n' 'this decision.\n\n'
'- Go Admins' '- Go Admins'
% (str(toremove.full_name)), % (str(toRemove.full_name)),
###################### ######################
settings.EMAIL_FROM, settings.EMAIL_FROM,
[user_mail] [user_mail]
) )
toremove.user.delete() toRemove.user.delete()
return HttpResponseRedirect('useradmin') return HttpResponseRedirect('useradmin')
# Get a list of all RegisteredUsers tthat need to be approved # Get a list of all RegisteredUsers that need to be approved
need_approval = RegisteredUser.objects.filter(registered=True).filter(approved=False) need_approval = RegisteredUser.objects.filter(registered=True).filter(approved=False)
current_users = RegisteredUser.objects.filter(approved=True).filter(registered=True) current_users = RegisteredUser.objects.filter(approved=True).filter(registered=True).filter(blocked=False)
blocked_users = RegisteredUser.objects.filter(blocked=True) blocked_users = RegisteredUser.objects.filter(blocked=True)
# Pass that list to the template # Pass that list to the template
......
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