当前位置: 首页>>代码示例>>Python>>正文


Python roles.Roles类代码示例

本文整理汇总了Python中models.roles.Roles的典型用法代码示例。如果您正苦于以下问题:Python Roles类的具体用法?Python Roles怎么用?Python Roles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Roles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_template_values

    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['left_links'] = []
        for func in self.LEFT_LINKS:
            self.template_value['left_links'].extend(func(self.app_context))
        self.template_value['right_links'] = []
        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)
开发者ID:ehiller,项目名称:course-builder,代码行数:59,代码来源:utils.py

示例2: get_public_courses

 def get_public_courses(self):
     """Get all the public courses."""
     public_courses = []
     for course in sites.get_all_courses():
         if ((course.now_available and Roles.is_user_whitelisted(course))
             or Roles.is_course_admin(course)):
             public_courses.append(course)
     return public_courses
开发者ID:CSCI1200Course,项目名称:csci1200OnlineCourse,代码行数:8,代码来源:student.py

示例3: get_template

 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)
开发者ID:sesamesushi,项目名称:satisrevude,代码行数:9,代码来源:utils.py

示例4: get_template

 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)
开发者ID:nicholaschris,项目名称:massive-wight,代码行数:12,代码来源:utils.py

示例5: get

    def get(self):
        param_map = {}
        for k in self.request.arguments():
            param_map[k] = self.request.get(k)
        client_id = param_map.get('client_id', 0)

        logging.debug("vanilla request: " + str(param_map))

        user = users.get_current_user()
        if Roles.is_course_admin(self.app_context):
            role= "administrator"
        else:
            role="member"

        logging.debug(str(user))

        if user:
            student = Student.get_enrolled_student_by_email(user.email())
            user = {
                "name": student.name,
                "email": user.email(),
                "uniqueid": user.user_id(),
                "photourl": "",
            }
        course = self.app_context.get_environ()['course']

        client_id = course['VANILLA_CLIENT_ID']
        secret_key = course['VANILLA_SECRET_KEY']

        jsconn_str = get_jsconnect_string(user, param_map, client_id, secret_key)

        logging.debug("mooc-ed response: " + jsconn_str)

        self.response.out.write(jsconn_str)
开发者ID:barkinet,项目名称:coursebuilder_plugin_vanilla,代码行数:34,代码来源:vanilla.py

示例6: get

    def get(self):
        if not Roles.is_course_admin(self.app_context):
            self.error(403)
            self.response.write("NO")
            return

        nav = self._get_nav()
        if not nav:
            self.render_choices_page()
            return

        query_class = analytics_queries.get(nav['query'], None)
        if not query_class:
            logging.warn("Unrecognized query")
            self.abort(404, "I couldn't find the query that you requested.")

        try:
            query = query_class(self)
        except ValueError as e:
            self.render_choices_page(error=e.message)
            return

        if nav['view'] == 'csv':
            self.render_as_csv(query.fields, query.run())
        elif nav['view'] == 'debug':
            i = query.run()
            for x in i:
                pass
        else:
            iterator = query.run()
            if hasattr(query_class, 'htmlize_row'):
                iterator = [query.htmlize_row(r) for r in iterator]
            self.render_as_table(query.fields, iterator)
开发者ID:twiffy,项目名称:eabooc,代码行数:33,代码来源:student_csv.py

示例7: get_schema

    def get_schema(cls):
        """Return the InputEx schema for the roles editor."""
        schema = schema_fields.FieldRegistry(
            'Role', description='role')

        schema.add_property(schema_fields.SchemaField(
            'version', '', 'string', optional=True, hidden=True))
        schema.add_property(schema_fields.SchemaField(
            'name', 'Name', 'string', optional=False,
            description=messages.ROLE_NAME_DESCRIPTION))
        schema.add_property(schema_fields.SchemaField(
            'description', 'Description', 'text', optional=True,
            description=messages.ROLE_DESCRIPTION_DESCRIPTION))
        # TODO(gdejonghe) Use user.id instead of user.email
        schema.add_property(schema_fields.SchemaField(
            'users', 'User Emails', 'text',
            description=messages.ROLE_USER_EMAILS_DESCRIPTION))

        subschema = schema.add_sub_registry('modules', 'Permission Modules')

        for module in Roles.get_modules():
            cls._add_module_permissions_schema(subschema, module.name)
        cls._add_module_permissions_schema(subschema, cls.INACTIVE_MODULES)

        return schema
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:25,代码来源:role_editor.py

示例8: get

    def get(self):
        """Handles GET requests."""
        if not Roles.is_course_admin(self.app_context):
            self.redirect('/preview')
            return

        student = self.personalize_page_and_get_enrolled(
            supports_transient_student=True)
        if not student:
            return
        else:
            # Set template value for progress bar that shows on the top navigation(header.html)
            total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
            self.template_value['progress_value'] = total_progress.get('progress_score', 0)
            self.template_value['complete_value'] = total_progress.get('completed_score', 0)
            self.template_value['percentage'] = total_progress.get('percentage', '')

        # Set template value for Google Community ID
        self.set_google_community_template_value()

        all_students = self.get_students()
        i = 0
        for s in all_students:
            i = i + 1
        self.template_value['navbar'] = {'students': True}
        self.template_value['total_students'] = i
        self.template_value['students_data'] = all_students
        self.render('students.html')
