Reputation: 1171
In my web app I am using django-allauth for account management.
If a user gets signed up in my app they will get an email with "confirmation link".(without confirming email they can login but wont get full rights).
Now I want to delay the sending of confirmation email as mean while they can perform some actions which results in updates in a table. If user do those actions( if table gets updated) then only I need to send that confirmation email .I am thinking to use signals here.
from django.db import models
from django.contrib.auth.models import User
from allauth.account.signals import user_signed_up
from allauth.account.utils import send_email_confirmation
from django.dispatch import receiver
import datetime
#this signal will be called when user signs up.
@receiver(user_signed_up, dispatch_uid="some.unique.string.id.for.allauth.user_signed_up")
def user_signed_up_(request, user, **kwargs):
send_email_confirmation(request, user, signup=True)
#this allauth util method, which sends confirmation email to user.
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
are_u_intrested = models.BooleanField(default=False)
models.signals.post_save.connect(user_signed_up_, sender=UserProfile, dispatch_uid="update_stock_count")
#If user fills this userProfile , then I only send confirmation mail.
#If UserProfile model instace saved , then it send post_save signal.
Upvotes: 0
Views: 1229
Reputation: 5871
EDIT-
One way I could think of was to set ACCOUNT_EMAIL_VERIFICATION
to "none"
, and then call allauths send_email_confirmation
method once the user has added those fields to the database.
Upvotes: 3