def can_edit(cls, action): """Checks if current user has editing rights.""" app_context = sites.get_app_context_for_current_request() if action in cls._post_action_to_permission: return cls._post_action_to_permission[action](app_context) return roles.Roles.is_course_admin(app_context)
def is_enabled(): # TODO(mgainer): Add tests to verify that this does the right thing # when this module is re-enabled in manifest.yaml. # Enabled/disabled in manifest.yaml if not custom_module.enabled: return False # If we don't have a course, we can't reasonably expect to have course news. app_context = sites.get_app_context_for_current_request() if not app_context: return False # Enabled at course level? settings = app_context.get_environ() news_settings = settings.get(NEWS_SETTINGS_SECTION, {}) return news_settings.get(IS_NEWS_ENABLED_SETTING, True) # True if unset.
def _get_i18n_news_title(_unused_key): app_context = sites.get_app_context_for_current_request() # I18N: Shown in list of news item titles (short descriptions) # when student has earned a course completion certificate. return app_context.gettext('Course completion certificate earned!')
def _get_settings(): from controllers import sites return sites.get_app_context_for_current_request().get_environ()
def _get_course(): from controllers import sites return courses.Course( None, app_context=sites.get_app_context_for_current_request())