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


Python Roles.is_course_admin方法代码示例

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


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

示例1: init_template_values

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_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['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,代码行数:61,代码来源:utils.py

示例2: insert

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:34,代码来源:utils.py

示例3: get

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:35,代码来源:student_csv.py

示例4: get

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:36,代码来源:vanilla.py

示例5: get

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:30,代码来源:utils.py

示例6: get_public_courses

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
 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,代码行数:10,代码来源:student.py

示例7: get

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:60,代码来源:utils.py

示例8: get_template

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_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)
开发者ID:sesamesushi,项目名称:satisrevude,代码行数:11,代码来源:utils.py

示例9: get

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
 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,代码行数:11,代码来源:booctools.py

示例10: post_save

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    def post_save(self):
        if not Roles.is_course_admin(self.app_context):
            self.abort(403, 'You are not an admin :(')
        user = self.personalize_page_and_get_enrolled()

        student_email = self.request.GET.get('email', None)
        if not student_email:
            self.abort(404, 'email= parameter required')
        student = Student.get_enrolled_student_by_email(student_email)
        if not student:
            self.abort(404, Markup('Could not find a student with email "%s"') % student_email)

        badge_slug = custom_badge_name(student)
        badge = Badge.get_or_insert(badge_slug)

        badge_form = BadgeForm(self.request.POST, badge)
        comments_form = CommentsForm(self.request.POST)
        if not (badge_form.validate() and comments_form.validate()):
            self.render_edit(badge_form, comments_form)
            return

        comments_form.validate()
        reviewer = Student.get_by_email(comments_form.review_source.data)
        if not reviewer:
            comments_form.review_source.errors.append("Could not find a user with that e-mail address")
            self.render_edit(badge_form, comments_form)
            return

        page = WikiPage.get_page(student, unit=UNIT_NUMBER)
        if not page:
            self.abort(404, Markup('Could not find unit %d wikifolio for student "%s"') % (UNIT_NUMBER, student_email))

        old_reviews = Annotation.reviews(whose=student, unit=UNIT_NUMBER).run()
        db.delete(old_reviews)
        Annotation.review(page, who=reviewer, text=comments_form.public_comments.data)

        if not Annotation.endorsements(what=page, who=user).count(limit=1):
            Annotation.endorse(page, who=user, optional_done=True)
        
        badge_form.populate_obj(badge)
        badge.put()

        report = PartReport.on(student, self.get_course(), 4, force_re_run=True, put=False)
        for rep in report.unit_reports:
            rep._run()
            rep.put()
        report.slug = badge_slug
        report.put()
        assertion = Badge.issue(badge, student, put=False)
        assertion.evidence = urljoin(self.request.host_url, '/badges/evidence?id=%d' % report.key().id())
        assertion.put()
        self.response.write(
                Markup("Issued badge %s to %s, evidence %s") % (
                    badge.key().name(), student_email, assertion.evidence))
开发者ID:twiffy,项目名称:eabooc,代码行数:56,代码来源:custom_badge.py

示例11: get_view

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    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,代码行数:13,代码来源:student_csv.py

示例12: get_template

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_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)
开发者ID:nicholaschris,项目名称:massive-wight,代码行数:14,代码来源:utils.py

示例13: post_start

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_admin [as 别名]
    def post_start(self):
        if not Roles.is_course_admin(self.app_context):
            self.abort(403)

        form = self.NavForm(self.request.POST)
        if not form.validate():
            self.render_form(form)
            return

        query_class = mapper_queries[form.query.data]
        mapper = query_class(course=self.get_course(), unit=form.unit.data, host_url=self.request.host_url)
        assert isinstance(mapper, TableMakerMapper)
        job_id = mapper.job_id
        deferred.defer(mapper.run, batch_size=50)
        self.redirect(self._action_url('watch', job_id=job_id))
开发者ID:twiffy,项目名称:eabooc,代码行数:17,代码来源:student_csv.py

示例14: get_template

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_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)
开发者ID:diego-G,项目名称:gdefier,代码行数:19,代码来源:utils.py

示例15: get_template

# 需要导入模块: from models.roles import Roles [as 别名]
# 或者: from models.roles.Roles import is_course_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)
开发者ID:twiffy,项目名称:eabooc,代码行数:19,代码来源:utils.py


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