Beispiel #1
0
def confirm_add():
    global APP_KEY, APP_SECRET
    person_id = int(request.form['person_id'])
    request_token = request.form['request_token']

    # Obtain access tokens from dropbox, and add them to the associated account in the database
    try:
        sess = dropbox.session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
        request_token = oauth.oauth.OAuthToken.from_string(request_token)
        full_access_token = sess.obtain_access_token(request_token)

        p = Person.find(person_id)
        p.access_secret = full_access_token.__str__()[19:34]
        p.access_token = full_access_token.__str__()[47:62]
        p.save()

        # Send success notification email to newly added user
        sendemail.mail_without_attach(
            p.personal_email, "Welcome to KindleFolder!",
            "Welcome to KindleFolder's free service!<br /><br />Please complete the following instructions to complete setup. <ol><li>Go to Manage Your Kindle on Amazon.com or <a href='https://www.amazon.com/gp/digital/fiona/manage?ie=UTF8&ref_=ya_14&'>click here</a>.</li><li>Go to &quot;Personal Document Settings&quot;, then under the &quot;Approved Personal Document E-mail List&quot;, click &quot;Add a new approved e-mail address&quot;.</li><li>Enter &quot;[email protected]&quot; and then click &quot;Add Address&quot;. We like unicorns.</li><li>Within the &quot;Apps&quot; folder of your Dropbox, a new folder will appear called &quot;KindleFolder&quot;. Any file that a Kindle can open will automatically be sent to your Kindle! Please note that this service uses Amazon's Kindle Personal Document Service - as a result, it may take up to 5 minutes for your file to be sent to your Kindle. Charges may apply for use over 3G.</li></ol><br />If you followed these directions, you should be good to go! Feel free to unsubscribe at any point by visiting <a href='http://www.kindlefolder.us/unsubscribe'>http://www.kindlefolder.us/unsubscribe</a>.<br /><br />Thanks!<br /><br />Chris and Geoff from KindleFolder"
        )

        return redirect(
            url_for('success',
                    kindle_email=p.kindle_email,
                    personal_email=p.personal_email))

    # If an error occured with dropbox, remove associated account from database, prompt user to try again from beginning
    except dropbox.rest.ErrorResponse:
        return dropbox_error(person_id)
    except dropbox.rest.RESTSocketError:
        return dropbox_error(person_id)
Beispiel #2
0
def confirm_add():
	global APP_KEY, APP_SECRET
	person_id = int(request.form['person_id'])
	request_token = request.form['request_token']
	
	# Obtain access tokens from dropbox, and add them to the associated account in the database
	try:
		sess = dropbox.session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
		request_token = oauth.oauth.OAuthToken.from_string(request_token)
		full_access_token = sess.obtain_access_token(request_token)
		
		p = Person.find(person_id)
		p.access_secret = full_access_token.__str__()[19:34]
		p.access_token = full_access_token.__str__()[47:62]		
		p.save()
		
		# Send success notification email to newly added user
		sendemail.mail_without_attach(p.personal_email, "Welcome to KindleFolder!","Welcome to KindleFolder's free service!<br /><br />Please complete the following instructions to complete setup. <ol><li>Go to Manage Your Kindle on Amazon.com or <a href='https://www.amazon.com/gp/digital/fiona/manage?ie=UTF8&ref_=ya_14&'>click here</a>.</li><li>Go to &quot;Personal Document Settings&quot;, then under the &quot;Approved Personal Document E-mail List&quot;, click &quot;Add a new approved e-mail address&quot;.</li><li>Enter &quot;[email protected]&quot; and then click &quot;Add Address&quot;. We like unicorns.</li><li>Within the &quot;Apps&quot; folder of your Dropbox, a new folder will appear called &quot;KindleFolder&quot;. Any file that a Kindle can open will automatically be sent to your Kindle! Please note that this service uses Amazon's Kindle Personal Document Service - as a result, it may take up to 5 minutes for your file to be sent to your Kindle. Charges may apply for use over 3G.</li></ol><br />If you followed these directions, you should be good to go! Feel free to unsubscribe at any point by visiting <a href='http://www.kindlefolder.us/unsubscribe'>http://www.kindlefolder.us/unsubscribe</a>.<br /><br />Thanks!<br /><br />Chris and Geoff from KindleFolder")
		
		return redirect(url_for('success', kindle_email=p.kindle_email, personal_email=p.personal_email))
	
	# If an error occured with dropbox, remove associated account from database, prompt user to try again from beginning
	except dropbox.rest.ErrorResponse:
		return dropbox_error(person_id)
	except dropbox.rest.RESTSocketError:
		return dropbox_error(person_id)
Beispiel #3
0
def send_unsubscribe_email():
	global ROOT
	personal_email = request.form['personal_email']
	
	# If submitted email is not found in the database, return an error
	ps = Person.find_many("personal_email='%s'" % personal_email)
	if len(ps) < 1:
		flash('Email was not found in our database', 'error')
		return render_template("unsubscribe.html")
	
	# Generate unsubscribe token for an account with the personal email
	unsubscribe_token = ps[0].generate_unsubscribe_token()
	
	# Send unsubscribe token to user via email
	sendemail.mail_without_attach(personal_email, "Unsubscribe","Hello!<br /><br />You have requested to be unsubscribed from KindleFolder's service. Please click the link below to confirm. <br /><br />%s<br /><br />If you did not request to be unsubscribed, please ignore this email. If you keep receiving this email, please contact [email protected].<br /><br />Thanks!<br /><br />Chris and Geoff from KindleFolder" % (ROOT + url_for('remove', personal_email=personal_email, unsubscribe_token=unsubscribe_token)))
	return redirect(url_for("unsubscribe_email_sent", personal_email=personal_email))
Beispiel #4
0
def send_unsubscribe_email():
    global ROOT
    personal_email = request.form['personal_email']

    # If submitted email is not found in the database, return an error
    ps = Person.find_many("personal_email='%s'" % personal_email)
    if len(ps) < 1:
        flash('Email was not found in our database', 'error')
        return render_template("unsubscribe.html")

    # Generate unsubscribe token for an account with the personal email
    unsubscribe_token = ps[0].generate_unsubscribe_token()

    # Send unsubscribe token to user via email
    sendemail.mail_without_attach(
        personal_email, "Unsubscribe",
        "Hello!<br /><br />You have requested to be unsubscribed from KindleFolder's service. Please click the link below to confirm. <br /><br />%s<br /><br />If you did not request to be unsubscribed, please ignore this email. If you keep receiving this email, please contact [email protected].<br /><br />Thanks!<br /><br />Chris and Geoff from KindleFolder"
        % (ROOT + url_for('remove',
                          personal_email=personal_email,
                          unsubscribe_token=unsubscribe_token)))
    return redirect(
        url_for("unsubscribe_email_sent", personal_email=personal_email))