Ejemplo n.º 1
0
	def post(self):
		
		email = self.request.get('email').lower()
		pw = self.request.get('pw')
		
		existing = models.User.gql('WHERE email=:1 AND pw=:2',email,pw).get()
		logging.info(existing)
		
		if existing:
			session = get_current_session()
			session.clear()
			session['logged_in'] = True
			session['cameras'] = existing.cameras
			session['user'] = existing.key()
			session.save()
			
			#cameras linked?
			if len(session.get('cameras',[])) > 0:
				self.redirect('/view')
			else:
				self.redirect('/link')
		
		else:
			template_values = {
				"error"		:	"Incorrect email/password. Please try again.",
				"email"		:	email
			}
			utils.respond(self,'templates/login.html',template_values)
Ejemplo n.º 2
0
	def get(self):
		
		session = get_current_session()
		logging.info(session)
		
		if session.get("logged_in",False) == True:
			user = db.get(session.get('user'))
			
			template_values = {
				"loggedin"	:	True,
				"addr1"		:	getattr(user,'addr1',''),
				"addr2"		:	getattr(user,'addr2',''),
				"city"		:	getattr(user,'city',''),
				"state"		:	getattr(user,'state',''),
				"tz"		:	getattr(user,'tz',''),
				"name"		:	getattr(user,'name','')
			}
			
			
		else:
			template_values = {
				"loggedin"	:	False
			}
		
		
	
		utils.respond(self,'templates/purchase.html',template_values)
Ejemplo n.º 3
0
    def get(self):

        utils.session_bounce(self)

        template_values = {}

        utils.respond(self, "templates/cancel.html", template_values)
Ejemplo n.º 4
0
def lambda_handler(event, context):
    post_data = dict(
        client_id=
        CLIENT_ID,  # The application’s ID, obtained during registration.
        client_secret=
        CLIENT_SECRET,  # The application’s secret, obtained during registration.
        grant_type=
        'refresh_token',  # The grant type for the request. When refreshing an access
        # token, must always be "refresh_token".
        refresh_token=TOKEN_REFRESH
    )  # The refresh token for this user, to be used to get the
    # next access token for this user. Please expect
    # that this value can change anytime you retrieve
    # a new access token. Once a new refresh token
    # code has been returned, the older code will no longer work.

    try:
        response = requests.post(
            url='https://www.strava.com/api/v3/oauth/token', data=post_data)
        data = response.json()
    except Exception as e:
        print(f'ERROR: {str(e)}')
        return respond({'error': str(e)}, 500)

    return respond(data, 200)
Ejemplo n.º 5
0
	def post(self):
		
		email = self.request.get('email').lower()
		pw1 = self.request.get('pw1')
		pw2 = self.request.get('pw2')
		
		existing = models.User.gql("WHERE email=:1",email).get()
		
		if existing:
			template_values = {
				"error"		:	"That user already exists"
			}
			utils.respond(self,'templates/signup.html',template_values)
		else:
			#create the user
			user = models.User(email=email,pw=pw1)
			user.put()
			
			#store in session
			session = get_current_session()
			session['logged_in'] = True
			session['user'] = user.key()
			session.save()
			
			self.redirect('/link')
Ejemplo n.º 6
0
	def get(self):
		
		session = get_current_session()
		if session.get('logged_in',False) == True:
			self.redirect('/view')
		
		template_values = {}
		utils.respond(self,'templates/login.html',template_values)
Ejemplo n.º 7
0
def run_command(user, command, channel, command_text):
    command_text_list = command_text.split()
    if command_text_list[0] in ['online', 'o']:
        return respond(None, online())
    if command_text_list[0] in ['ong', 'g']:
        return respond(None, online_grouped())
    return respond(
        None, "%s invoked %s in %s with the following text: %s" %
        (user, command, channel, command_text))
Ejemplo n.º 8
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['body']:
        payload = json.loads(event['body'])
        response = update_shift(payload)
        if 'error' in response:
            return respond(response)
        else:
            return respond(None, {'data': response['Attributes']})
    else:
        return respond({'error': 'No request body'})
Ejemplo n.º 9
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['pathParameters']:
        params = event['pathParameters']
    else:
        params = {}
    if 'company' in params:
        response = get_all_trades(params['company'])
        if 'error' in response:
            respond(response)
        else:
            respond(None, {'data': response['Items']})
    else:
        return respond({'error': 'No company specified'})
