blob: 3dd52c2617cff504ba959c9ef01eadb66d027304 [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is govered by a BSD-style
# license that can be found in the LICENSE file or at
"""Classes for the user projects feed."""
from framework import jsonfeed
from sitewide import sitewide_helpers
class ProjectsJsonFeed(jsonfeed.JsonFeed):
"""Servlet to get all of a user's projects in JSON format."""
def HandleRequest(self, mr):
"""Retrieve list of a user's projects for the "My projects" menu.
mr: common information parsed from the HTTP request.
Results dictionary in JSON format
if not mr.auth.user_id:
return {'error': 'User is not logged in.'}
json_data = {}
with self.profiler.Phase('page processing'):
return json_data
def _GatherProjects(self, mr):
"""Return a dict of project names the current user is involved in."""
with self.profiler.Phase('GetUserProjects'):
project_lists = sitewide_helpers.GetUserProjects(
mr.cnxn,, mr.auth.user_pb, mr.auth.effective_ids,
(visible_ownership, _visible_deleted, visible_membership,
visible_contrib) = project_lists
with self.profiler.Phase('GetStarredProjects'):
starred_projects = sitewide_helpers.GetViewableStarredProjects(
mr.cnxn,, mr.auth.user_id,
mr.auth.effective_ids, mr.auth.user_pb)
projects_dict = {
'memberof': [p.project_name for p in visible_membership],
'ownerof': [p.project_name for p in visible_ownership],
'contributorto': [p.project_name for p in visible_contrib],
'starred_projects': [p.project_name for p in starred_projects],
return projects_dict