def put(self): username = self.normalized_payload.get('username') action = self.normalized_payload.get('action') topic_id = self.normalized_payload.get('topic_id') user_settings = user_services.get_user_settings_from_username(username) if user_settings is None: raise self.InvalidInputException( 'User with given username does not exist.') user_id = user_settings.user_id if action == 'assign': if not feconf.ROLE_ID_TOPIC_MANAGER in user_settings.roles: user_services.add_user_role(user_id, feconf.ROLE_ID_TOPIC_MANAGER) topic_manager = user_services.get_user_actions_info(user_id) topic_services.assign_role(user_services.get_system_user(), topic_manager, topic_domain.ROLE_MANAGER, topic_id) elif action == 'deassign': topic_services.deassign_manager_role_from_topic( user_services.get_system_user(), user_id, topic_id) if not topic_fetchers.get_topic_rights_with_user(user_id): user_services.remove_user_role(user_id, feconf.ROLE_ID_TOPIC_MANAGER) self.render_json({})
def setUp(self): """Completes the sign-up process for self.VOICE_ARTIST_EMAIL.""" super(VoiceArtistManagementTests, self).setUp() self.signup(self.OWNER_EMAIL, self.OWNER_USERNAME) self.signup(self.VOICE_ARTIST_EMAIL, self.VOICE_ARTIST_USERNAME) self.signup(self.VOICEOVER_ADMIN_EMAIL, self.VOICEOVER_ADMIN_USERNAME) self.owner_id = self.get_user_id_from_email(self.OWNER_EMAIL) self.voice_artist_id = self.get_user_id_from_email( self.VOICE_ARTIST_EMAIL) self.voiceover_admin_id = self.get_user_id_from_email( self.VOICEOVER_ADMIN_EMAIL) self.owner = user_services.get_user_actions_info(self.owner_id) self.save_new_valid_exploration( self.published_exp_id_1, self.owner_id) self.save_new_valid_exploration( self.published_exp_id_2, self.owner_id) self.save_new_valid_exploration( self.private_exp_id_1, self.owner_id) self.save_new_valid_exploration( self.private_exp_id_2, self.owner_id) rights_manager.publish_exploration(self.owner, self.published_exp_id_1) rights_manager.publish_exploration(self.owner, self.published_exp_id_2) user_services.add_user_role( self.voiceover_admin_id, feconf.ROLE_ID_VOICEOVER_ADMIN)
def setUp(self): super(TranslationContributionStatsHandlerTest, self).setUp() self.signup(self.CURRICULUM_ADMIN_EMAIL, self.CURRICULUM_ADMIN_USERNAME) self.signup(self.CONTRIBUTOR_EMAIL, self.CONTRIBUTOR_USERNAME) self.admin_id = self.get_user_id_from_email(self.CURRICULUM_ADMIN_EMAIL) self.contributor_id = self.get_user_id_from_email( self.CONTRIBUTOR_EMAIL) self.login(self.CURRICULUM_ADMIN_EMAIL, is_super_admin=True) self.set_curriculum_admins([self.CURRICULUM_ADMIN_USERNAME]) user_services.add_user_role( self.contributor_id, feconf.ROLE_ID_TRANSLATION_ADMIN)
def setUp(self): super(ContributorDashboardAdminPageTest, self).setUp() self.signup(self.USER_A_EMAIL, 'userA') self.signup(self.TRANSLATION_ADMIN_EMAIL, 'translationExpert') self.signup(self.QUESTION_ADMIN_EMAIL, 'questionExpert') user_services.add_user_role( self.get_user_id_from_email(self.QUESTION_ADMIN_EMAIL), feconf.ROLE_ID_QUESTION_ADMIN) user_services.add_user_role( self.get_user_id_from_email(self.TRANSLATION_ADMIN_EMAIL), feconf.ROLE_ID_TRANSLATION_ADMIN)
def setUp(self): super(ContributionRightsDataHandlerTest, self).setUp() self.signup(self.REVIEWER_EMAIL, 'reviewer') self.signup(self.TRANSLATION_ADMIN, 'translationAdmen') self.signup(self.QUESTION_ADMIN, 'questionAdmen') user_services.add_user_role( self.get_user_id_from_email(self.TRANSLATION_ADMIN), feconf.ROLE_ID_TRANSLATION_ADMIN) user_services.add_user_role( self.get_user_id_from_email(self.QUESTION_ADMIN), feconf.ROLE_ID_QUESTION_ADMIN) self.reviewer_id = self.get_user_id_from_email(self.REVIEWER_EMAIL)
def post(self) -> None: """Handles POST requests.""" username = self.normalized_payload.get('username') role = self.normalized_payload.get('role') user_id = user_services.get_user_id_from_username(username) if user_id is None: raise self.InvalidInputException( 'User with given username does not exist.') user_services.add_user_role(user_id, role) role_services.log_role_query( self.user_id, feconf.ROLE_ACTION_ADD, role=role, username=username) self.render_json({})
def setUp(self): super(ContributorUsersListHandlerTest, self).setUp() self.signup(self.TRANSLATION_REVIEWER_EMAIL, 'translator') self.signup(self.QUESTION_REVIEWER_EMAIL, 'question') self.signup(self.TRANSLATION_ADMIN_EMAIL, 'translationAdmen') self.signup(self.QUESTION_ADMIN_EMAIL, 'questionAdmen') self.translation_reviewer_id = self.get_user_id_from_email( self.TRANSLATION_REVIEWER_EMAIL) self.question_reviewer_id = self.get_user_id_from_email( self.QUESTION_REVIEWER_EMAIL) user_services.add_user_role( self.get_user_id_from_email(self.TRANSLATION_ADMIN_EMAIL), feconf.ROLE_ID_TRANSLATION_ADMIN) user_services.add_user_role( self.get_user_id_from_email(self.QUESTION_ADMIN_EMAIL), feconf.ROLE_ID_QUESTION_ADMIN)
def put(self): username = self.payload.get('username') role = self.payload.get('role') user_settings = user_services.get_user_settings_from_username(username) if user_settings is None: raise self.InvalidInputException( 'User with given username does not exist.') if role == feconf.ROLE_ID_TOPIC_MANAGER: # The Topic manager role assignment is handled via # TopicManagerRoleHandler. raise self.InvalidInputException( 'Unsupported role for this handler.') user_services.add_user_role(user_settings.user_id, role) self.render_json({})