def get(self, username): """ """ if username == 'profile': up_dict = self.current_userprofile.to_python() username = self.current_user.username else: # Load user's profile, if available. up_dict = load_userprofile(self.db_conn, owner_username=username) if up_dict and 'email' in up_dict and 'avatar_url' not in up_dict: # ad-hoc gravatar support! email = up_dict['email'] email_hash = md5(email).hexdigest() avatar_url = 'http://www.gravatar.com/avatar/%s?s=100' % email_hash up_dict['avatar_url'] = avatar_url user_links = load_listitems(self.db_conn, owner_username=username, archived=None) user_links = ListHandlerBase.prepare_items(user_links) context = { 'userprofile': up_dict, 'links': user_links, } return self.render_template('profiles/view.html', **context)
def get(self, username): """ """ if username == 'profile': up_dict = self.current_userprofile.to_python() username = self.current_user.username else: # Load user's profile, if available. up_dict = load_userprofile(self.db_conn, username=username) if up_dict and 'email' in up_dict and 'avatar_url' not in up_dict: # ad-hoc gravatar support! email = up_dict['email'] email_hash = md5(email).hexdigest() avatar_url = 'http://www.gravatar.com/avatar/%s?s=100' % email_hash up_dict['avatar_url'] = avatar_url user_links = load_listitems(self.db_conn, owner_username=username, archived=None) user_links = ListHandlerBase.prepare_items(user_links) context = { 'userprofile': up_dict, 'links': user_links, } return self.render_template('profiles/view.html', **context)
def get_current_userprofile(self): """Attempts to load the userprofile associated with `self.current_user`. If no profile is found it prepares a blank one. """ userprofile_dict = load_userprofile(self.db_conn, owner_id=self.current_user.id) if userprofile_dict: userprofile = UserProfile(**userprofile_dict) else: up_dict = { "owner_id": self.current_user.id, "owner_username": self.current_user.username, "created_at": self.current_time, "updated_at": self.current_time, } userprofile = UserProfile(**up_dict) return userprofile
def get_current_userprofile(self): """Attempts to load the userprofile associated with `self.current_user`. If no profile is found it prepares a blank one. """ userprofile_dict = load_userprofile(self.db_conn, owner_id=self.current_user.id) if userprofile_dict: userprofile = UserProfile(**userprofile_dict) else: up_dict = { 'owner_id': self.current_user.id, 'owner_username': self.current_user.username, 'created_at': self.current_time, 'updated_at': self.current_time, } userprofile = UserProfile(**up_dict) return userprofile
def get(self, username): """ """ if username == "profile": up_dict = self.current_userprofile.to_python() username = self.current_user.username else: # Load user's profile, if available. up_dict = load_userprofile(self.db_conn, owner_username=username) if up_dict and "email" in up_dict and "avatar_url" not in up_dict: # ad-hoc gravatar support! email = up_dict["email"] email_hash = md5(email).hexdigest() avatar_url = "http://www.gravatar.com/avatar/%s?s=100" % email_hash up_dict["avatar_url"] = avatar_url user_links = load_listitems(self.db_conn, owner_username=username, archived=None) user_links = ListHandlerBase.prepare_items(user_links) context = {"userprofile": up_dict, "links": user_links} return self.render_template("profiles/view.html", **context)