def GET(self): page = web.input(page=1)['page'] service = web.input(service=None)['service'] category = web.input(category=None)['category'] logout = web.input(logout='false')['logout'] user_info = None associated_sites = None associated_sites_keys = None user = web.ctx.env.get('webob.adhoc_attrs').get('user') if user and user.auth_ids: profile_keys = [ndb.Key('UserProfile', p) for p in user.auth_ids] profiles = ndb.get_multi(profile_keys) user_info = profiles[0].user_info['extra']['raw_info'] associated_sites = profiles[0].user_info['extra'][ 'associated_sites'] associated_sites_keys = profiles[0].user_info['extra'][ 'associated_sites_keys'] if category in ('favorites', 'asked', 'answered') and user_info: se_downloader = StackExchangeDownloader(service) if category == 'favorites': result, pagination = se_downloader.get_favorites_questions( associated_sites[service]['user_id'], page) if category == 'asked': result, pagination = se_downloader.get_asked_questions( associated_sites[service]['user_id'], page) if category == 'answered': result, pagination = se_downloader.get_answered_questions( associated_sites[service]['user_id'], page) return render.myse_questions(user_info['display_name'], associated_sites[service]['user_id'], result, service, pagination, category) if logout == 'true' and user_info: StackAuthDownloader.invalidate_auth_token( (profiles[0].credentials).access_token) web.ctx.env.get('webob.adhoc_attrs').get('session').key.delete() user.key.delete() profiles[0].key.delete() web.redirect('/myse') return render.myse(user_info, associated_sites, associated_sites_keys)
def GET(self): page = web.input(page = 1)['page'] service = web.input(service = None)['service'] category = web.input(category = None)['category'] logout = web.input(logout = 'false')['logout'] user_info = None associated_sites = None associated_sites_keys = None user = web.ctx.env.get('webob.adhoc_attrs').get('user') if user and user.auth_ids: profile_keys = [ndb.Key('UserProfile', p) for p in user.auth_ids] profiles = ndb.get_multi(profile_keys) user_info = profiles[0].user_info['extra']['raw_info'] associated_sites = profiles[0].user_info['extra']['associated_sites'] associated_sites_keys = profiles[0].user_info['extra']['associated_sites_keys'] if category in ('favorites','asked','answered') and user_info: se_downloader = StackExchangeDownloader(service) if category == 'favorites': result, pagination = se_downloader.get_favorites_questions(associated_sites[service]['user_id'], page) if category == 'asked': result, pagination = se_downloader.get_asked_questions(associated_sites[service]['user_id'], page) if category == 'answered': result, pagination = se_downloader.get_answered_questions(associated_sites[service]['user_id'], page) return render.myse_questions(user_info['display_name'], associated_sites[service]['user_id'], result, service, pagination, category) if logout == 'true' and user_info: StackAuthDownloader.invalidate_auth_token((profiles[0].credentials).access_token) web.ctx.env.get('webob.adhoc_attrs').get('session').key.delete() user.key.delete() profiles[0].key.delete() web.redirect('/myse') return render.myse(user_info, associated_sites, associated_sites_keys)