def get(self): loggedin = "?" user = users.get_current_user() if user: uid = user.user_id() crud = ProfileCrud(uid) shout_tz = pytz.timezone(crud.profile().time_zone) shout_list = shouts(self, shout_tz) values = { 'shouts': shout_list, 'loggedin': loggedin, 'logout_url': users.create_logout_url("/"), 'profile': crud.profile(), 'app_vars': env_vars() } else: shout_tz = pytz.timezone(env_vars().default_tz) shout_list = shouts(self, shout_tz) loggedin = "Anonymous" values = { 'shouts': shout_list, 'loggedin': loggedin, 'login_url': webapp2.uri_for('login', _scheme='https'), 'logout_url': users.create_logout_url("/"), 'app_vars': env_vars() } home_view(self, values)
def post(self): user = users.get_current_user() uid = user.user_id() crud = ProfileCrud(uid) post_shout(self, message=self.request.get('message'), who=crud.profile().user_name, avatar=crud.profile().avatar, uid=uid) self.redirect('/')
def post(self): user = users.get_current_user() uid = user.user_id() crud = ProfileCrud(uid) # Create Gravatar URL - http://blog.gravatar.com/2008/01/17/gravatars-in-python-25/ default_avatar = "https://ae-baseapp.appspot.com/static/images/avatar.png" avatar_size = 64 avatar_email = self.request.get('email') gravatar_url = "https://secure.gravatar.com/avatar.php?" gravatar_url += urllib.urlencode({ 'gravatar_id': hashlib.md5(avatar_email.lower()).hexdigest(), 'default': default_avatar, 'size': str(avatar_size), 'r': 'pg' }) # Create or Update the profile is_valid = crud.update_profile( user_name=self.request.get('user_name'), first_name=self.request.get('first_name'), last_name=self.request.get('last_name'), email=self.request.get('email'), avatar=gravatar_url, time_zone=self.request.get('time_zone'), last_ip=self.request.remote_addr) logging.info("is_valid: " + is_valid) if is_valid != "OK": self.abort(500) # Check if user has created a profile if not Generate Validation Code # and Send out Validation Email if not crud.is_validated(): validation_code = str(uuid.uuid4()) # TODO: Update validation_link to use coded domain validation_link = "https://ae-python.appspot.com/verify?" + validation_code email_values = { 'first_name': self.request.get('first_name'), 'validation_link': validation_link } address = self.request.get('email') send_verification(self, email_values, validation_link, address) # Store Validation Information in Datastore save_validation_code(self, uid, validation_code) # Send the user back home after saving the profile self.redirect('/')
def get(self): # Get the environment variables user = users.get_current_user() uid = user.user_id() query_string = self.request.query_string # Perform Validation crud = ProfileCrud(uid) # TODO catch not logged in error lookup request url to set redirect if crud.validate_email(query_string): values = {'profile': crud.profile(), 'app_vars': env_vars(), 'loggedin': "?", 'logout_url': users.create_logout_url("/")} validation_error = False validate_view(self, values, validation_error) else: values = {'app_vars': env_vars(), 'loggedin': "Anonymous"} validation_error = True validate_view(self, values, validation_error)
def get(self): user = users.get_current_user() if not user: self.abort(401) # TODO: self.redirect doesn't work look into it uid = user.user_id() crud = ProfileCrud(uid) # If no profile send them to complete it otherwise route them back to home # TODO: Expose the update functionality it is already in place if not crud.profile(): values = {'user': user, 'profile': crud.profile(), 'app_vars': env_vars(), 'time_zones': tz_list()} profile_view(self, values) else: crud.update_ip(self.request.remote_addr) self.redirect('/')
def get(self): loggedin = "?" user = users.get_current_user() if user: uid = user.user_id() crud = ProfileCrud(uid) shout_tz = pytz.timezone(crud.profile().time_zone) shout_list = shouts(self, shout_tz) values = {'shouts': shout_list, 'loggedin': loggedin, 'logout_url': users.create_logout_url("/"), 'profile': crud.profile(), 'app_vars': env_vars()} else: shout_tz = pytz.timezone(env_vars().default_tz) shout_list = shouts(self, shout_tz) loggedin = "Anonymous" values = {'shouts': shout_list, 'loggedin': loggedin, 'login_url': webapp2.uri_for('login', _scheme='https'), 'logout_url': users.create_logout_url("/"), 'app_vars': env_vars()} home_view(self, values)
def post(self): user = users.get_current_user() uid = user.user_id() crud = ProfileCrud(uid) # Create Gravatar URL - http://blog.gravatar.com/2008/01/17/gravatars-in-python-25/ default_avatar = "https://ae-baseapp.appspot.com/static/images/avatar.png" avatar_size = 64 avatar_email = self.request.get('email') gravatar_url = "https://secure.gravatar.com/avatar.php?" gravatar_url += urllib.urlencode({'gravatar_id':hashlib.md5( avatar_email.lower()).hexdigest(), 'default':default_avatar, 'size':str(avatar_size), 'r':'pg'}) # Create or Update the profile is_valid = crud.update_profile(user_name=self.request.get('user_name'), first_name=self.request.get('first_name'), last_name=self.request.get('last_name'), email=self.request.get('email'), avatar=gravatar_url, time_zone=self.request.get('time_zone'), last_ip=self.request.remote_addr) logging.info("is_valid: " + is_valid) if is_valid != "OK": self.abort(500) # Check if user has created a profile if not Generate Validation Code # and Send out Validation Email if not crud.is_validated(): validation_code = str(uuid.uuid4()) # TODO: Update validation_link to use coded domain validation_link = "https://ae-python.appspot.com/verify?" + validation_code email_values = {'first_name': self.request.get('first_name'), 'validation_link': validation_link} address = self.request.get('email') send_verification(self, email_values, validation_link, address) # Store Validation Information in Datastore save_validation_code(self, uid, validation_code) # Send the user back home after saving the profile self.redirect('/')
def get(self): user = users.get_current_user() if not user: self.abort(401) # TODO: self.redirect doesn't work look into it uid = user.user_id() crud = ProfileCrud(uid) # If no profile send them to complete it otherwise route them back to home # TODO: Expose the update functionality it is already in place if not crud.profile(): values = { 'user': user, 'profile': crud.profile(), 'app_vars': env_vars(), 'time_zones': tz_list() } profile_view(self, values) else: crud.update_ip(self.request.remote_addr) self.redirect('/')