Пример #1
0
    def details(self):

	# Authenticate user and get list of subscriptions
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']

        db = psycopg2.connect("dbname=triggr")
        qr = db.cursor()
        qr.execute("select * from fn_account_subscriptions(%s) as (usersubscriptionid bigint, categoryid varchar(16), websiteid char(4), parameters text, filter text)", (userid,))

	c.subscriptions = []

        for row in qr.fetchall():
                usersubscriptionid = row[0]
		categoryid = row[1]
		websiteid = row[2]
		parameters = row[3]
		filter = row[4]

		subscription = {
                        'usersubscriptionid': usersubscriptionid,
			'categoryid': categoryid,
			'parameters': json.loads(parameters),
			'filter': filter,
		}
		c.subscriptions.append(subscription)

        return render('/account_details.mako')
Пример #2
0
    def login(self):
        c.identity = request.environ.get('repoze.who.identity')

        # Render login prompt or user info based on authentication status
        if c.identity is None:
		if request.params.has_key('failure'):
                	c.error = 'oops! incorrect email or password'

                return render('/account_login.mako')
        else:
                return render('/account_info.mako')
Пример #3
0
    def add(self):

        # Authenticate user
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']

        # Extract parameters from request
        artist = request.params['artist']
        location = request.params['location']
        radius = request.params['radius']

	websiteid = 'lafm'
        parameters = json.dumps({'artist': artist, 'location': {'name': location}, 'radius': radius})
        filter = 'true'

        # Register the subscription
	try:
		subscribe(userid, websiteid, parameters, filter)
	except SubscriptionValidationException, (e):
                response.content_type = 'text/plain'
		response.status = 400
                return e
Пример #4
0
    def add(self):

        # Authenticate user
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']

        # Extract parameters from request
        fromplaceid = request.params['fromplaceid']
        toplaceid = request.params['toplaceid']
        month_out = month_rtn = request.params['month']

        price = request.params['price']
        currency = request.params['currency']

	websiteid = 'skys'
        parameters = json.dumps({'fromplaceid': fromplaceid, 'toplaceid': toplaceid, 'month_out': month_out, 'month_rtn': month_rtn, 'price': price, 'currency': currency})
        filter = 'price < ' + price

        # Register the subscription
	try:
		subscribe(userid, websiteid, parameters, filter)
	except SubscriptionValidationException, (e):
                response.content_type = 'text/plain'
		response.status = 400
                return e
Пример #5
0
    def cancel(self, id):

	# Authenticate user and get list of subscriptions
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']
        usersubscriptionid = int(id)

        db = psycopg2.connect("dbname=triggr")
        qr = db.cursor()
        qr.execute("select * from fn_subscriptions_remove(%s, %s)", (userid, usersubscriptionid))
        db.commit()
Пример #6
0
    def add(self):

        # Authenticate user
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']

        # Extract parameters from request
        severity = request.params['severity']
        line = request.params['line']

	websiteid = 'tfl_'
        parameters = json.dumps({'severity': severity, 'line': line})
        filter = 'true'

        # Register the subscription
	try:
		subscribe(userid, websiteid, parameters, filter)
	except SubscriptionValidationException, (e):
                response.content_type = 'text/plain'
		response.status = 400
                return e
Пример #7
0
 def subscription(self, id):
     # Return a rendered template
     c.categoryid = id
     return render("/categories/" + id + "_subscription.mako")
Пример #8
0
 def list(self):
     # Return a rendered template
     return render("/category_list.mako")
Пример #9
0
        # Authenticate user
        c.identity = request.environ.get('repoze.who.identity')
        if c.identity is None:
                return render('/account_create.mako')

        userid = c.identity['user']['login']

        # Extract parameters from request
        artist = request.params['artist']
        location = request.params['location']
        radius = request.params['radius']

	websiteid = 'lafm'
        parameters = json.dumps({'artist': artist, 'location': {'name': location}, 'radius': radius})
        filter = 'true'

        # Register the subscription
	try:
		subscribe(userid, websiteid, parameters, filter)
	except SubscriptionValidationException, (e):
                response.content_type = 'text/plain'
		response.status = 400
                return e
	except SubscriptionException, (e):
                response.content_type = 'text/plain'
		response.status = 400
                return e
	else:
		# Return a summary for the user to confirm their subscription
		return render('categories/gigs_display.mako', extra_vars={ 'parameters': json.loads(parameters), 'filter': filter})
Пример #10
0
 def legal(self):
     return render('/static/legal.mako')
Пример #11
0
 def privacy(self):
     return render('/static/privacy.mako')
Пример #12
0
 def about(self):
     return render('/static/about.mako')
Пример #13
0
 def gather(self):
     return render('/feedback.mako')
Пример #14
0
    def allocate(self):
        captcha_response = h.recaptcha.submit()
        if captcha_response.is_valid:
                login = request.params['login'].lower()
                password = md5(request.params['password'] + login).hexdigest()

		if not valid(login):
                        return 'Invalid Mail Address'

		# Create the user account in the database
                try:
			db = psycopg2.connect("dbname=triggr")
			qr = db.cursor()
			qr.execute("select * from fn_account_create(%s, %s)", (login, password))
			qr.execute("select * from logging.fn_signup(%(userid)s)", {'userid': login})
			db.commit()
                except:
                        return 'An account with that email address already exists; please <a style="color: blue" href="javascript:history.back(1)">try again</a>'

		# Attempt to automatically log the user in
                try:
                        # This is a bit of a workaround - manually instantiate a user identity ...
                        request.environ['repoze.who.identity'] = {
                            'identifier': 'form',
                            'repoze.who.userid': login,
                        }
                        # ... create a repoze.who cookie authentication plugin ...
                        plugin = auth_tkt.make_plugin(secret='N0t1fy', cookie_name='auth_tkt')

                        # ... and use it to persist the user's newly-created account in their session
                        cookies = plugin.remember(request.environ, request.environ['repoze.who.identity'])
                        for (header, value) in cookies:
                                response.headers.add(str(header), str(value))
                except:
                        pass

		# Send a new account notification
		addrFrom = '*****@*****.**'
		addrTo = login
		subject = 'Triggr: User Account Created'

		body = """\
From: %s
To: %s
Subject: %s

Welcome to Triggr!  Your user account has been created and you'll now be able to
log into the website using your e-mail address (%s) and the password you
supplied during registration.

We're still a new service, so things may be a little rocky from time to time,
but we'll do our best and will always listen to feedback.  If you find any
problems with the service, just reply to this message or use the 'contact'
link on the https://triggr.me site to get in touch, and we'll get back to you!

Enjoy the service and we hope it comes in useful!

Regards,
Team Triggr
""" % (addrFrom, addrTo, subject, addrTo)

	    	server = smtplib.SMTP('smtp.gmail.com', 587)
	    	server.ehlo()
	    	server.starttls()
		server.login('*****@*****.**', 'T3llM3Wh3n')
		server.sendmail(addrFrom, addrTo, body)
		server.quit()

		for row in qr.fetchall():
			pass

		return 'Account Created'
        else:
                return render('/account_create.mako')
Пример #15
0
 def create(self):
     return render('/account_create.mako')
Пример #16
0
 def index(self):
     return render('/default.mako')