Ejemplo n.º 10
0
	def get(self):
		
		utils.session_bounce(self)
		
		#grab session
		session = get_current_session()
		camera_keys = session.get("cameras")
		cameras = db.get(camera_keys)
		
		logging.info(get_current_session())
		
		template_values = {
			"cameras"	:	cameras
		}
		utils.respond(self,'templates/password.html',template_values)
Ejemplo n.º 11
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['pathParameters']:
        params = event['pathParameters']
    else:
        params = {}
    if 'userId' in params:
        response = get_user(params['userId'], params['company'])
        if 'Item' in response:
            return respond(None, {'data': response['Item']})
        else:
            return respond(response)
    else:
        return respond({'error': 'Invalid user path'})
Ejemplo n.º 12
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['pathParameters']:
        params = event['pathParameters']
        if 'id' not in params:
            return respond({'error': 'shift id not specified'})
        else:
            response = delete_shift(params['id'])
            if 'error' in response:
                return respond(response)
            else:
                return respond(None, {'data': response['Attributes']})
    else:
        return respond({'error': 'this will never happen probably...'})
Ejemplo n.º 13
0
    def c2b_checkout(self):
        # Alert user of incoming Mpesa checkout
        menu_text = "END We have sent the MPESA checkout...\n"
        menu_text += "If you dont have a bonga pin, dial \n"
        menu_text += "Dial dial *126*5*1# to create.\n"

        # Declare params
        gateway = make_gateway()
        product_name = current_app.config["PRODUCT_NAME"]
        currency_code = "KES"
        amount = int(self.user_response)
        metadata = {"sacco": "Nerds", "productId": "321"}

        # pass to gateway
        try:
            menu_text += "transactionId is: %s" % \
                         gateway.initiateMobilePaymentCheckout(
                             product_name,
                             self.phone_number,
                             currency_code,
                             amount,
                             metadata)

        except AfricasTalkingGatewayException as e:
            menu_text += "Received error response: {}".format(str(e))

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 14
0
    def c2b_checkout(self):
        # Alert user of incoming Mpesa checkout
        menu_text = "END We are sending you the MPESA checkout in a moment...\n"
        menu_text += "If you dont have a bonga pin, dial \n"
        menu_text += "Dial dial *126*5*1# to create.\n"
        gateway = make_gateway()
        product_name = current_app.config["PRODUCT_NAME"]
        currency_code = "KES"
        amount = int(self.user_response)
        metadata = {"sacco": "Nerds", "productId": "321"}
        api_key = current_app.config["AT_APIKEY"]
        user_name = current_app.config["AT_USERNAME"]
        payload = {
            "phone_number": self.phone_number,
            "product_name": product_name,
            "metadat": metadata,
            "amount": amount,
            "currency_code": currency_code,
            "metadata": metadata,
            "api_key": api_key,
            "user_name": user_name
        }
        async_checkoutc2b.apply_async(args=[payload], countdown=10)

        return respond(menu_text)
Ejemplo n.º 15
0
    def b2c_checkout(self):
        if self.user.account > 1:
            # Reduce the balance
            self.user.withdraw(1)
            db.session.add(self.user)
            db.session.commit()

            menu_text = "END We are sending your withdrawal of\n"
            menu_text += " KES {}/- shortly... \n".format(self.user_response)

            # Declare Params
            gateway = make_gateway()

            product_name = current_app.config["PRODUCT_NAME"]

            recipients = [{
                "phoneNumber": self.phone_number,
                "currencyCode": "KES",
                "amount": int(self.user_response),
                "metadata": {
                    "name": "Client",
                    "reason": "Withdrawal"
                }
            }]
            # Send B2c
            try:
                gateway.mobilePaymentB2CRequest(product_name, recipients)
            except AfricasTalkingGatewayException as e:
                print "Received error response {}".format(str(e))
        else:
            # Alert user of insufficient funds
            menu_text = "END Sorry, you don't have sufficient\n"
            menu_text += " funds in your account \n"

        return respond(menu_text)
Ejemplo n.º 16
0
    def home(self):
        """
        If user level is zero or zero
        Serves the home menu
        :return: a response object with headers['Content-Type'] = "text/plain" headers
        """

        # upgrade user level and serve home menu
        # TODO background task here
        self.session.promote_level()
        db.session.add(self.session)
        db.session.commit()
        # serve the menu
        menu_text = "CON Welcome to Nerd \
        Microfinance, {} Choose a service.\n".format(
            self.user.name)
        menu_text += " 1. Please call me.\n"
        menu_text += " 2. Deposit Money\n"
        menu_text += " 3. Withdraw Money\n"
        menu_text += " 4. Send Money\n"
        menu_text += " 5. Buy Airtime\n"
        menu_text += " 6. Repay Loan\n"

        # print the response on to the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 17
