def post_save_user(sender, instance, **kwargs): """ This signal is event of model user for create new profile. """ if kwargs['created']: subclasses = models.AbstractProfile.__subclasses__() if len(subclasses) > 0: User = get_user_model() user = User.objects.get(id=instance.id) Profile = subclasses[0] # For confirm email data = utils.get_data_confirm_email(user.email) # Insert profile profile = Profile(iduser=user, photo="", about="", activation_key=data['activation_key'], key_expires=data['key_expires']) profile.save() # Send email for confirm user utils.send_welcome_email(user.email, user.username, data['activation_key'])
def post(self, request, username, *args, **kwargs): if request.user.is_authenticated(): return redirect("forums") User = get_user_model() user = get_object_or_404(User, username=username) email = user.email # For confirm email data = utils.get_data_confirm_email(email) # Update activation key profile = get_object_or_404(models.Profile, iduser=user) profile.activation_key = data['activation_key'] profile.key_expires = data['key_expires'] profile.save() # Send email for confirm user utils.send_welcome_email(email, username, data['activation_key']) data = {'username': username, 'new_key': True} return render(request, self.template_name, data)
def post_save_user(sender, instance, **kwargs): """ This signal is event of model user for create new profile. """ if kwargs['created']: User = get_user_model() user = User.objects.get(id=instance.id) # For confirm email data = utils.get_data_confirm_email(user.email) # Insert profile profile = models.Profile( iduser=user, photo="", about="", location="", activation_key=data['activation_key'], key_expires=data['key_expires'] ) profile.save() # Send email for confirm user utils.send_welcome_email( user.email, user.username, data['activation_key'] )