def handle_customer(): if request.method == 'GET': email = request.args.get('email') contact_number = request.args.get('contact_number') return gateway.get_customer(contact_number=contact_number, email=email) elif request.method == 'POST': data = request.get_json() return gateway.add_customer(data['email'], data['contact_number'], data['first_name'], data['last_name']) elif request.method == 'DELETE': return 'unimplemented'
def post(self, url=None): user = users.get_current_user() lat = float(self.request.get('lat')) lon = float(self.request.get('lon')) title = str(cgi.escape(self.request.get('title'))) key = self.request.get('key') point = dict(title=title, lat=lat, lon=lon) if not key: if title == '' or title == None: raise Exception, "You need to provide a title." new_point = gateway.set_point(gateway.get_customer(user), point) self.respond(new_point.key()) else: gateway.edit_point(key, point, user) self.respond('OK')
def authdetails(page="/"): user = users.get_current_user() if user: customer = gateway.get_customer(user) label = "Sign Out" link = users.create_logout_url(page) status = 1 url = customer.url if customer else None at_home = status and (url == page[1:]) else: label = "Sign In" link = users.create_login_url(page) status = 0 url = None at_home = 0 return dict(status=status, link=link, label=label, url=url, at_home=at_home)