Пример #1
0
def _sendSubsriptionEmail(user, action):
    '''Common functionality to send email to the CoG mailing list.'''
    
    # [email protected]
    toAddress = settings.COG_MAILING_LIST.replace('@','-request@')
    # subscribe address=<email address>
    subject = '%s address=%s' % (action, user.email)
    # body
    message = ''
    
    print 'Sending subscription email: To=%s Subject=%s' % (toAddress, subject)
    sendEmail(toAddress, subject, message, fromAddress=user.email)
Пример #2
0
def user_reminder(request):
    
    # redirect to another node if necessary
    if redirectToIdp():
        return HttpResponseRedirect(settings.IDP_REDIRECT + request.path)

    if request.method == 'GET':
        form = UsernameReminderForm()
        return render_user_reminder_form(request, form)

    else:
        form = UsernameReminderForm(request.POST)

        if form.is_valid():
            email = form.cleaned_data.get('email')

            # look up username
            users = User.objects.filter(email__iexact=email)

            # user in this context is an account. There can be more than one account associated with an email
            if len(users) > 0:

                # send email with username(s) to the requester
                subject = "Username/OpenID Reminder"
                message = ""
                for user in users:
                    message += "\nYour username is: %s\n" % user.username

                    for openid in user.profile.openids():
                        message += "Your OpenID is: %s\n" % openid

                sendEmail(email, subject, message)

                # redirect to login page with special message
                return HttpResponseRedirect(reverse('login')+"?message=user_reminder")

            # user not found
            else:
                return render_user_reminder_form(request, form, "This email address cannot be found.")

        else:
            print "Form is invalid: %s" % form.errors
            return render_user_reminder_form(request, form)