def get(self): current_user = users.get_current_user() youtify_user = get_current_youtify_user_model() if (current_user is not None) and (youtify_user is None): youtify_user = create_youtify_user_model() path = os.path.join(os.path.dirname(__file__), 'html', 'translations.html') self.response.headers['Content-Type'] = 'text/html; charset=utf-8' self.response.out.write( template.render( path, { 'is_admin': simplejson.dumps(users.is_current_user_admin()), 'my_langs': simplejson.dumps(get_leader_langs_for_user(youtify_user)), 'my_user_email': current_user.email(), 'my_user_name': current_user.nickname().split('@')[0], 'my_user_id': youtify_user.key().id(), 'logout_url': users.create_logout_url('/'), 'languages': [ lang for lang in get_languages() if lang['enabled_in_tool'] ], }))
def get(self): current_user = users.get_current_user() user = get_current_youtify_user_model() if (current_user is not None) and (user is None): user = create_youtify_user_model() path = os.path.join(os.path.dirname(__file__), 'html', 'admin.html') self.response.headers['Content-Type'] = 'text/html; charset=utf-8' self.response.out.write(template.render(path, { 'my_user_name': user.google_user2.nickname().split('@')[0], 'my_user_email': user.google_user2.email(), 'my_user_id': user.key().id(), 'logout_url': users.create_logout_url('/'), 'languages': [lang for lang in get_languages() if lang['enabled_in_tool']], }))
def get(self): my_followers_struct = [] my_followings_struct = [] settings_struct = {} youtify_user_struct = None current_user = users.get_current_user() youtify_user_model = get_current_youtify_user_model() if (current_user is not None) and (youtify_user_model is None): youtify_user_model = create_youtify_user_model() if youtify_user_model is not None: youtify_user_model.device = generate_device_token() youtify_user_model.last_login = datetime.now() youtify_user_struct = get_youtify_user_struct( youtify_user_model, include_private_data=True) # https://developers.google.com/appengine/docs/python/runtime#Request_Headers youtify_user_model.country = self.request.headers.get( 'X-AppEngine-Country', None) youtify_user_model.reqion = self.request.headers.get( 'X-AppEngine-Region', None) youtify_user_model.city = self.request.headers.get( 'X-AppEngine-City', None) youtify_user_model.latlon = self.request.headers.get( 'X-AppEngine-CityLatLong', None) youtify_user_model.save() my_followers_struct = get_followers_for_youtify_user_model( youtify_user_model) my_followings_struct = get_followings_for_youtify_user_model( youtify_user_model) settings_struct = get_settings_struct_for_youtify_user_model( youtify_user_model) lang_code = auto_detect_language(self.request) json = { 'ON_PRODUCTION': config.ON_PRODUCTION, 'SEARCH_STATS_URL': config.SEARCH_STATS_URL, 'languagesFromServer': get_languages(), 'device': youtify_user_model is not None and youtify_user_model.device, 'user': youtify_user_struct, 'lastNotificationSeenTimestamp': youtify_user_model is not None and youtify_user_model.last_notification_seen_timestamp, 'myFollowers': my_followers_struct, 'myFollowings': my_followings_struct, 'settingsFromServer': settings_struct, 'autoDetectedLanguageByServer': lang_code, 'autoDetectedTranslations': get_translations_for_lang(lang_code), 'loginUrl': users.create_login_url('/'), 'logoutUrl': users.create_logout_url('/'), } self.response.headers['Content-Type'] = 'application/json' self.response.out.write(simplejson.dumps(json))