开发者ID:cglmoocs,项目名称:cgl-mooc-builder,代码行数:28,代码来源:utils.py

示例9: insert

    def insert(self, name):
        # Do we want page markup to permit course admins to edit hooks?
        show_admin_content = False
        if (self.prefs and self.prefs.show_hooks and
            Roles.is_course_admin(self.course.app_context)):
            show_admin_content = True
        if self.course.version == courses.CourseModel12.VERSION:
            show_admin_content = False

        # Look up desired content chunk in course.yaml dict/sub-dict.
        content = ''
        environ = self.course.app_context.get_environ()
        for part in name.split(':'):
            if part in environ:
                item = environ[part]
                if type(item) == str:
                    content = item
                else:
                    environ = item
        if show_admin_content and not self._has_visible_content(content):
            content += name

        # Add the content to the page in response to the hook call.
        hook_div = safe_dom.Element('div', className='gcb-html-hook',
                                    id=re.sub('[^a-zA-Z-]', '-', name))
        hook_div.add_child(tags.html_to_safe_dom(content, self))

        # Mark up content to enable edit controls
        if show_admin_content:
            hook_div.add_attribute(onclick='gcb_edit_hook_point("%s")' % name)
            hook_div.add_attribute(className='gcb-html-hook-edit')
        return jinja2.Markup(hook_div.sanitized)
开发者ID:Rosebotics,项目名称:RoseboticsWeb,代码行数:32,代码来源:utils.py

示例10: get_template

    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)
开发者ID:diego-G,项目名称:gdefier,代码行数:17,代码来源:utils.py

示例11: get_template

 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)
开发者ID:twiffy,项目名称:eabooc,代码行数:17,代码来源:utils.py

示例12: get

    def get(self):


        if not(Roles.is_course_admin(self.app_context)):
            self.redirect("preview")

        self.response.headers['Content-type'] = 'text/csv'
        self.response.headers['Content-disposition'] = 'attachment; filename=students.csv'


        course = self.get_course()

        assessments=[]

        for unit in course.get_units():
            if (unit.type=="A"):
                assessments.append(str(unit.unit_id))


        writer = UnicodeWriter(self.response.out)

        keys = Student.all(keys_only=True).run()

        rows=[]

        for key in keys:

            student=Student.get_by_key_name(key.name())

            rec={"email": key.name(), "name": student.name, "enrolled": unicode(student.is_enrolled), "dateEnrolled": unicode(student.enrolled_on) }

            if (student.scores):
                scores=json.loads(student.scores)

                for assessmentName, score in scores.iteritems():
                    rec[assessmentName]=str(score)


            rows.append(rec)

        headerRow = ["Email", "Name", "Is Enrolled", "Enrolled On"]

        for assessmentName in assessments:
            headerRow.append(course.find_unit_by_id(assessmentName).title)

        writer.writerow(headerRow)

        for row in rows:

            renderedRow=[row["email"],row["name"],row["enrolled"],row["dateEnrolled"]]

            for assessmentName in assessments:
                if (assessmentName in row):
                    renderedRow.append(row[assessmentName])
                else:
                    renderedRow.append("")

            writer.writerow(renderedRow)
开发者ID:graemian,项目名称:ami-mooc-pilot,代码行数:58,代码来源:utils.py

示例13: get

 def get(self):
     user = self.personalize_page_and_get_enrolled()
     if not user:
         return
     if not Roles.is_course_admin(self.app_context):
         self.abort(403)
     self.template_value['student_count'] = get_student_count()
     self.template_value['navbar'] = {'booctools': True}
     self.render('booctools.html')
开发者ID:twiffy,项目名称:eabooc,代码行数:9,代码来源:booctools.py

示例14: _update_dict_with_permissions

 def _update_dict_with_permissions(self, dictionary):
     app_context = self.get_course().app_context
     modules = {}
     for (module, callback) in Roles.get_permissions():
         modules[module.name] = []
         for (permission, description) in callback(app_context):
             modules[module.name].append(
                 self._generate_permission(permission, description, False))
     dictionary['modules'] = modules
     return dictionary
开发者ID:kingctan,项目名称:course-builder,代码行数:10,代码来源:role_editor.py

示例15: get_view

    def get_view(self):
        if not Roles.is_course_admin(self.app_context):
            self.abort(403)

        job_id = self.request.GET.get('job_id', None)
        if not job_id:
            self.abort(404)

        result = TableMakerResult(job_id)
        fields = result.fields
        self.render_as_table(fields, result)
开发者ID:twiffy,项目名称:eabooc,代码行数:11,代码来源:student_csv.py


注:本文中的models.roles.Roles类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。