Ejemplo n.º 1
0
    def put(self):
        # type: () -> None
        """Handles PUT requests."""
        username = self.normalized_payload.get('username')
        user_id = user_services.get_user_id_from_username(username)
        if user_id is None:
            raise self.InvalidInputException('Invalid username: %s' % username)

        user_services.remove_user_role(user_id,
                                       feconf.ROLE_ID_BLOG_POST_EDITOR)
        blog_services.deassign_user_from_all_blog_posts(user_id)
        self.render_json({})
Ejemplo n.º 2
0
 def test_raise_exception_if_username_provided_is_not_of_author(self):
     self.login(self.user_email)
     self.get_json(
         '%s/%s' % (
             feconf.AUTHOR_SPECIFIC_BLOG_POST_PAGE_URL_PREFIX,
             self.BLOG_ADMIN_USERNAME),
         )
     user_services.remove_user_role(
         self.blog_admin_id, feconf.ROLE_ID_BLOG_ADMIN)
     self.get_json(
         '%s/%s' % (
             feconf.AUTHOR_SPECIFIC_BLOG_POST_PAGE_URL_PREFIX,
             self.BLOG_ADMIN_USERNAME),
         expected_status_int=404)
Ejemplo n.º 3
0
    def delete(self):
        username = self.request.get('username')
        role = self.request.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.')

        if role == feconf.ROLE_ID_TOPIC_MANAGER:
            topic_services.deassign_user_from_all_topics(self.user, user_id)

        user_services.remove_user_role(user_id, role)

        self.render_json({})