コード例 #1
0
    def get(self, profile_email):
        """
        GET request handler that renders a profile overview page.

        @param profile_email: The email address of the user whose profile's
                              overview page should be rendered.
        @type profile_email: str
        """
        cur_user = users.get_current_user()
        if not account_facade.viewer_has_access(cur_user, profile_email):
            self.redirect(constants.HOME_URL)

        section_statuses = account_facade.get_updated_sections(
            cur_user, profile_email)
        sections = constants.PORTFOLIO_SECTIONS
        account_facade.set_viewed(cur_user, profile_email, None)

        template = jinja_environment.get_template("portfolio_overview.html")
        template_vals = get_standard_template_dict()
        owner_name = util.get_full_name_from_email(profile_email)
        template_vals["profile_safe_email"] = util.sanitize_email(profile_email)
        template_vals["cur_section"] = "overview"
        template_vals["owner_name"] = " ".join(owner_name)
        template_vals["owner_first_name"] = owner_name[0]
        template_vals["owner_last_name"] = owner_name[1]
        template_vals["sections"] = sections
        template_vals["section_statuses"] = section_statuses
        content = template.render(template_vals)
        self.response.out.write(content)
コード例 #2
0
    def test_get_updated_sections(self):
        """Test listing of unread comments / updated portfolio sections."""
        user_1 = FakeUser("*****@*****.**")
        user_2 = FakeUser("*****@*****.**")
        profile_email = "safe_email"
        section_1_name = "section1"
        section_2_name = "section2"
        contents_1 = "test contents 1"
        contents_2 = "test contents 2"
        test_timestamp_1 = datetime.datetime(2000, 1, 2)
        test_timestamp_2 = datetime.datetime(2003, 4, 5)
        viewing_timestamp = datetime.datetime(2001, 4, 5)

        test_comment_1 = models.Comment()
        test_comment_1.author_email = user_1.email()
        test_comment_1.profile_email = profile_email
        test_comment_1.section_name = section_1_name
        test_comment_1.contents = contents_1
        test_comment_1.timestamp = test_timestamp_1
        test_comment_1.put()

        test_comment_2 = models.Comment()
        test_comment_2.author_email = user_2.email()
        test_comment_2.profile_email = profile_email
        test_comment_2.section_name = section_2_name
        test_comment_2.contents = contents_2
        test_comment_2.timestamp = test_timestamp_2
        test_comment_2.put()

        viewing_profile = models.ViewingProfile()
        viewing_profile.viewer_email = user_1.email()
        viewing_profile.profile_email = profile_email
        viewing_profile.section_name = section_1_name
        viewing_profile.last_visited = viewing_timestamp
        viewing_profile.put()

        updated_listing = account_facade.get_updated_sections(user_1,
            profile_email)
        self.assertIn(section_2_name, updated_listing)
        self.assertEqual(updated_listing[section_2_name], 1)
コード例 #3
0
    def get(self, profile_email, section_name):
        """
        GET request handler that renders the private comments for a section.

        @param profile_email: The email address of the user whose portfolio's
                              comments should be displayed.
        @type profile_email: str
        @param section_name: The name of the portfolio section to render
                             comments for.
        @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)

        new_comments = account_facade.get_new_comments(
            cur_user, profile_email, section_name)
        old_comments = account_facade.get_old_comments(
            cur_user, profile_email, section_name)

        section_statuses = account_facade.get_updated_sections(
            cur_user, profile_email)
        sections = constants.PORTFOLIO_SECTIONS
        account_facade.set_viewed(cur_user, profile_email, section_name)

        template = jinja_environment.get_template("portfolio_section.html")
        template_vals = get_standard_template_dict()
        owner_name = util.get_full_name_from_email(profile_email)
        template_vals["profile_safe_email"] = util.sanitize_email(profile_email)
        template_vals["cur_section"] = section_name
        template_vals["owner_name"] = " ".join(owner_name)
        template_vals["owner_first_name"] = owner_name[0]
        template_vals["owner_last_name"] = owner_name[1]
        template_vals["sections"] = sections
        template_vals["section_statuses"] = section_statuses
        template_vals["new_comments"] = new_comments
        template_vals["old_comments"] = old_comments
        content = template.render(template_vals)
        self.response.out.write(content)