示例#1
0
    def get(self):

        page = 0
        try:
            page = int(self.request.get("page"))
        except:
            pass

        video_key = self.request.get("video_key")
        playlist_key = self.request.get("playlist_key")
        qa_expand_key = self.request_string("qa_expand_key")
        sort = self.request_int("sort", default=-1)

        try:
            video = db.get(video_key)
        except db.BadRequestError:
            # Temporarily ignore errors caused by cached google pages of non-HR app
            return

        playlist = db.get(playlist_key)

        user_data = models.UserData.current()

        if video:
            template_values = video_qa_context(user_data, video, playlist, page, qa_expand_key, sort)
            html = self.render_jinja2_template_to_string("discussion/video_qa_content.html", template_values)
            self.render_json({"html": html, "page": page, "qa_expand_key": qa_expand_key})

        if qa_expand_key > 0:
            # If a QA question is being expanded, we want to clear notifications for its
            # answers before we render page_template so the notification icon shows
            # its updated count. 
            notification.clear_question_answers_for_current_user(qa_expand_key)

        return
示例#2
0
    def get(self):

        page = 0
        try:
            page = int(self.request.get("page"))
        except:
            pass

        video_key = self.request.get("video_key")
        topic_key = self.request.get("topic_key")
        qa_expand_key = self.request_string("qa_expand_key")
        sort = self.request_int("sort", default=-1)

        try:
            video = db.get(video_key)
        except db.BadRequestError:
            # Temporarily ignore errors caused by cached google pages of non-HR app
            return

        user_data = models.UserData.current()

        if video:
            try:
                topic = db.get(topic_key)
            except db.BadKeyError:
                topic = video.first_topic()

            template_values = video_qa_context(user_data, video, topic, page,
                                               qa_expand_key, sort)
            html = self.render_jinja2_template_to_string(
                "discussion/video_qa_content.html", template_values)
            self.render_json({
                "html": html,
                "page": page,
                "qa_expand_key": qa_expand_key
            })

        if qa_expand_key > 0:
            # If a QA question is being expanded, we want to clear notifications for its
            # answers before we render page_template so the notification icon shows
            # its updated count.
            notification.clear_question_answers_for_current_user(qa_expand_key)

        return
示例#3
0
文件: qa.py 项目: genb/khanacademy
 def post(self):
     notification.clear_question_answers_for_current_user(self.request.get("qa_expand_id"))
示例#4
0
文件: qa.py 项目: di445/khanacademy
 def post(self):
     notification.clear_question_answers_for_current_user(self.request.get("qa_expand_id"))