def get(self, username, name): adata = UserData.load_from_nickname(username) author = adata.user page_admin = self.page_admin(author) name = urllib.unquote_plus(urllib.unquote(name)) unix_name = utils.unix_string(name) context = self.context context['author'] = author context['page_author'] = adata context['page_admin'] = page_admin # Check to see if we already have a profile for that character. profile = Profile.get_by_key_name( stores.Profile.key_name_form % (unix_name, adata.key_name) ) # If we can't find that character and we're the author we may want to # make it, other wise we should move the user back to the user page. if not profile or (not profile.public and not page_admin): self.flash.msg = "Unknown Profile: %s" % name self.redirect(Profile.get_url(username)) return context['profile'] = profile self.render(['delete', 'deleteprofile'], context)
def get(self, username): get = self.request.get name = get('name') if name: # Redriect people to the updated url format. self.redirect(Profile.get_url(username, urllib.quote_plus(name)), permanent=True) return adata = UserData.load_from_nickname(username) if not adata: self.redirect('/404/') return author = adata.user page_admin = self.page_admin(author) get = self.request.get action = get('action') refresh_cache = get('refresh_cache', False) is not False sterile_url = framework.sterilize_url(self.request.url) context = self.context context['author'] = author context['adata'] = adata context['page_admin'] = page_admin def __build_profile_data(): order = get('order', 'created').lower() page = self.request.get_range('profiles_page', min_value=1, default=1) # Allow page numbers to be more natural items_per_page = self.request.get_range('profiles_items', min_value=1, max_value=25, default=10) offset = ((page - 1) * items_per_page) last_page = True # Orders the profiles most recently created first. query = Profile.all() query.filter('author =', adata) if not page_admin: query.filter('public =', True) if order == 'alpha': query.order('name') else: query.order('-created') profiles = query.fetch((items_per_page + 1), offset) # Since each page is 6 items long if there are 7 items then we # know that there is at least one more page. if len(profiles) > items_per_page: last_page = False profiles.pop() @framework.memoize(sterile_url, 'profile_listing', refresh=refresh_cache) def fetch(): return profiles return {'profiles':fetch(), 'page':page, 'last_page':last_page} @framework.memoize(sterile_url, 'world_listing', refresh=refresh_cache) def __fetch_world_memberships(): query = WorldMember.all() query.filter('user ='******'profile_data'] = __build_profile_data() context['profile_data']['partial_listing'] = True context['profile_data']['list_edit'] = True context['profile_data']['list_pages'] = True context['world_data'] = { 'worlds': __fetch_world_memberships(), 'list_author': True, } c = counter.Counter('%sProfiles' % adata.key_name, 1) context['profile_count'] = c.get_count(refresh_cache) c = counter.Counter('%sWorlds' % adata.key_name, 1) context['world_count'] = c.get_count(refresh_cache) c = counter.Counter('%sTotalWords' % adata.key_name, 1) context['total_word_count'] = c.get_count(refresh_cache) self.render(['view', 'viewUser']) return