0
    def repay_loan(self):
        """
        Pay Loan
        :param session_id, amount:
        :return response object:
        """
        # Alert user of incoming Mpesa checkout
        amount = int(self.user_response)
        menu_text = "END You are repaying {}/-. \
        We have sent the MPESA \
        checkout...\n".format(amount)
        menu_text += "If you dont have a bonga pin, dial \n"
        menu_text += "Dial dial *126*5*1# to create.\n"

        # Declare Params
        gateway = make_gateway()

        productName = current_app.config["PRODUCT_NAME"]

        currencyCode = "KES"
        metadata = {"Sacco Repayment": "Nerds", "productId": "321"}

        # pass to gateway
        try:
            transactionId = gateway.initiateMobilePaymentCheckout(
                productName, self.phone_number, currencyCode, amount, metadata)
        except AfricasTalkingGatewayException as e:
            print "Received error response: {}".format(str(e))

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 18
0
	def post(self):
		
		#grab inputs
		oldpw = self.request.get('oldpw')
		pw1 = self.request.get('pw1')
		pw2 = self.request.get('pw2')
		
		#grab session
		session = get_current_session()
		camera_keys = session.get("cameras",[])
		cameras = db.get(camera_keys)
		
		#check existing password
		user = db.get(session['user'])
		success = None
		if oldpw == user.pw:
			if pw1 == pw2:
				if len(pw1) > 5:
					user.pw = pw1
					user.put()
					
					success = "Your password has been successfully changed."
					error = None
					oldpw = ""
					pw1 = ""
					pw2 = ""
				else:
					error = "Passwords should be at least 5 characters."
					pw1 = ""
					pw2 = ""
			else:
				error = "New passwords do not match. Please try again."
				pw1 = ""
				pw2 = ""
		else:
			error = "Incorrect existing password. Please try again."
			oldpw = ""
		
		template_values = {
			"error"		:	error,
			"success"	:	success,
			"oldpw"		:	oldpw,
			"pw1"		:	pw1,
			"pw2"		:	pw2
		}
		
		utils.respond(self,'templates/password.html',template_values)
Ejemplo n.º 19
0
	def get(self):
		
		utils.session_bounce(self)
		
		#grab session
		session = get_current_session()
		camera_keys = session.get("cameras",[])
		cameras = db.get(camera_keys)
		
		template_values = {
			"cameras"	:	cameras if cameras != [None] else []
		}
		
		logging.info(template_values)
		
		
		utils.respond(self,'templates/managecameras.html',template_values)
Ejemplo n.º 20
0
    def send_money(self):
        # Send Another User Some Money
        menu_text = "CON You can only send 1 shilling.\n"
        menu_text += " Enter a valid phonenumber (like 0722122122)\n"

        # Update sessions to level 11
        update_session(self.session_id, SessionLevel, 11)
        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 21
0
 def class_menu(session):
     # Return user to Main Menu & Demote user's level
     menu_text = "CON You have to choose a service.\n"
     menu_text += "Press 0 to go back to main menu.\n"
     # demote
     session.demote_level()
     db.session.add(session)
     db.session.commit()
     # Print the response onto the page so that our gateway can read it
     return respond(menu_text)
