예제 #1
0
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'])
예제 #2
0
파일: views.py 프로젝트: yeawin/webcms
    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)
예제 #3
0
    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)
예제 #4
0
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']
        )