def me_account_del_view(request, template_name="dtr5app/account_del.html"): """delete all account data.""" if request.method in ["POST"]: request.user.profile.reset_all_and_save() request.user.subs.all().delete() request.user.flags_sent.all().delete() request.user.flags_received.all().delete() # if user's last_login is None means they have not activated their # account or have deleted it. either way, treat it as if it doesn't # exist. request.user.last_login = None # can be None since dj 1.8 # request.user.date_joined = None # can't be None, so leave it # # Setting an account to "is_active = False" will prevent the user from # using the same reddit account to sign up again. If "is_active = True" # then the user will be able to sign up again, using the same reddit # account. ~~request.user.is_active = False~~ # request.user.save() api.delete_token(request) messages.success(request, 'All account data was deleted.') return redirect(request.POST.get('next', settings.LOGIN_URL)) ctx = {} return render_to_response(template_name, ctx, context_instance=RequestContext(request))
def me_account_del_view(request, template_name='dtr5app/account_del.html'): """ Delete all account data. """ if request.method in ["POST"]: # fetch all of this users matches and discount them from the other # users match counts. currently, it can happen that a user sees a # match in the "upvote matches" header, but that match was from a # deleted user who doesn't exist anymore. qs = get_matches_user_queryset(request.user) qs = qs.prefetch_related('profile') for match_user in qs: if match_user.profile.matches_count > 0: match_user.profile.matches_count -= 1 match_user.profile.save() # remove all data request.user.profile.reset_all_and_save() request.user.subs.all().delete() request.user.flags_sent.all().delete() request.user.flags_received.all().delete() # if user's last_login is None means they have not activated their # account or have deleted it. either way, treat it as if it doesn't # exist. request.user.last_login = None # can be None since dj 1.8 # request.user.date_joined = None # can't be None, so leave it # # Setting an account to "is_active = False" will prevent the user from # using the same reddit account to sign up again. If "is_active = True" # then the user will be able to sign up again, using the same reddit # account. ~~request.user.is_active = False~~ # request.user.save() api.delete_token(request) messages.success(request, 'All account data was deleted.') if request.is_ajax(): return HttpResponse() # HTTP 200 return redirect(request.POST.get('next', settings.LOGIN_URL)) ctx = {} kwargs = {'context_instance': RequestContext(request)} return render_to_response(template_name, ctx, **kwargs)
def me_account_del_view(request, template_name="dtr5app/account_del.html"): """ Delete all account data. """ if request.method in ["POST"]: # fetch all of this users matches and discount them from the other # users match counts. currently, it can happen that a user sees a # match in the "upvote matches" header, but that match was from a # deleted user who doesn't exist anymore. qs = get_matches_user_queryset(request.user) qs = qs.prefetch_related("profile") for match_user in qs: if match_user.profile.matches_count > 0: match_user.profile.matches_count -= 1 match_user.profile.save() # remove all data request.user.profile.reset_all_and_save() request.user.subs.all().delete() request.user.flags_sent.all().delete() request.user.flags_received.all().delete() # if user's last_login is None means they have not activated their # account or have deleted it. either way, treat it as if it doesn't # exist. request.user.last_login = None # can be None since dj 1.8 # request.user.date_joined = None # can't be None, so leave it # # Setting an account to "is_active = False" will prevent the user from # using the same reddit account to sign up again. If "is_active = True" # then the user will be able to sign up again, using the same reddit # account. ~~request.user.is_active = False~~ # request.user.save() api.delete_token(request) messages.success(request, "All account data was deleted.") if request.is_ajax(): return HttpResponse() # HTTP 200 return redirect(request.POST.get("next", settings.LOGIN_URL)) return render(request, template_name)