Ejemplo n.º 22
0
    def send_loan(self, ):
        debptor_phone_number = self.user_response
        amount = 1
        # Find and update creditor
        creditorAccount = self.user
        creditorAccount.withdraw(amount)
        # Send the loan if new account balance is above 0
        if creditorAccount.account > 0:
            menu_text = "END We are sending KES {}/- \n".format(amount)
            menu_text += "to the loanee shortly. \n"
            # get and update Debtor
            debptorAccount = User.query.filter_by(
                phone_number=debptor_phone_number).first()

            if debptorAccount:
                debptorAccount.deposit(amount)
                db.session.add(debptorAccount)
                db.session.add(creditorAccount)

            # SMS New Balance

            code = current_app.config["SMS_CODE"]
            recepients = self.phone_number
            message = "We have sent {}/- to {} \nIf \
            this is a wrong number the transaction will fail\n" \
                      "Your new balance is {} \n\
                      Thank you.\n".format(amount, debptor_phone_number,
=
                                         creditorAccount.account)
            gateway = make_gateway()
            try:
                gateway.sendMessage(recepients, message, code)
            except AfricasTalkingGatewayException as e:
                print "Encountered an error while sending: {}\n".format(str(e))

            # TODO figure out
            # change user level to 0
            # session_level = SessionLevel.query.filter_by(session_id=session_id).first()
            # session_level.demote_level()
            # db.session.add(session_level)

            # Update DB
            db.session.commit()

            # respond
            menu_text += "CONFIRMED we have sent money to {} \n".format(
                creditorAccount.phone_number)
        else:
            # respond
            menu_text = "END Sorry we could not send the money. \n"
            menu_text += "You dont have enough money. {}\n".format(
                creditorAccount.account)

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 23
0
	def post(self):
		
		email = self.request.get('email').lower()
		pw1 = self.request.get('pw1')
		pw2 = self.request.get('pw2')
		
		existing = models.User.gql("WHERE email=:1",email).get()
		
		if existing:
			template_values = {
				"error"		:	"That user already exists. <a href='/login'>Sign in</a>"
			}
			utils.respond(self,'templates/signup.html',template_values)
		else:

			if not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email):
				template_values = {
				"error"		:	"Please enter a valid email address",
				"pw1"		:	pw1,
				"pw2"		:	pw2
				}
				utils.respond(self,'templates/signup.html',template_values)
			else:
				if pw1 != pw2:
					template_values = {
					"error"		:	"Passwords must match",
					"email"		:	email
					}
					utils.respond(self,'templates/signup.html',template_values)
				else:
					if len(pw1) < 6:
						template_values = {
						"error"		:	"Passwords must be at least 6 characters",
						"email"		:	email
						}
						utils.respond(self,'templates/signup.html',template_values)
					else:
						
# 						create the user
						user = models.User(email=email,pw=pw1)
						user.put()
						
						#store in session
						session = get_current_session()
						logging.info(session)
						session.clear()
						logging.info(session)
						session['logged_in'] = True
						session['user'] = user.key()
						session.save()
						
						self.redirect('/link')
Ejemplo n.º 24
0
    def pay_loan_menu(self):
        # Ask how much and Launch the Mpesa Checkout to the user
        menu_text = "CON How much are you depositing?\n"
        menu_text += " 4. 1 Shilling.\n"
        menu_text += " 5. 2 Shillings.\n"
        menu_text += " 6. 3 Shillings.\n"

        # Update sessions to level 9
        self.session.promote_level(12)
        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 25
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['body']:
        payload = json.loads(event['body'])
        if type(payload) is list:
            users = []
            for user in payload:
                user['password'] = bcrypt.hash(user['password'])
                users.append(user)
            response = create_batch(users, 'User')
        else:
            payload['password'] = bcrypt.hash(payload['password'])
            response = create_user(payload)
        if 'error' in response:
            return respond(response)
        else:
            return respond(None, {'data': payload})
    else:
        return respond({'error': 'No request body'})
Ejemplo n.º 26
0
    def deposit(self):
        # as how much and Launch teh Mpesa Checkout to the user
        menu_text = "CON How much are you depositing?\n"
        menu_text += " 1. 1 Shilling.\n"
        menu_text += " 2. 2 Shillings.\n"
        menu_text += " 3. 3 Shillings.\n"

        # Update sessions to level 9
        update_session(self.session_id, SessionLevel, 9)
        # print the response on to the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 27
0
    def withdraw(self):
        # Ask how much and Launch B2C to the user
        menu_text = "CON How much are you withdrawing?\n"
        menu_text += " 1. 1 Shilling.\n"
        menu_text += " 2. 2 Shillings.\n"
        menu_text += " 3. 3 Shillings.\n"

        # Update sessions to level 10
        update_session(self.session_id, SessionLevel, 10)

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 28
0
def lambda_handler(event, context):
    body = {k.lower(): v for k, v in event.items() if k.lower() == 'body'}

    if not body or not body.get('body'):
        return respond({'error', 'missing request body'}, 400)

    parameter_info = body.get('body')

    try:
        response = client.put_parameter(
            Name=parameter_info['name'],
            Description=parameter_info['description'],
            Value=parameter_info['value'],
            Type='SecureString',
            Overwrite=True,
            Tier='Standard',
        )
    except Exception as e:
        return respond(str(e), 500)

    return respond(response, 200)
