def get(self, target_email):
        cur_user = users.get_current_user()
        if not account_facade.is_admin(cur_user):
            self.redirect(constants.HOME_URL)

        target_user_info = models.UserInfo.get_for_email(target_email)
        target_user_info.is_reviewer = True
        target_user_info.put()

        account_facade.set_flash_message(
            cur_user.email(),
            constants.FLASH_MSG_TYPE_CONFIRMATION,
            constants.FLASH_MSG_USER_MADE_REVIEWER % target_email
        )

        self.redirect("/administer")
    def get(self):
        """
        GET request handler that ensures a user has a models.UserInfo record.

        GET request handler that checks that a user has a models.UserInfo
        record, creating it if it does not already exit. All users are then
        redirected to the page specified by util.get_user_home.
        """
        cur_user = users.get_current_user()
        target_email = cur_user.email()

        if not util.check_email(target_email):
            account_facade.set_flash_message(
                target_email,
                constants.FLASH_MSG_TYPE_ERR,
                constants.FLASH_MSG_INVALID_EMAIL
            )
            self.redirect(constants.HOME_URL)
        else:
            account_facade.ensure_user_info(cur_user)
            self.redirect(util.get_user_home(cur_user))
    def post(self, profile_email, section_name):
        """
        POST handler for adding a priate comment to a portfolio section.

        @param profile_email: The email address of the user whose portfolio
                              should recieve the new comment.
        @type profile_email: str
        @param section_name: The name of the portfolio section to add the new
                             comment to.
        @type section_name: str
        """
        cur_user = users.get_current_user()
        if not account_facade.viewer_has_access(cur_user, profile_email):
            self.redirect(constants.HOME_URL)

        raw_comment_contents = self.request.get("comment-contents", "")
        comment_contents = cgi.escape(raw_comment_contents)
        comment_contents = "<br>".join(comment_contents.splitlines())

        new_comment = models.Comment()
        new_comment.author_email = cur_user.email()
        new_comment.profile_email = profile_email
        new_comment.section_name = section_name
        new_comment.contents = comment_contents
        new_comment.timestamp = datetime.datetime.now()
        new_comment.put()

        account_facade.set_viewed(cur_user, profile_email, section_name)

        account_facade.set_flash_message(
            cur_user.email(),
            constants.FLASH_MSG_TYPE_CONFIRMATION,
            constants.FLASH_MSG_ADDED_COMMENT
        )

        self.redirect(self.request.path)