Hello Keegan,

although I am no sure how my code will help you with your issue no problem 
to post it:

My custom '' signup"

def signup2(request, template="accounts/account_signup.html",
           extra_context=None, verify_mail="signup_verify", attachments=[]):
    """
    Custom Signup form.

    This is basically a copy of 'accounts/views/signup' from Mezzanine.
    Added were the possibilities to pass the required mail template as an
    argument and to pass attachments. For sending the verification mail 
    a customized method is called.

    Attachments are passed as an iterable of filenames / paths, relative
    to the MEDIA_ROOT directory.
    """
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(request, _("Thanks for signing up! You'll receive "
                                "an email when your account is activated."))
            else:
                atts = []
                for fn in attachments:
                    with open(os.path.join(settings.MEDIA_ROOT, fn), 'rb') 
as prop_file:
                        prop_data = prop_file.read()
                    name = fn.split('/')[-1]
                    atts.append((name, prop_data))
                send_verification_mail(request, new_user, "signup_verify", 
                                       verify_mail=verify_mail,
                                       attachments = atts)
                info(request, _("A verification email has been sent with "
                                "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)

... and the custom "send_verification_mail" function:

def send_verification_mail(request, user, verification_type, 
                           verify_mail=None, attachments=[]):
    """
    Sends an email with a verification link to users when
    ``ACCOUNTS_VERIFICATION_REQUIRED`` is ```True`` and they're signing
    up, or when they reset a lost password.
    The ``verification_type`` arg is both the name of the urlpattern for
    the verification link, as well as the names of the email templates
    to use.

    This is basically a copy of the function with the same name in 
    the "utils.email" module. This function allows passing the template
    as a parameter and sending attachments.
    """
    if verify_mail is None:
        verify_mail = verification_type

    verify_url = reverse(verification_type, kwargs={
        "uidb36": int_to_base36(user.id),
        "token": default_token_generator.make_token(user),
    }) + "?next=" + (next_url(request) or "/")
    context = {
        "request": request,
        "user": user,
        "verify_url": verify_url,
    }
    subject_template_name = "email/%s_subject.txt" % verification_type
    subject = subject_template(subject_template_name, context)
    send_mail_template(subject, "email/%s" % verify_mail,
                       settings.DEFAULT_FROM_EMAIL, user.email,
                       attachments=attachments, context=context)

Regards

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to