Ejemplo n.º 29
0
def lambda_handler(event, context):
    params = parse_qs(event['body'])
    token = params['token'][0]
    if token != expected_token:
        logger.error("Request token (%s) does not match expected", token)
        return respond(Exception('Invalid request token'))

    user = params['user_name'][0]
    command = params['command'][0]
    channel = params['channel_name'][0]
    command_text = params['text'][0]

    return run_command(user, command, channel, command_text)
Ejemplo n.º 30
0
def handler(event, context):
    print("Received api request: " + json.dumps(event, indent=2))

    if event['body']:
        payload = json.loads(event['body'])
        if type(payload) is list:
            shifts = []
            for shift in payload:
                shift['id'] = str(uuid4())
                shift['tradeable'] = False
                shifts.append(shift)
            response = create_batch(shifts, 'Shifts')
        else:
            payload['id'] = str(uuid4())
            payload['tradeable'] = False
            response = create(payload)
        if 'error' in response:
            return respond(response)
        else:
            return respond(None, {'data': payload})
    else:
        return respond({'error': 'No request body'})
Ejemplo n.º 31
0
	def get(self):
		
		utils.session_bounce(self)
		
		#get current user
		session = get_current_session()
		camera_keys = session.get("cameras")
		cameras = db.get(camera_keys)
		user = session['user']
		
		#get all alerts
		alerts = models.Alert.gql('WHERE ANCESTOR IS :1',user).fetch(None)
		logging.info(alerts)
		
		#segregate
		justonce = []
		recurring = []
		for alert in alerts:
			if alert.alerttype == 'justonce':
				alert.stringstart = alert.justoncestart.strftime("%m/%d/%Y %I:%M:%S %p")
				alert.stringend = alert.justonceend.strftime("%m/%d/%Y %I:%M:%S %p")
				justonce.append(alert)
			elif alert.alerttype == 'recurring':
				alert.stringstart = alert.recurringstart.strftime("%I:%M:%S %p")
				alert.stringend = alert.recurringend.strftime("%I:%M:%S %p")
				recurring.append(alert)
		
		logging.info(justonce)
		logging.info(recurring)
		
		template_values = {
			"justonce"		:	justonce,
			"recurring"		:	recurring,
			"cameras"		:	cameras
		}
		
		utils.respond(self,'templates/managealert.html',template_values)
Ejemplo n.º 32
0
	def post(self):
		
		camera_id = self.request.get('camera_id')
		camera_name = self.request.get('camera_name')
		
		camera = models.Camera.gql("WHERE camera_id=:1",camera_id).get()
		
		if not camera:
			template_values = {
				"error"		:	"Camera ID not found. Please try again.",
				"camera_id"	:	camera_id,
				"camera_name"	:	camera_name
			}
			utils.respond(self,'templates/link.html',template_values)
		else:
			#get current user
			session = get_current_session()
			user = db.get(session['user'])
			
			#update camera name
			camera.camera_name = camera_name
			camera.put()
			
			#add camera
			user.cameras.append(camera.key())
			#unique
			user.cameras = list(set(user.cameras))
			user.put()
			
			#store in session
			s_cameras = session.get('cameras',[])
			s_cameras.append(camera.key())
			session['cameras'] = list(set(s_cameras))
			session.save()
			
			self.redirect('/view?camera='+camera_id)
Ejemplo n.º 33
0
    def buy_airtime(self):
        # 9e.Send user airtime
        menu_text = "END Please wait while we load your account.\n"

        # Search DB and the Send Airtime
        recipientStringFormat = [{"phoneNumber": self.user.phone_number, "amount": "KES 5"}]

        # Create an instance of our gateway
        gateway = AfricasTalkingGateway(
            current_app.config["AT_USERNAME"], current_app.config["AT_APIKEY"])
        try:
            menu_text += gateway.sendAirtime(recipientStringFormat)
        except AfricasTalkingGatewayException as e:
            menu_text += str(e)

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 34
0
    def please_call(self):
        # call the user and bridge to a sales person
        menu_text = "END Please wait while we place your call.\n"

        # make a call
        caller = current_app.config["AT_NUMBER"]
        to = self.user.phone_number

        # create a new instance of our awesome gateway
        gateway = AfricasTalkingGateway(current_app.config["AT_USERNAME"],
                                        current_app.config["AT_APIKEY"])
        try:
            gateway.call(caller, to)
        except AfricasTalkingGateway as e:
            print "Encountered an error when calling: {}".format(str(e))

        # print the response on to the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 35
