本文整理汇总了Python中models.roles.Roles.is_super_admin方法的典型用法代码示例。如果您正苦于以下问题:Python Roles.is_super_admin方法的具体用法?Python Roles.is_super_admin怎么用?Python Roles.is_super_admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.roles.Roles
的用法示例。
在下文中一共展示了Roles.is_super_admin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_template_values
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def init_template_values(self, environ, prefs=None):
"""Initializes template variables with common values."""
self.template_value[COURSE_INFO_KEY] = environ
self.template_value[
'page_locale'] = self.app_context.get_current_locale()
self.template_value['html_hooks'] = HtmlHooks(
self.get_course(), prefs=prefs)
self.template_value['is_course_admin'] = Roles.is_course_admin(
self.app_context)
self.template_value['can_see_drafts'] = (
courses_module.courses.can_see_drafts(self.app_context))
self.template_value[
'is_read_write_course'] = self.app_context.fs.is_read_write()
self.template_value['is_super_admin'] = Roles.is_super_admin()
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
self.template_value['right_links'] = (
[('/admin', 'Admin')] if Roles.is_super_admin() else [])
for func in self.RIGHT_LINKS:
self.template_value['right_links'].extend(func(self.app_context))
if not prefs:
prefs = models.StudentPreferencesDAO.load_or_create()
self.template_value['student_preferences'] = prefs
if (Roles.is_course_admin(self.app_context) and
not appengine_config.PRODUCTION_MODE and
prefs and prefs.show_jinja_context):
@jinja2.contextfunction
def get_context(context):
return context
self.template_value['context'] = get_context
if CAN_PUT_DEBUG_INFO_INTO_PAGES.value:
self.template_value['debug_info'] = self.debug_info()
self.template_value[
'extra_global_css_urls'] = self.EXTRA_GLOBAL_CSS_URLS
self.template_value[
'extra_global_js_urls'] = self.EXTRA_GLOBAL_JS_URLS
# Common template information for the locale picker (only shown for
# user in session)
can_student_change_locale = (
self.get_course().get_course_setting('can_student_change_locale')
or self.get_course().app_context.can_pick_all_locales())
if can_student_change_locale:
self.template_value['available_locales'] = [
{
'name': locales.get_locale_display_name(loc),
'value': loc
} for loc in self.app_context.get_allowed_locales()]
self.template_value['locale_xsrf_token'] = (
XsrfTokenManager.create_xsrf_token(
StudentLocaleRESTHandler.XSRF_TOKEN_NAME))
self.template_value['selected_locale'] = self.get_locale_for(
self.request, self.app_context, prefs=prefs)
示例2: get_template
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def get_template(self, template_file, additional_dirs=None):
"""Computes location of template files for the current namespace."""
self.template_value[COURSE_INFO_KEY] = self.app_context.get_environ()
self.template_value["is_course_admin"] = Roles.is_course_admin(self.app_context)
self.template_value["is_super_admin"] = Roles.is_super_admin()
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
return self.app_context.get_template_environ(
self.template_value[COURSE_INFO_KEY]["course"]["locale"], additional_dirs
).get_template(template_file)
示例3: initialize_page_and_get_user
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def initialize_page_and_get_user(self):
"""Add basic fields to template and return user."""
self.template_values['course_info'] = Courses.COURSE_TEMPLATE_DICT
self.template_values['course_info']['course'] = {'locale': LOCALE}
user = users.get_current_user()
if not user:
self.template_values['loginUrl'] = users.create_login_url('/')
else:
self.template_values['email'] = user.email()
self.template_values['is_super_admin'] = Roles.is_super_admin()
self.template_values['logoutUrl'] = users.create_logout_url('/')
return user
示例4: get_template
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def get_template(self, template_file, additional_dirs=None):
"""Computes location of template files for the current namespace."""
self.template_value[COURSE_INFO_KEY] = self.app_context.get_environ()
self.template_value["is_course_admin"] = Roles.is_course_admin(self.app_context)
self.template_value["is_read_write_course"] = self.app_context.fs.is_read_write()
self.template_value["is_super_admin"] = Roles.is_super_admin()
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
template_environ = self.app_context.get_template_environ(
self.template_value[COURSE_INFO_KEY]["course"]["locale"], additional_dirs
)
template_environ.filters["gcb_tags"] = jinja_utils.get_gcb_tags_filter(self)
return template_environ.get_template(template_file)
示例5: get_template
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def get_template(self, template_file, additional_dirs=None):
"""Computes location of template files for the current namespace."""
self.template_value[COURSE_INFO_KEY] = self.app_context.get_environ()
self.template_value["is_course_admin"] = Roles.is_course_admin(self.app_context)
self.template_value["is_read_write_course"] = self.app_context.fs.is_read_write()
self.template_value["is_super_admin"] = Roles.is_super_admin()
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
template_environ = self.app_context.get_template_environ(
self.template_value[COURSE_INFO_KEY]["course"]["locale"], additional_dirs
)
template_environ.filters["gcb_tags"] = jinja_utils.get_gcb_tags_filter(self)
course = sites.get_course_for_current_request()
if course.get_slug().split("_")[-1] == "DFR":
self.template_value["gDefier_enabled"] = True
return template_environ.get_template(template_file)
示例6: get_template
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def get_template(self, template_file, additional_dirs=None):
"""Computes location of template files for the current namespace."""
self.template_value[COURSE_INFO_KEY] = self.app_context.get_environ()
self.template_value['is_course_admin'] = Roles.is_course_admin(
self.app_context)
self.template_value[
'is_read_write_course'] = self.app_context.fs.is_read_write()
self.template_value['is_super_admin'] = Roles.is_super_admin()
self.template_value['ga_analytics_key'] = GOOGLE_ANALYTICS_KEY.value
self.template_value['ga_analytics_site'] = self.request.host
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
environ = self.app_context.get_template_environ(
self.template_value[COURSE_INFO_KEY]['course']['locale'],
additional_dirs
)
self.mess_with_template_environ(environ)
return environ.get_template(template_file)
示例7: get_template
# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_super_admin [as 别名]
def get_template(self, template_file, additional_dir=None):
"""Computes location of template files for the current namespace."""
self.template_value[COURSE_INFO_KEY] = self.app_context.get_environ()
self.template_value['is_course_admin'] = Roles.is_course_admin(
self.app_context)
self.template_value['is_super_admin'] = Roles.is_super_admin()
self.template_value[COURSE_BASE_KEY] = self.get_base_href(self)
template_dir = self.app_context.get_template_home()
dirs = [template_dir]
if additional_dir:
dirs += additional_dir
jinja_environment = jinja2.Environment(
extensions=['jinja2.ext.i18n'],
loader=jinja2.FileSystemLoader(dirs))
jinja_environment.install_gettext_translations(i18n)
locale = self.template_value[COURSE_INFO_KEY]['course']['locale']
i18n.get_i18n().set_locale(locale)
return jinja_environment.get_template(template_file)