I've made my own LoginRequiredMixin like this:
class LoginRequiredMixin(object):
@classmethod
def as_view(cls, **initkwargs):
view = super(LoginRequiredMixin, cls).as_view(**initkwargs)
# (!!) multilangue = reverse_lazy, PAS reverse
return login_required(view, login_url=reverse_lazy('my_home_login'))
So far so good, everything works fine when you create new views like this:
class EditView(LoginRequiredMixin, generic.UpdateView):
model = Personne
template_name = 'my_home/profile/base.html'
form_class = ProfileForm
success_url = reverse_lazy('my_home_profile_edit')
and so on.
Now, my client asked me to implement an option: if the user wants to delete his account, I have to mark it as "inactive", sends an email with a re-activation link that is valid for 15 days and if the user tries to login in within those 15 days without having clicked on the re-activation link, I should display a message saying "your account has been disabled, please click on the link we sent".
So I want to implement the "inactive" account after the user is logged in, and display the "your account is disabled" message. Because I want to display it whatever the URL is (my profile, my travels, my buddies, my messages or whatever), I should do it in the LoginRequiredMixin class. The problem is: I dont know how to do it. For example, I need to override all template_name if there's one, and forbid every action but display the message.
How to do it?