def get(self): """Handles GET requests.""" self.values.update({ 'nav_mode': feconf.NAV_MODE_GALLERY, 'allow_yaml_file_upload': ALLOW_YAML_FILE_UPLOAD.value, 'gallery_login_redirect_url': (current_user_services.create_login_url( feconf.GALLERY_CREATE_MODE_URL)), 'has_fully_registered': bool( self.user_id and user_services.has_fully_registered(self.user_id)), 'SPLASH_PAGE_YOUTUBE_VIDEO_ID': SPLASH_PAGE_YOUTUBE_VIDEO_ID.value, 'CAROUSEL_SLIDES_CONFIG': CAROUSEL_SLIDES_CONFIG.value, 'LANGUAGE_CODES_AND_NAMES': [{ 'code': lc['code'], 'name': utils.get_short_language_description(lc['description']), } for lc in feconf.ALL_LANGUAGE_CODES], }) self.render_template('galleries/gallery.html')
def get(self): """Handles GET requests.""" # TODO(sll): Figure out what to do about explorations in categories # other than those explicitly listed. language_codes_to_short_descs = { lc['code']: utils.get_short_language_description(lc['description']) for lc in feconf.ALL_LANGUAGE_CODES } query_string = self.request.get('q') search_cursor = self.request.get('cursor', None) exp_summaries_list, search_cursor = ( exp_services.get_exploration_summaries_matching_query( query_string, cursor=search_cursor)) def _get_intro_card_color(category): return ( feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR) # TODO(msl): Store 'is_editable' in exploration summary to avoid O(n) # individual lookups. Note that this will depend on user_id. explorations_list = [{ 'id': exp_summary.id, 'title': exp_summary.title, 'category': exp_summary.category, 'objective': exp_summary.objective, 'language_code': exp_summary.language_code, 'last_updated': utils.get_time_in_millisecs( exp_summary.exploration_model_last_updated), 'status': exp_summary.status, 'community_owned': exp_summary.community_owned, 'thumbnail_image_url': ( '/images/gallery/exploration_background_%s_small.png' % _get_intro_card_color(exp_summary.category)), 'is_editable': exp_services.is_exp_summary_editable( exp_summary, user_id=self.user_id), 'ratings': exp_summary.ratings } for exp_summary in exp_summaries_list] if len(explorations_list) == feconf.DEFAULT_QUERY_LIMIT: logging.error( '%s explorations were fetched to load the gallery page. ' 'You may be running up against the default query limits.' % feconf.DEFAULT_QUERY_LIMIT) preferred_language_codes = [feconf.DEFAULT_LANGUAGE_CODE] if self.user_id: user_settings = user_services.get_user_settings(self.user_id) preferred_language_codes = user_settings.preferred_language_codes self.values.update({ 'explorations_list': explorations_list, 'preferred_language_codes': preferred_language_codes, 'search_cursor': search_cursor, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" self.values.update({ 'nav_mode': feconf.NAV_MODE_GALLERY, 'allow_yaml_file_upload': ALLOW_YAML_FILE_UPLOAD.value, 'gallery_login_redirect_url': (current_user_services.create_login_url( feconf.GALLERY_CREATE_MODE_URL)), 'has_fully_registered': bool(self.user_id and user_services.has_fully_registered(self.user_id)), 'SPLASH_PAGE_YOUTUBE_VIDEO_ID': SPLASH_PAGE_YOUTUBE_VIDEO_ID.value, 'CAROUSEL_SLIDES_CONFIG': CAROUSEL_SLIDES_CONFIG.value, 'LANGUAGE_CODES_AND_NAMES': [{ 'code': lc['code'], 'name': utils.get_short_language_description(lc['description']), } for lc in feconf.ALL_LANGUAGE_CODES], }) self.render_template('galleries/gallery.html')
def get(self): """Handles GET requests.""" self.values.update({ 'nav_mode': feconf.NAV_MODE_PROFILE, 'LANGUAGE_CODES_AND_NAMES': [{ 'code': lc['code'], 'name': utils.get_short_language_description( lc['description']), } for lc in feconf.ALL_LANGUAGE_CODES], }) self.render_template( 'profile/preferences.html', redirect_url_on_logout='/')
def get(self): """Handles GET requests.""" self.values.update( { "nav_mode": feconf.NAV_MODE_PROFILE, "LANGUAGE_CODES_AND_NAMES": [ {"code": lc["code"], "name": utils.get_short_language_description(lc["description"])} for lc in feconf.ALL_LANGUAGE_CODES ], } ) self.render_template("profile/preferences.html", redirect_url_on_logout="/")
def get(self): """Handles GET requests.""" # TODO(sll): Figure out what to do about explorations in categories # other than those explicitly listed. language_codes_to_short_descs = { lc['code']: utils.get_short_language_description(lc['description']) for lc in feconf.ALL_LANGUAGE_CODES } query_string = self.request.get('q') search_cursor = self.request.get('cursor', None) exp_summaries_list, search_cursor = ( exp_services.get_exploration_summaries_matching_query( query_string, cursor=search_cursor)) def _get_intro_card_color(category): return (feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR) # TODO(msl): Store 'is_editable' in exploration summary to avoid O(n) # individual lookups. Note that this will depend on user_id. explorations_list = [{ 'id': exp_summary.id, 'title': exp_summary.title, 'category': exp_summary.category, 'objective': exp_summary.objective, 'language_code': exp_summary.language_code, 'last_updated': utils.get_time_in_millisecs( exp_summary.exploration_model_last_updated), 'status': exp_summary.status, 'community_owned': exp_summary.community_owned, 'thumbnail_image_url': ('/images/gallery/exploration_background_%s_small.png' % _get_intro_card_color(exp_summary.category)), 'is_editable': exp_services.is_exp_summary_editable(exp_summary, user_id=self.user_id) } for exp_summary in exp_summaries_list] if len(explorations_list) == feconf.DEFAULT_QUERY_LIMIT: logging.error( '%s explorations were fetched to load the gallery page. ' 'You may be running up against the default query limits.' % feconf.DEFAULT_QUERY_LIMIT) preferred_language_codes = [feconf.DEFAULT_LANGUAGE_CODE] if self.user_id: user_settings = user_services.get_user_settings(self.user_id) preferred_language_codes = user_settings.preferred_language_codes self.values.update({ 'explorations_list': explorations_list, 'preferred_language_codes': preferred_language_codes, 'search_cursor': search_cursor, }) self.render_json(self.values)