0
    def get_number(self):
        # insert user's phone number
        new_user = User(phone_number=self.phone_number)
        # TODO background task
        db.session.add(new_user)
        db.session.commit()
        # create a new sessionlevel
        session = SessionLevel(session_id=self.session_id,
                               phone_number=self.phone_number)

        # promote the user a higher session level
        session.promote_level(21)
        db.session.add(session)
        db.session.commit()
        menu_text = "CON Please enter your name"

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 36
0
    def get_name(self):
        # Request again for name - level has not changed...
        if self.user_response:

            # insert user name into db request for city
            self.user.name = self.user_response

            # graduate user level

            self.session.promote_level(22)
            db.session.add(self.session)
            db.session.add(self.user)
            menu_text = "CON Enter your city"

        else:
            menu_text = "CON Name not supposed to be empty. Please enter your name \n"

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 37
0
    def get_city(self):
        if self.user_response:

            # if user response is not an empty string
            # insert user city into db request for city
            self.user.city = self.user_response

            # demote user level to 0
            self.session.demote_level()
            db.session.add(self.session)
            db.session.add(self.user)
            db.session.commit()
            menu_text = "END You have been successfully registered. \n"

        else:

            # if user response is an empty string
            # Request again for city - level has not changed...
            menu_text = "CON City not supposed to be empty. Please enter your city \n"

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 38
0
Archivo: main.py Proyecto: forter/boten
def run_payload(bot, payload, logger):
    try:
        for message in bot.run_command(payload):
            utils.respond(payload, message)
    except Exception:
        logger.exception("Cannot run")
Ejemplo n.º 39
0
    def register_default():
        menu_text = "END Apologies something went wrong \n"

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 40
0
	def get(self):
		
		logging.info(get_current_session())
		
		template_values = {}
		utils.respond(self,'templates/signup.html',template_values)
Ejemplo n.º 41
0
 def b2c_default(self):
     menu_text = "END Apologies, something went wrong... \n"
     # Print the response onto the page so that our gateway can read it
     return respond(menu_text)
Ejemplo n.º 42
0
			template_values = {
				"email" : email,
				"pw1" : pw1,
				"pw2" : pw2,
				"tz" : tz,
				"name" : name,
				"addr1" : addr1,
				"addr2" : addr2,
				"city" : city,
				"state" : state,
				"numcams" : numcams,
				"loggedin" : loggedin,
				"carderror" : carderror
			}
			
			utils.respond(self,'templates/purchase.html',template_values)
			
		
		
		
		
class CheckEmailHandler(webapp2.RequestHandler):
	def get(self):
		
		session = get_current_session()
		logging.info(session)
		if session.get("logged_in",False) == True:
			user = db.get(session.get('user'))
			logged_in_email = user.email
		else:
			logged_in_email = ''
Ejemplo n.º 43
0
 def default_loan_checkout():
     menu_text = "END Apologies, something went wrong... \n"
     # Print the response onto the page so that our gateway can read it
     return respond(menu_text)
Ejemplo n.º 44
0
    def default_higher_level_response():
        # Request for city again
        menu_text = "END Apologies, something went wrong... \n"

        # Print the response onto the page so that our gateway can read it
        return respond(menu_text)
Ejemplo n.º 45
0
	def get(self):
		
		template_values = {}
		utils.respond(self,'templates/landing.html',template_values)
Ejemplo n.º 46
0
		
		if specific:
			camera_keys = [specific]
		
		template_values = {
			"photos_outer"	:	photos_outer,
			"cameras"	:	cameras,
			"view_all"	:	view_all,
			"offset"	:	offset,
			"older"		:	older,
			"newer"		:	newer,
			"specific"	:	specific,
			"camera_keys":	[str(x) for x in camera_keys]
		}
		
		utils.respond(self,'templates/view.html',template_values)


class ViewAllHandler(webapp2.RequestHandler):
	def get(self):
		
		#get base url
		o = urlparse.urlparse(self.request.url)
		s = urlparse.urlunparse((o.scheme, o.netloc, '', '', '', ''))
		
		photos = models.Photo.gql("ORDER BY timestamp DESC").fetch(None)
# 		photos.reverse()
		for photo in photos:
# 			photo.key().parent())
			camera = db.get(photo.key().parent())
			img_path = s+'/photo/'+str(photo.blob_key.key())