def test_reject_voiceover_application(self): voiceover_services.create_new_voiceover_application( suggestion_models.TARGET_TYPE_EXPLORATION, '0', 'en', '', 'audio_file.mp3', self.applicant_id) user_voiceover_applications = ( voiceover_services.get_user_submitted_voiceover_applications( self.applicant_id)) self.assertEqual(len(user_voiceover_applications), 1) self.assertEqual(user_voiceover_applications[0].status, suggestion_models.STATUS_IN_REVIEW) opportunities, _, more = ( opportunity_services.get_voiceover_opportunities('en', None)) self.assertEqual(len(opportunities), 1) self.assertFalse(more) voiceover_services.reject_voiceover_application( user_voiceover_applications[0].voiceover_application_id, self.admin_id, 'Rejection message') user_voiceover_applications = ( voiceover_services.get_user_submitted_voiceover_applications( self.applicant_id)) self.assertEqual(len(user_voiceover_applications), 1) self.assertEqual(user_voiceover_applications[0].status, suggestion_models.STATUS_REJECTED) opportunities, _, more = ( opportunity_services.get_voiceover_opportunities('en', None)) self.assertEqual(len(opportunities), 1) self.assertFalse(more)
def test_accept_application_removes_exploration_voiceover_opportunity( self): voiceover_services.create_new_voiceover_application( suggestion_models.TARGET_TYPE_EXPLORATION, '0', 'en', '', 'audio_file.mp3', self.applicant_id) user_voiceover_applications = ( voiceover_services.get_user_submitted_voiceover_applications( self.applicant_id)) self.assertEqual(len(user_voiceover_applications), 1) self.assertEqual(user_voiceover_applications[0].status, suggestion_models.STATUS_IN_REVIEW) opportunities, _, more = ( opportunity_services.get_voiceover_opportunities('en', None)) self.assertEqual(len(opportunities), 1) self.assertFalse(more) voiceover_services.accept_voiceover_application( user_voiceover_applications[0].voiceover_application_id, self.admin_id) user_voiceover_applications = ( voiceover_services.get_user_submitted_voiceover_applications( self.applicant_id, status=suggestion_models.STATUS_ACCEPTED)) self.assertEqual(len(user_voiceover_applications), 1) self.assertEqual(user_voiceover_applications[0].status, suggestion_models.STATUS_ACCEPTED) opportunities, _, more = ( opportunity_services.get_voiceover_opportunities('en', None)) self.assertEqual(len(opportunities), 0) self.assertFalse(more)
def get(self, opportunity_type): """Handles GET requests.""" if not feconf.COMMUNITY_DASHBOARD_ENABLED: raise self.PageNotFoundException search_cursor = self.request.get('cursor', None) if opportunity_type == constants.OPPORTUNITY_TYPE_TRANSLATION: language_code = self.request.get('language_code') if language_code is None or not ( utils.is_supported_audio_language_code(language_code)): raise self.InvalidInputException opportunities, next_cursor, more = ( opportunity_services.get_translation_opportunities( language_code, search_cursor)) elif opportunity_type == constants.OPPORTUNITY_TYPE_VOICEOVER: language_code = self.request.get('language_code') if language_code is None or not ( utils.is_supported_audio_language_code(language_code)): raise self.InvalidInputException opportunities, next_cursor, more = ( opportunity_services.get_voiceover_opportunities( language_code, search_cursor)) else: raise self.PageNotFoundException self.values = { 'opportunities': opportunities, 'next_cursor': next_cursor, 'more': more } self.render_json(self.values)
def _get_voiceover_opportunity_dicts(self, language_code, search_cursor): """Returns a list of voiceover opportunity dicts. Args: language_code: str. The language for which voiceover opportunities should be fetched. search_cursor: str or None. If provided, the list of returned entities starts from this datastore cursor. Otherwise, the returned entities start from the beginning of the full list of entities. Returns: 3-tuple(opportunities, cursor, more). where: opportunities: list(dict). A list of ExplorationOpportunitySummary dicts. cursor: str or None. A query cursor pointing to the next batch of results. If there are no more results, this might be None. more: bool. If True, there are (probably) more results after this batch. If False, there are no further results after this batch. """ opportunities, next_cursor, more = ( opportunity_services.get_voiceover_opportunities( language_code, search_cursor)) opportunity_dicts = [opp.to_dict() for opp in opportunities] return opportunity_dicts, next_cursor, more