def get(self): user = users.get_current_user() user_id = user.user_id() email = user.email() if user: myUser = User.all().filter('id = ',user_id) if(myUser.count() >= 1): userMetaData = json.loads(myUser[0].metadata) if (userMetaData['profile_completed'] == 0): path = os.path.join(os.path.dirname(__file__), '../views' , 'complete_profile.html') self.response.out.write(template.render(path,locals())) else: self.redirect('/home') else: userDict ={} userDict['is_first_time'] = 1; userDict['profile_completed'] = 0; new_user = User() new_user.id = user_id new_user.email = email; new_user.metadata = json.dumps(userDict) new_user.put() path = os.path.join(os.path.dirname(__file__), '../views' , 'complete_profile.html') self.response.out.write( template.render(path,locals()) ) else: self.redirect('/login')
def getUserbyId(user_id): if not user_id: return False; myUser = User.all().filter('id = ',user_id) if(myUser): return myUser[0] else: return False
def post(self): current_user = users.get_current_user() if(not current_user): self.redirect('/login') else: user_id = current_user.user_id() nickname = self.request.get('nickname') aboutme = self.request.get('about-me') allusers = User.all().filter('id = ',user_id) for user in allusers: if(user): userMetaData = json.loads(user.metadata) if(userMetaData['is_first_time']): userMetaData['profile_completed'] = 1 userMetaData['is_first_time'] = 0 user.nickname = nickname user.aboutme = aboutme user.metadata = json.dumps(userMetaData) user.put() self.redirect('/home') else: self.redirect('/home') else: self.response.out.write("Sorry something went wrong, Please try again")