def test_reset_notification_count_upon_read(self): video = self.make_video() asker = self.make_user_data('*****@*****.**') answerer = self.make_user_data('*****@*****.**') question = self.make_question("Where did Harry go?", video, asker) self.make_answer("He went to the loo.", question, answerer) notification.clear_notification_for_question(question.key(), asker) self.assertEqual(0, asker.feedback_notification_count())
def get(self): page = 0 try: page = int(self.request.get("page")) except: pass video_key = self.request.get("video_key") qa_expand_key = self.request_string("qa_expand_key") sort = self.request_int("sort", default=-1) video = db.get(video_key) user_data = user_models.UserData.current() count = user_data.feedback_notification_count() if user_data else 0 if qa_expand_key: # Clear unread answer notification for expanded question count = notification.clear_notification_for_question(qa_expand_key) if video: template_values = video_qa_context(user_data, video, 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, "count_notifications": count, }) return
def get(self): page = 0 try: page = int(self.request.get("page")) except: pass video_key = self.request.get("video_key") qa_expand_key = self.request_string("qa_expand_key") sort = self.request_int("sort", default=-1) video = db.get(video_key) user_data = user_models.UserData.current() count = user_data.feedback_notification_count() if user_data else 0 if qa_expand_key: # Clear unread answer notification for expanded question count = notification.clear_notification_for_question(qa_expand_key) if video: template_values = video_qa_context(user_data, video, 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, "count_notifications": count, }) return
def get_questions_for_video(readable_id, qa_expand_key, page, sort): """Get a list of util_discussion.ClientFeedback entities corresponding to the questions and answers below the specified video. Arguments: qa_expand_key: the key of a question to be included in the response page: the desired page number sort: one of possible sort orders in voting.VotingSortOrder """ video = video_models.Video.get_for_readable_id(readable_id) if not video: return None user_data = user_models.UserData.current() count = user_data.feedback_notification_count() if user_data else 0 restrict_posting = user_data and user_data.is_child_account() if qa_expand_key: # Clear unread answer notification for expanded question count = notification.clear_notification_for_question(qa_expand_key) if video: context = video_qa_context(user_data, video, page, qa_expand_key, sort) context['questions'] = [ util_discussion.ClientFeedback.from_feedback( question, with_extra_vote_properties=True) for question in context['questions'] ] context['count_notifications'] = count context['temp_video_key'] = str(video.key()) context['show_mod_controls'] = user_data and user_data.moderator context['restrict_posting'] = restrict_posting return context return None
def get_questions_for_video(readable_id, qa_expand_key, page, sort): """Get a list of util_discussion.ClientFeedback entities corresponding to the questions and answers below the specified video. Arguments: qa_expand_key: the key of a question to be included in the response page: the desired page number sort: one of possible sort orders in voting.VotingSortOrder """ video = video_models.Video.get_for_readable_id(readable_id) if not video: return None user_data = user_models.UserData.current() count = user_data.feedback_notification_count() if user_data else 0 restrict_posting = user_data and user_data.is_child_account() if qa_expand_key: # Clear unread answer notification for expanded question count = notification.clear_notification_for_question(qa_expand_key) if video: context = video_qa_context(user_data, video, page, qa_expand_key, sort) context['questions'] = [util_discussion.ClientFeedback.from_feedback( question, with_extra_vote_properties=True) for question in context['questions']] context['count_notifications'] = count context['temp_video_key'] = str(video.key()) context['show_mod_controls'] = user_data and user_data.moderator context['restrict_posting'] = restrict_posting return context return None
def post(self): qa_expand_key = self.request.get("qa_expand_key") notification.clear_notification_for_question(qa_expand_key)