def user_delete_view(request): if request.POST: users = tools.get_all_users_of_account(request.user) user = User.objects.get(id=request.POST['id']) if user in users: user.delete() tools.delete_log_entries(user.email) else: return Http404 return HttpResponseRedirect('/')
def user_activate_view(request, key): try: username = base64.urlsafe_b64decode(key.encode('utf-8')) user = User.objects.get(username=username) user.is_active = True user.save() messages.success(request, 'The user %s was successfully activated.' % user.email) tools.delete_log_entries(user.email) except: messages.error(request, 'The user could not be activated.') return HttpResponseRedirect('/')
def user_connect_view(request, key, account_id): try: account = Account.objects.get(pk=account_id) username = base64.urlsafe_b64decode(key.encode('utf-8')) user = User.objects.get(username=username) old_account = user.userprofile.account user.userprofile.account = account user.userprofile.save() old_account.delete() messages.success( request, 'The user %s was successfully connected with this account.' % user.email) tools.delete_log_entries(user.email) except: messages.error(request, 'The user could not be connected.') return HttpResponseRedirect('/')