Django - What is the best way to have multi level status before login
<p>I have one scenario, there is a user registration and it should have multiple status(may be is_active - but this is boolean by default)</p>

<ol>
<li>List item Code - 0 -> Pending for Email Confirmation</li>
<li>List item Code - 1 -> Account Activated/Active(Only after email confirmed admin will approve it)</li>
<li>List item Code - 2 -> Email Confirmed</li>
</ol>

<p>I am using django allauth, I was browsing to achieve it, but unable to find some close match of it. For your info I also have <code>Profile OnetoOne model for User model</code></p>

<p><strong>Updated</strong> </p>

<pre><code>class CustomConfirmEmailView(ConfirmEmailView):
    def get(self):
        raise Exception('GET')
    def post(self,*args,**kwargs):
        raise Exception('POST')
</code></pre>

<p><strong>Settings file</strong></p>

<pre><code>ACCOUNT_CONFIRM_EMAIL_ON_GET = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
</code></pre>

<p>You should create custom <code>User</code> or custom <code>Profile</code>(i believe that it's better with custom <code>Profile</code>, to avoid messing with django <code>User</code>):</p>

<pre><code>from itertools import compress

class CustomProfile(Profile):
    is_confirmed = models.BooleanField(default=False)

    @property
    def status(self):
        return next(compress(['Pending', 'Active', 'Confirmed'], 
                             [not self.is_confirmed, not self.is_confirmed and self.user.is_active, self.confirmed and self.user.is_active]))
</code></pre>

<p>You can see that i added <code>@property</code> that would answer your question about user status.</p>

<p>But for setting <code>is_confirmed</code> you need to look at the sources, <a href="http://django-allauth.readthedocs.io/en/latest/views.html#e-mail-verification" rel="nofollow">docs</a> lead you to <a href="https://github.com/pennersr/django-allauth/blob/master/allauth/account/views.py#L225" rel="nofollow"><code>allauth.account.views.ConfirmEmailView</code></a> view.</p>

<p>And i think that you need to override <code>post</code> method.</p>

<pre><code>class CustomConfirmEmailView(ConfirmEmailView):
    def post(self, *args, **kwargs):
        self.object = confirmation = self.get_object()
        confirmation.confirm(self.request)
        get_adapter(self.request).add_message(
            self.request,
            messages.SUCCESS,
            'account/messages/email_confirmed.txt',
            {'email': confirmation.email_address.email})
        if app_settings.LOGIN_ON_EMAIL_CONFIRMATION:
            resp = self.login_on_confirm(confirmation)
            if resp is not None:
                return resp
        profile = confirmation.email_address.user.profile
        profile.is_confirmed = True
        profile.save()
        redirect_url = self.get_redirect_url()
        if not redirect_url:
            ctx = self.get_context_data()
            return self.render_to_response(ctx)
        return redirect(redirect_url)
</code></pre>

<p>And then you need to put that View in url.</p>

<p>That's it. Sure i didn't run it. But the logic is here.</p>

python django